{"id":36509,"date":"2026-05-14T16:09:51","date_gmt":"2026-05-14T16:09:51","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=36509"},"modified":"2026-05-14T16:09:51","modified_gmt":"2026-05-14T16:09:51","slug":"segment-heap-support-for-c-projects-in-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/segment-heap-support-for-c-projects-in-visual-studio\/","title":{"rendered":"Segment Heap support for C++ projects in Visual Studio"},"content":{"rendered":"<p>Visual Studio 2026 version 18.6 makes it easier to take advantage of modern Windows memory management improvements. <a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/sbscs\/application-manifests#heaptype\">Segment Heap<\/a> is a modern heap implementation in Windows that delivers stronger protection against common memory vulnerabilities, higher allocation throughput, lower memory fragmentation, better scalability across cores, and more predictable performance under load. Starting with this release, <strong>new C++ projects are now configured to use Segment Heap by default<\/strong>.<\/p>\n<h2>Onboarding your project to use the Segment Heap<\/h2>\n<p><strong>New C++ projects come with Segment Heap enabled by default.<\/strong> For existing projects, follow the steps below to enable it.<\/p>\n<p>For MSBuild solution-based C++ projects, the project property is located at <strong>Project -&gt; Properties -&gt; Manifest Tool -&gt; Input and Output -&gt; Enable Segment Heap<\/strong>. You can opt into the segment heap on a per-project basis, allowing you to onboard at your own pace.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/05\/property_pages_ss.webp\" alt=\"Property Pages\" \/><\/p>\n<p>For CMake users, Visual Studio provides a helper script, <strong>SegmentHeap.cmake<\/strong>, that integrates Segment Heap into your build automatically. If you manage your configuration through CMakePresets, you can enable Segment Heap by setting <code>CMAKE_PROJECT_TOP_LEVEL_INCLUDES<\/code>. Optionally, you can use the <code>VS_SEGMENT_HEAP_ALLOWLIST<\/code> and <code>VS_SEGMENT_HEAP_EXCLUDE<\/code> environment variables in the same preset to control which targets opt in:<\/p>\n<pre><code class=\"language-json\">{\r\n    \"name\": \"foo\",\r\n    \"displayName\": \"Foo\",\r\n    \"inherits\": \"\",\r\n    \"environment\": {\r\n        \"VS_SEGMENT_HEAP_ALLOWLIST\": \"target1;target2;\",\r\n        \"VS_SEGMENT_HEAP_EXCLUDE\": \"target3;\"\r\n    },\r\n    \"cacheVariables\": {\r\n        \"CMAKE_PROJECT_TOP_LEVEL_INCLUDES\": \"$env{VSINSTALLDIR}Common7\/IDE\/CommonExtensions\/Microsoft\/CMake\/cmake\/Microsoft\/SegmentHeap.cmake\"\r\n    }\r\n}<\/code><\/pre>\n<p>In this example, the optional <code>VS_SEGMENT_HEAP_ALLOWLIST<\/code> variable limits Segment Heap to <code>target1<\/code> and <code>target2<\/code>, while the optional <code>VS_SEGMENT_HEAP_EXCLUDE<\/code> variable keeps it disabled for <code>target3<\/code>. This gives you fine-grained control over which targets in the project use Segment Heap when you need it.<\/p>\n<p>Segment Heap integration is designed to coexist cleanly with existing toolchains and build configurations. It integrates into the standard linker + manifest tool flow, and it avoids introducing custom build steps or requiring changes to your toolchain configuration. This design ensures that Segment Heap adoption is low-risk and does not interfere with existing build logic.<\/p>\n<h2>How to check if Segment Heap is enabled<\/h2>\n<p>You can verify whether Segment Heap is enabled by checking the final application manifest embedded in your executable. Open the executable directly in Visual Studio, inspect the <strong>RT_MANIFEST<\/strong> resource for the following entry:<\/p>\n<pre><code class=\"language-xml\">&lt;heapType&gt;SegmentHeap&lt;\/heapType&gt;<\/code><\/pre>\n<p>This indicates that the Segment Heap is active for your application.<\/p>\n<p>Alternatively, you can open a <strong>Developer Command Prompt for Visual Studio<\/strong>, extract the embedded manifest with <code>mt<\/code>, and then open the generated manifest file in Visual Studio, and locate the same entry there.<\/p>\n<p>For example:<\/p>\n<pre><code class=\"language-bat\">mt.exe -inputresource:YourApp.exe;#1 -out:YourApp.manifest<\/code><\/pre>\n<p>Because Segment Heap is enabled via manifest embedding, the presence of this declaration in the final binary confirms that the feature is in effect.<\/p>\n<h2>Get started and share your feedback<\/h2>\n<p>We encourage you to download <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio 2026 version 18.6 Stable<\/a> to start using Segment Heap in your C++ projects. Whether you&#8217;re creating a new project or onboarding an existing one, we&#8217;d love to hear how it goes. You can reach us through <strong>Help &gt; Send Feedback<\/strong> in the Visual Studio IDE or by posting on <a href=\"https:\/\/developercommunity.visualstudio.com\/VisualStudio\">Developer Community<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how Visual Studio enables Segment Heap by default for new C++ projects and how to adopt and verify it in existing builds.<\/p>\n","protected":false},"author":190345,"featured_media":35743,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,1,3958],"tags":[185],"class_list":["post-36509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-cplusplus","category-visual-studio","tag-visual-studio"],"acf":[],"blog_post_summary":"<p>Learn how Visual Studio enables Segment Heap by default for new C++ projects and how to adopt and verify it in existing builds.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/36509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/190345"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=36509"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/36509\/revisions"}],"predecessor-version":[{"id":36511,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/36509\/revisions\/36511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35743"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=36509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=36509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=36509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}