|
-
February 7th, 2004, 04:56 AM
#1
Doubt on HeapAlloc
hi,
I have a doubt on HeapFree Function.
We do the heap allocation like this.
pV = HeapAlloc(Mem, HEAP_ZERO_MEMORY , ulSize);
When we do the heap free
HeapFree(Mem, 0, pV);
does this freeing memory has by any chance corrupt the memeory. What actually happens when the HeapFree function in called? is the the memory that is released by this HeapFree can be reused till the Heap is destroyed?
Thanks in Advance,
Varadha
-
February 7th, 2004, 06:54 AM
#2
Re: Doubt on HeapAlloc
Originally posted by Varadha
does this freeing memory has by any chance corrupt the memeory.
What do you mean by "corrupt the memory"? Are you asking if the heap (generally) will become corrupted or if the freed memory becomes corrupted? The heap itself shouldn't get corrupted but the freed memory shouldn't be reused until it has been reallocated.
-
February 7th, 2004, 07:15 AM
#3
Re: Doubt on HeapAlloc
Originally posted by Varadha
is the the memory that is released by this HeapFree can be reused till the Heap is destroyed?
No. Once you have freed a memory block, consider it "invalid". This doesn't apply only to the HeapXxx functions, but to all memory allocation mechanisms. Accessing freed memory yields in undefined behaviour and is a no-no in all circumstancies.
-
February 8th, 2004, 11:23 PM
#4
I am allocationg the memory in the HeapAlloc function. If i call HeapDestroy fo the heap without freeing the memory by HeapFree is this causes any problem.
-
February 8th, 2004, 11:42 PM
#5
I am allocationg memory using the HeapAlloc function. If i call HeapDestroy before freeing the heap created using HeapFree function, can any error may arise due to this.
i.e
hHeap = HeapCreate(0, 1000000, 0);
pV = HeapAlloc(hHeap, HEAP_ZERO_MEMORY , ulSize);
HeapDestroy(hHeap);
here before freeing pV, we are Destroying the Heap. Is this causes any problem.
-
February 9th, 2004, 02:06 AM
#6
http://msdn.microsoft.com/library/de...eapdestroy.asp
Remarks
Processes can call HeapDestroy without first calling the HeapFree function to free memory allocated from the heap.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|