Hello Everybody,
I have been playing around with the heap functions and have seen
something that doesn't make sense. I have included an example of
the code below.
Heres the problem, HeapCreate should preallocate a block of memory
from which HeapAlloc can request a portion. When I create my own
heap the task manager reports that X amount has been allocated(OK).
but when I call HeapAlloc to request memory from my own heap the
tasm manager reports that even more memory get allocated.
HeapCreate(5000000 bytes) Task manager shows increase of ~5000000 bytes
HeapAlloc(myheap,2000000) Task manager shows increase of ~2000000 bytes
As I understand it this shouldn't happen until I request more memory
than what I reserved with HeapCreate.
Any help on this would be greatly appreciated!
------------------
Cheers
I have been playing around with the heap functions and have seen
something that doesn't make sense. I have included an example of
the code below.
Heres the problem, HeapCreate should preallocate a block of memory
from which HeapAlloc can request a portion. When I create my own
heap the task manager reports that X amount has been allocated(OK).
but when I call HeapAlloc to request memory from my own heap the
tasm manager reports that even more memory get allocated.
HeapCreate(5000000 bytes) Task manager shows increase of ~5000000 bytes
HeapAlloc(myheap,2000000) Task manager shows increase of ~2000000 bytes
As I understand it this shouldn't happen until I request more memory
than what I reserved with HeapCreate.
Code:
#compile exe #register none %HEAP_NO_SERIALIZE = &h00000001 %HEAP_GROWABLE = &h00000002 %HEAP_GENERATE_EXCEPTIONS = &h00000004 %HEAP_ZERO_MEMORY = &h00000008 declare function HeapFree lib "KERNEL32.DLL" alias "HeapFree" (byval long,byval long,any) as long declare function HeapAlloc lib "KERNEL32.DLL" alias "HeapAlloc" (byval long,byval long,byval long) as long declare function HeapCreate lib "KERNEL32.DLL" alias "HeapCreate" (byval long,byval long,byval long) as long declare function HeapDestroy lib "KERNEL32.DLL" alias "HeapDestroy" (byval long) as long function pbmain as long local Heap as long local Memory as long rem create 20mb heap Heap = HeapCreate(%HEAP_ZERO_MEMORY,20000000,0) msgbox str$(Heap) rem Task manager memory usage increases by 20mb rem allocate 5mb from our heap Memory = HeapAlloc(Heap,0,5000000) msgbox str$(Heap) rem For some reason task manager increases again? rem I dont think this should happen because I have rem already set allocated the space in the heap rem free memory block HeapFree Heap,0,byval Memory msgbox "done" rem ddestroy heap HeapDestroy Heap end function
Any help on this would be greatly appreciated!
------------------
Cheers
Comment