lua-users home
lua-l archive

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


> 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
> >ends.
> >
> >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.)
> 
> -John

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
exits
> even if the process leaked something. This was somewhat a problem afaik
with
> win9x based systems with ui and gdi resources but also not with plain
> memory.

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
exiting :-)
I suppose those reporting memory leaks were using BoundsChecker, Purify or
friends, which count the allocated/freed memory, no matter what happens to it
thereafter.

Regards.

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--

GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net