[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Userdata GC troubles
- From: "Wim Couwenberg" <w.couwenberg@...>
- Date: Tue, 26 Aug 2003 08:59:52 +0200
> The results suggest that if I don't provide a custom __gc method the
> system would free some resources automatically and if I do have
> custom __gc, I have to do it manually. However I couldn't find
> anything in the docs related to what it is.
>
> The only custom __gc method in lua I could find is io_gc. Seems like
> it exhibits same problem:
>> =gcinfo()
> 17 29
>> for i=1,100000 do a=io.open("somenonexistingfile") end
>> a=nil
>> =gcinfo()
> 474 508
>> collectgarbage()
>> =gcinfo()
> 237 473
>
> Looks like a memory leak. Any ideas how to fix it?
Try running collectgarbage() again. Collecting userdata with __gc methods
that are allowed to do anthing at all is tricky business. Therefore it
takes two cycles to collect everthing.
--
Wim