lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sun, Sep 12, 2004 at 11:04:43AM -0700, Mark Hamburg wrote:
> Is there any standard advice on how to manage large, indirect (i.e., the
> userdata itself stores a pointer to a separate block) userdata? I sometimes
> find that my application is choking on large, cached pixmaps and textures. I
> need to have something happen to drive the garbage collector forward or
> prompt collection in response to the existence of these objects.

Can't you just do it the same way Lua does? I.e. keep your own
independent byte count and threshold for this data and force a Lua GC
when an allocation of one of these objects would cause the former to
exceed the latter. That should work as long as your code continues to
turn over objects; if there are points where you suddenly have a lot
of references released, and no new allocations are happening, I
imagine you could figure out when that is and add extra manual GC

-- Jamie Webb