I have having problems with the HeapAlloc, etc., memory routines and would
like to try using the VirtualAlloc, etc., routines instead.
But why is there no "VirtualReAlloc" corresponding to the "HeapReAlloc" routine?
-- how do I change the size of my allocated memory?
And why is there no "VirtualSize" corresponding to the "HeapSize" routine?
-- how do I get the size of my allocated memory?
Thank you!!!
Kevin Killion
ke...@shsmedia.com
Because their tasks are different enough that it doesn't make sense.
VirtualAlloc is mostly a tool to manipulate virtual memory mappings.
Sometimes this does allocate space in the swap file or other backing
store, but that's incidental and the backing store isn't necessarily
in a one-to-one correspondence to the virtual address space allocated.
VirtualAlloc is in a sense on a lower level than the other memory
allocation routines: the others will use VirtualAlloc to divide the
address space between them.
> -- how do I change the size of my allocated memory?
You can achieve the effect simply by asking for another block next to
the one you've got (using the first argument). If that fails, you
need to move the object.
> And why is there no "VirtualSize" corresponding to the "HeapSize" routine?
> -- how do I get the size of my allocated memory?
It's not convenient for the OS to track this info, you need to keep
track of the sizes of your data objects yourself. Note that the
granularity of VirtualAlloc is large (depends on the platform, on
Wintel 8 kB for commit and 64 kB for reserve, see GetSystemInfo) --
it's a low-level routine.
--
Pekka P. Pirinen, Adaptive Memory Management Group, Harlequin Limited
The Memory Management Reference: articles, bibliography, glossary, news
<URL:http://www.xanalys.com/software_tools/mm/>
> ....
> Note that the
> granularity of VirtualAlloc is large (depends on the platform, on
> Wintel 8 kB for commit and 64 kB for reserve, see GetSystemInfo) --
> it's a low-level routine.
Thanks for all your suggestions. I'll work on it. But, the more I get
into it, and with your tips, the more I realize that the Virtualxxx
routines may not be the best for what I need.
I was just hoping that by switching to another set of memory routines I
could get around the crash problem I was having using HeapAlloc and
HeapFree. (I made a separate posting about that -- I'm crashing on the
HeapFree call (of all things), and only when running under NT.)
Thanks again,
Kevin
P.S. Is your name Finnish? My wife has been to Finland twice, and raves
about the people and the country!