[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Loadlib's callfromlib() - anybody using it?!?
- From: Philippe Lhoste <PhiLho@...>
- Date: Tue, 11 Jun 2002 13:39:03 +0200 (MEST)
> Roberto wrote:
> >In several "common" platforms (such as most Unixes and Windows) you
> >get nothing by closing the state, as all resorces (memory and file
> >descriptors) are automatically released by the system when the program
> >On the other hand, closing a large state takes some time, as Lua has to
> >release all memory it was using.
> It is possible that a Lua program grabs some resource that is not
> automatically released (for example video memory, or the semaphore to
> the robot attached to your USB port). Even though I wrote my program
> correctly to free allocated resources, I need to worry about specifying
> the -c option.
> It seems backwards. Why not treat "not closing state" as a special
> optimization that must be explicitly requested? (Still, I can't believe
> it will make a noticeable difference in your average app.)
I agree. Actually, I was thinking of implementing it in my own versions of
the interpreter; the -c option being silently ignored, adding a -q (quick)
option to exit without closing Lua.
Dirk Ringe wrote:
> Thats wrong. WinNT based systems free all resources after the process
> even if the process leaked something. This was somewhat a problem afaik
> win9x based systems with ui and gdi resources but also not with plain
I love this mailing list because I learn so much things :-)
It seems you are right. malloc uses internally HeapAlloc, whose
documentation actually don't mention the need for a HeapFree...
I made and ran a stupid little program allocating 1MB and exiting. Multiple
runs didn't seemed to change the memory load.
OK, but being old fashioned, I prefer to free the memory I allocate when
I suppose those reporting memory leaks were using BoundsChecker, Purify or
friends, which count the allocated/freed memory, no matter what happens to it
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
GMX - Die Kommunikationsplattform im Internet.