[Gc] GC Warning: Repeated allocation of very large block

mijobee at mijobee.com mijobee at mijobee.com
Mon Oct 30 12:13:45 PST 2006

I'm running into this error in a class implementing variable length  
arrays of pointers.  I have gotten past the error by using the  
solution provided on the previously sited website and modifying the  
array code to expand the array by larger amounts when its capacity is  
reached.  The software I'm working on is general purpose and intended  
to be used in a large number of projects so I'd like to take every  
precaution to ensure that it doesn't leak memory or print a warning.   
Would it help if the memory block were allocated using  
GC_malloc_uncollectable?  The memory block itself doesn't need to be  
garbage collected however the pointers it contains needs to be seen  
by the collector so the memory pointed to isn't collected.  Thanks.

On Oct 30, 2006, at 2:46 PM, Boehm, Hans wrote:

> Unfortunately, it's debatable whether the collector runs perfectly
> correctly when this happens.  This message is only printed if the
> collector has significant reason to believe that you will be leaking
> large blocks of memory, as a result of  allocating objects larger than
> what it can place between known "false pointers".  Hence the block  
> will
> be allocated, but is likely to remain pinned for the rest of the
> process.  Things will continue to work for a while, but often not
> indefinitely.
> I think the warning is currently only printed after allocating 5 such
> blocks, suggesting that this is being repeated often enough to be a
> serious issue.  You might look at the GC_PRINT_STATS log to see  
> whether
> it really appears benign.  Repeated sequences of heap expansions  
> without
> an intervening GC are generally suspicious.
> If you are seeing this on a 64-bit machine, we should investigate.   
> On a
> 32-bit machine, this is unfortunately hard to avoid in general.  We
> could see where the false references are coming from, and try to avoid
> those.  But I think there's no easy way out.
> You should also remember that allocating a 2MB block in a
> garbage-collected setting is expensive, no matter what the collector.
> The collector cost is roughly the same as allocating 20,000 100-byte
> blocks.  If you are allocating a bunch of these in a row, it's  
> probably
> worth thinking about ways to avoid that.
> Hans
>> -----Original Message-----
>> From: gc-bounces at napali.hpl.hp.com
>> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Andrew Haley
>> Sent: Monday, October 30, 2006 3:35 AM
>> To: mijobee at mijobee.com
>> Cc: gc at napali.hpl.hp.com
>> Subject: Re: [Gc] GC Warning: Repeated allocation of very large block
>> mijobee at mijobee.com writes:
>>> Hello Everyone,
>>> I was hoping to get some advice on getting rid of the
>> following  > warning message:
>>> GC Warning: Repeated allocation of very large block (appr.
>> size  > 1986560):
>>>          May lead to memory leak and poor performance.
>> Yeah, it's very annoying.  Several times I've tracked this
>> down and it's turned out to be something perfectly benign
>> such as the creation of a large array.  I don't agree that
>> the gc should warn on a perfectly normal and correct operation.
>> Andrew.
>> _______________________________________________
>> Gc mailing list
>> Gc at linux.hpl.hp.com
>> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/

More information about the Gc mailing list