[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Memory leak with lua ...
- From: Jay Carlson <nop@...>
- Date: Tue, 24 Apr 2007 17:41:37 -0700
Sent from a Treo, excuse infelicities
From: "David Given" <email@example.com>
To: "Lua list" <firstname.lastname@example.org>
Sent: 4/24/07 4:18 AM
Subject: Re: Memory leak with lua ...
-----BEGIN PGP SIGNED MESSAGE-----
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.
┌── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ─── http://www.cowlark.com ───────────────────
│ "Feminism encourages women to leave their husbands, kill their children,
│ practice withcraft, destroy capitalism and become lesbians." --- Rev. Pat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----