[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: GC and memory management
- From: "Julien Patte" <julien.patte@...>
- Date: Fri, 30 Jun 2006 16:52:29 +0200
I think it would be interesting (in the next versions?) that the GC would be called when a memory allocation fails...
It's sad to have a memory error where there are elements waiting to be collected :/
2006/6/30, Roberto Ierusalimschy <email@example.com>:
> Also, something I don't really understand: If there isn't enough memory, my
> allocator function can detect it and return NULL. Then the interpreter raise
> an error and the execution breaks softly. But in that case why doesn't the
> interpreter try to perform a GC cycle, then try to allocate memory again?
> Most of the time a part of memory may be safely freed and this allocation
> shouldn't break the program.
> Would it be safe to manualy call the GC in the allocator function in case of
Unfortunately no, with the current structure of Lua. Several objects
., tables) need several memory blocks. If a memory allocation fails
in an intermediate block and you call the GC, previously allocated blocks
would be collected. (The object only goes to the root set when it is
assigned to a variable, which only happens after it has been completely