[Gc] Re: Want to find reason of heap size keep growth
bruce at hoult.org
Thu Jul 8 20:27:17 PDT 2010
On Fri, Jul 9, 2010 at 3:10 PM, biosli <biosli at hotmail.com> wrote:
> GC Warning: Repeated allocation of very large block (appr. size 2305024):
> May lead to memory leak and poor performance.
> Then the heap size grows.
> I've used GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE malloc large block(as bitmap array,
> data array, or string).
> Can you kindly advise how i can prevent this warning from happending?
Yes. Don't do that.
Repeated allocation and freeing of such a large object is very likely
to cause fragmentation and heap growth because once that space is in
the heap and has been freed it is likely to start being used for
smaller objects. Next time you need a large object there is no
contiguous space and more has to be allocated.
Use your own free list for large objects, possibly rounding up to a
few standard sizes if the natural size varies. Or use a "handle"
library using double-indirection so that they can be moved around in
memory (like in the original Macintosh OS and others). Or split your
large objects into data structures with an internal structure using
small objects of standard sizes arranged into multi-level arrays, or
lists, or trees.
There are lots of options.
More information about the Gc