I've been using heap memory for a long while without problems.
Just recently, I've been using heap memory more intensively.
I create my own heap with HeapCreate, no flags, at 100,000 bytes.

The problem I'm having is with HeapRealloc - I have certain objects which need to grow on demand.
Sometimes it refuses to resize (larger) a block of memory.
My response is to first call HeapCompact and then try again.
HeapCompact is handy because it returns the size of the largest non-allocated (available) block of memory.
I can see there's plenty of heap space, and I try to reallocate my block again.
Again I fail, so now I try to allocate a new block of the larger size, in order to "clone" the data from one block to the other.
This succeeds, I copy my data, then I crash when I try to free the old block... any ideas why?

(note - if the size increases are substantial, the initial reallocation seems to always succeed - its only where I try to "creep" the object size that there's a problem - what IS the granularity for heap objects, sizes like 1044 are acceptable and verifiable via HeapSize)
Posted on 2005-03-08 20:28:43 by Homer