|
On May 22, 2014, at 12:39 AM, Philipp Janda <siffiejoe@gmx.net> wrote: As soon as you have garbage collection and lifetime dependencies, manual disposal doesn't work that well anymore: E.g. if I cleared an APR memory pool (which is possible in the C API), I would break all userdata objects that were created using this memory pool. This is also the reason why exposing something like `SDL_Quit` to Lua is dangerous. Manual management is only possible at the leaf nodes of such a lifetime dependency graph (e.g. I can manually close/delete an APR file object without problems even if it depends on a memory pool). That really depends entirely on what semantic you want to assign to Dispose(). In the case of a memory pool it could mark the pool as unavailable for new allocations and then (later) actually delete the pool when the last allocated object was itself disposed (or collected). There are many different ways to bridge the impedance gap between Lua and non-GC type allocation models. My point stands however: trying to force a GC to trigger resource recovery is inefficient. —Tim |