Reputation: 1
After going through the link I could not get the purpose of using this api.
I am using the below call in our code.
ULONG heapInfo = 2 ;
HeapSetInformation( GetProcessHeap(),HeapCompatibilityInformation,&heapInfo, sizeof( heapInfo ) )
As per second arg, the above link says: Enables heap features. Only the low-fragmentation heap (LFH) is supported. However, it is not necessary for applications to enable the LFH because the system uses the LFH as needed to service memory allocation requests.
My question:
1)
Can you please help me understand the meaning of this api HeapSetInformation
() and the purpose of second argument(HeapCompatibilityInformation
) in this api? I could not understand the meaning of LFH here.
Upvotes: 1
Views: 478
Reputation: 5741
These are pretty low level memory management API provided on MS Platform. You should not try to use these API unless it is absolutely required and we fully understand about this.
Now, regarding your question:
Meaning of this api HeapSetInformation()?
This Enables features for a specified heap. Now each process maintains the number of heap segments. One is known as default heap segment. GetProcessHeap() API returns the handle of that default heap segment. The feature would be decided by the second argument of this API.
Purpose of second argument(HeapCompatibilityInformation) in this API?
This decides the type of feature can be set to a particular heap segment. Currently two feature is supported:
You can read detail about these from MSDN link. LFH(Low-fragmentation-heap) is policy which would be applied by system for process heap segment. However MSDN documentation clearly mention that system would take care about these stuff and hence we should not try to set/change these attributes by yourself.
However, it is not necessary for applications to enable the LFH because the system uses the LFH as needed to service memory allocation requests.
If you really want to understand about these stuff in detail, please read the classic book "Advanced Windows Debugging, Author: By: Mario Hewardt; Daniel Pravat" Chapter 06. This cover almost everything about how system manage heap segment and various other low lever concept managed on Windows based system.
http://advancedwindowsdebugging.com/ch06.pdf
Upvotes: 0
Reputation: 613013
The API sets properties of the heap. The second property identifies which property to set.
The property you are discussing is whether or not the low fragmentation heap is used. On Vista and later that's all there is so the property has no impact. On XP this property can be used to request the low fragmentation heap.
The low fragmentation heap is described here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366750.aspx
Upvotes: 2