lua-users home
lua-l archive

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



-- 
Jay
Sent from a Treo, excuse infelicities

-----Original Message-----
From: "David Given" <dg@cowlark.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: 4/24/07 4:18 AM
Subject: Re: Memory leak with lua ...

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stephen Kellett wrote:
[...]
> The basic problem is that there is no memory allocation hook for 
> reporting object creation/GC collection. Thus we've had to reverse 
> engineer one into the executing binary. The same applies to detecting 
> when a GC is about to start/has ended.

If you're using 5.1 then you can pass in a user-provided alloc and free
routine (usually hooked up to malloc() and free()), so if you wish you can
mediate all of Lua's memory allocations; but this is used for everything, not
just Lua objects, so could well be more low level than you want.

[...]
> There is no type information for an object because that is the way Lua 
> is. So we can't know that the variables 'orinoco' and 'montgomery' are 
> objects of type Womble because there is no type information to tell us that.

Depending on how your class system works, it may be easier to do this all from
within Lua. If your ultimate superclass' constructor adds all created objects
to a weak-referenced table, then it ought to be easy enough at program
completion to scan the table and report all objects that still validate. Since
you're doing it all from within Lua, it should be relatively trivial to figure
out what class each object is.

[...]
> For fans of The Clangers I can rewrite the above with comments about 
> Soup Dragons and Flying Teapots :-)

Unfortunately I don't believe there's any Clanger script in Unicode.

- --
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "Feminism encourages women to leave their husbands, kill their children,
│ practice withcraft, destroy capitalism and become lesbians." --- Rev. Pat
│ Robertson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGLeecf9E0noFvlzgRAlujAJ90Dn8qEdhh0StXU7ROA5OlN/LviwCeONxw
H0o8gyFUs67aevByMvead/A=
=+/WE
-----END PGP SIGNATURE-----