mirror of
https://github.com/Chatterino/chatterino2.git
synced 2026-08-24 02:24:18 -05:00
build(windows): Enable segment heap if possible (#7142)
With Visual Studio 2026 18.6, Microsoft included a script to easily enable the segment heap for apps ([blog](https://devblogs.microsoft.com/cppblog/segment-heap-support-for-c-projects-in-visual-studio/)). The segment heap was already available for some years, but it hasn't been enabled by default. With the provided script we can add a manifest to enable it. In my basic testing it reduced the memory usage from ~75MiB to ~70MiB with one tab and 4 messages. So it should be a free win for us. Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -15,6 +15,10 @@ list(APPEND CMAKE_MODULE_PATH
|
||||
"${CMAKE_SOURCE_DIR}/cmake"
|
||||
)
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
include(EnableSegmentHeap)
|
||||
endif()
|
||||
|
||||
option(BUILD_APP "Build Chatterino" ON)
|
||||
option(BUILD_TESTS "Build the tests for Chatterino" OFF)
|
||||
option(BUILD_BENCHMARKS "Build the benchmarks for Chatterino" OFF)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# SPDX-FileCopyrightText: 2026 Contributors to Chatterino <https://chatterino.com>
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
if(NOT DEFINED ENV{VSINSTALLDIR})
|
||||
message(WARNING "Missing VSINSTALLDIR environment variable - not enabling segment heap.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(segment_heap_path "$ENV{VSINSTALLDIR}Common7/IDE/CommonExtensions/Microsoft/CMake/cmake/Microsoft/SegmentHeap.cmake")
|
||||
if (NOT EXISTS "${segment_heap_path}")
|
||||
message(STATUS "Missing '${segment_heap_path}'. Segment heap will be disabled - consider updating Visual Studio.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Including segment heap script from '${segment_heap_path}'.")
|
||||
include("${segment_heap_path}")
|
||||
Reference in New Issue
Block a user