[Gc] Silently fails to allocate memory?
The Devils Jester
thedevilsjester at gmail.com
Sat Apr 13 23:55:18 PDT 2013
On Sat, Apr 13, 2013 at 4:04 PM, Colin LeMahieu <clemahieu at gmail.com> wrote:
> You certainly haven't explained what you mean by "give up". Someone
> already asked, null pointer, freeze? What is a "give up".
I have said that I am working on getting a more definitive definition. At
current I am not sure what it does exactly except that I have a large loop,
that creates objects, and compares or modifies them in some fashion and at
some seemingly arbitrary point all of the compares/modifications will
simply fail. The code will continue to loop and "complete" so long as the
loop ending condition does not depend on the values of any of the objects
created. If for example, I created a "number" object that held a value,
and each iteration created another number object that holds the next value,
and do this ten thousand times, it will complete the ten
thousand iterations but the "last value" that it would show (assuming I
printed each value to the console as it was created) would be about 3500.
If instead the loop is set to loop until I get an object that has a value
of say, 5000, it would never reach that point no matter how many objects I
created with iterative values, as if the objects are just "not created"
after a certain point. Since my code has many checks to deal with NULL
values, which are allowed in every situation (and handled differently
depending on the situation), if its a case of "new" returning NULL every
time after that point, it will be difficult to trace but I am working on a
solution to help me narrow it down. (Of course, if I just dont free the
memory at all, or use libgc at all, all of the objects are created, and the
amount printed to the console, and the final number of the last object are
exactly as expected, but I need libgc).
On Sat, Apr 13, 2013 at 8:11 PM, Brian Beuning <bbeuning at corecard.com>
> I recently used GC to allocate 2 GB of objects and it worked fine.
I do not know if its the size, or the count. My loop test loops about 10
million times, every time creating about 7 trivial objects. At about 3500
it fails (The 10 million loop is overkill, but it never even makes it to
4000). If I create a few less objects each iteration, it will fail at a
later time, relative to the number of objects being created. If I just let
the memory be unfreed and accumulate (i.e. temporarily disable libgc) then
it completes all 10 million iterations without issue. This is on a 32bit
Ubuntu Linux install.
I think we get what you are doing and the issue you are seeing.
> There are too many things your code might be doing wrong for anyone to
> guess at.
> If you can reproduce the issue with some small test case (under 100 lines)
> then someone will probably volunteer to look at it.
I am combing through my code as best I can, making sure every vector, every
string, everything is using libgc (even things not remotely involved in the
test case, just to be certain) and will retest when I am sure that I am not
allocating memory through any other means. I posed the question only
because I thought that worst case scenario if I didnt use libgc everywhere
would be leaked/unfreed memory, not this so I assumed there was some key I
was missing. A compile flag to use (or not use), or some additional step
like the GC_INIT command, etc...If no one has any idea why this would
happen, I will dig deeper and email again when I have more information (or
possibly a test case) that can help solve the issue.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gc