[Gc] Silently fails to allocate memory?

Brian Beuning bbeuning at corecard.com
Sat Apr 13 05:54:40 PDT 2013

The simplest answer is your process is running out of memory.
Try using the ps(1) command to check your process size.

If you are using any C++ STL containers (string, map, vector, list, etc.),
I expect they would allocate memory using regular malloc and GC will not
reclaim that memory.  You need to define an STL allocator template and
pass it to the container templates to get STL to allocate memory using GC.
(Overriding the global operator new might work on Linux, it does not work
on Windows.)

----- Original Message -----
From: "The Devils Jester" <thedevilsjester at gmail.com>
To: gc at linux.hpl.hp.com
Sent: Friday, April 12, 2013 5:51:53 PM
Subject: [Gc] Silently fails to allocate memory?

It is difficult to describe the issue I am having with libgc. 

I have a for loop that allocates thousands of (small) objects. Each iteration of the loop only allocates a few new objects, but when the loop is sufficiently large (usually around 3500 iterations), then for some reason it just...well gives up. It does not hang or segfault, or give any indication that something is wrong, but it (and this is difficult to determine) seems to silently stop allowing the objects to be created. 

If I disable libgc (or manually call delete, which is not a working long term solution), the loop executes correctly. This is on Ubuntu Linux using GCC 4.7 . 

On Mac OS X, I cannot tell if its working (which it appears to be) or if the limit to "give up" is might higher. 

Is there some trick to this? Am I using it wrong? How I am using libgc is by simply including "gc_cpp.h" calling "GC_INIT" and having my class(es) inherit from gc. 
Gc mailing list
Gc at linux.hpl.hp.com

More information about the Gc mailing list