Can I have the same effect as with HeapCompact()
for the Visual C++ runtime heap? How can I achieve that?
views:
105answers:
2
+2
A:
IIRC not without writing your own memory manager. It's also a non-trivial piece of work, especially if you expect to do more than just combining adjacent smaller empty memory blocks into larger ones.
Timo Geusch
2010-03-10 10:59:39
In fact combining adjacent blocks is the only thing HeapCompact() does.
sharptooth
2010-03-10 13:37:32
You'd have to *really* need to do this for there not to be a better idea.
Spike
2010-03-10 14:24:35
+2
A:
You can get a HANDLE for the CRT heap using _get_heap_handle, then call HeapCompact on it. Not sure whether this is supported/stable as I have not tried this myself. I imagine you would want to call HeapCompact in serialized mode to have any chance of this working.
If you are going to this trouble just call HeapSetInformation on the handle (per MDSN docs on _get_heap_handle) and let the built-in LFH handle compaction for you.
Steve Townsend
2010-03-10 14:26:56