Skip to content

Conversation

@goodusername123
Copy link
Contributor

Use Segment Heaps for memory (de)allocation if available via manifest opt-in. This applies to Win10 version 2004 and newer (such as Win11) otherwise falls back to the default NT Heaps. https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#heaptype

Testing shows that this reduces memory usage a little bit. attributes related to memory fragmentation have not been tested however Segment heaps are supposedly better in this regard as well.

!heap in WinDbg can be used to confirm that the memory heaps of the process(es) are indeed being allocated with the newer heap type.

Use Segment Heaps for memory (de)allocation if available via manifest opt-in (applies to Win10 version 2004 and newer (such as Win11) otherwise falls back to the default NT Heaps).
https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#heaptype
@hpwamr hpwamr requested a review from RaiKoHoff November 20, 2025 17:49
Copy link
Owner

@rizonesoft rizonesoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Analysis

No executable code | ✅ Only XML manifest modifications
No new dependencies | ✅ Uses built-in Windows feature
Official Microsoft API | ✅ Documented by Microsoft
Backward compatible | ✅ Falls back to NT Heaps on older Windows
No hidden characters | ✅ Clean diff

Technical Benefits

  • Memory reduction: Segment Heap is a modern heap implementation that reduces overall memory usage
  • Less fragmentation: Improved memory allocation strategy
  • Windows 10 2004+ only: On older systems, Windows ignores the setting and uses the default NT Heap

Compatibility

  • Windows 10 version 2004+ / Windows 11: Uses Segment Heap
  • Older Windows versions: Gracefully ignored, uses standard NT Heap

Verdict

This is a low-risk, high-value optimization. The change is minimal, uses an official Microsoft manifest setting, and provides automatic fallback for older systems. Recommended to merge. 👍

@rizonesoft rizonesoft merged commit 65c2b11 into rizonesoft:master Jan 17, 2026
1 check passed
@hpwamr hpwamr removed the request for review from RaiKoHoff January 17, 2026 18:45
rizonesoft added a commit that referenced this pull request Jan 17, 2026
Changes:
- Moved installer scripts to Build\Installer folder with local language files
- Fixed user config setup to run as original user context (ExecAsOriginalUser)
- Added Segment Heap memory optimization (PR #5490)
- Updated .gitignore to exclude .agent folder
- Created todo folder with Scintilla/Lexilla upgrade research
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants