|
From: strk <st...@ke...> - 2004-04-29 07:46:29
|
I've finally implemented garbage collection in Ming. Sorry klaus, I was too lazy to take care of Ming objects from user code.. What you have now is a Ming_collectGarbage() function that will destroy all Ming objects. The implementation does not cover *all* ming objects because I did not have handy code to test it on. Currently handled: movie, movieclip, shape, jpeg, fill, input. Robert, can you give it a try and add garbage collection support for the objects you still see alive after Ming_collectGarbage call ? Verify that TRACK_ALLOCS is defined in ming_config.h and copy from movie.c the changes in the struct, the constructor and the desctructor. Then, when you've done with the Ming object you created call Ming_collectGarbage(). Note that you must know what you are doing, since calling Ming_collectGarbage() and then trying to use your objects will result in a segfault. Use with care. If you're afraid, keep doing as you always did and everything will be fine. If you can't stand 6 bytes of overhead for each created Ming object undefine TRACK_ALLOCS in ming_config.h. --strk; On Mon, Apr 05, 2004 at 05:33:39PM +0200, strk wrote: > On Mon, Apr 05, 2004 at 01:29:09PM +0200, Klaus Rechert wrote: > > > > >On Sun, Apr 04, 2004 at 05:03:09PM -0000, ham...@t-... wrote: > > > > > > > > > > > >>Now, to the subject of garbage collection: > > >>I could imagine a setup where ming keeps a linked list of allocated objects. Every object > > >>has a destructor, and the destructor would unlink the object from the list. So if it comes to > > >>garbage collection, one could just walk the linked list and called all the objects' destructors > > >>This should be a function available through the api, because otherwise we get problems with > > >>php or perl - they build their own objects which reference the ming objects, and call the > > >>destructors themselves > > >> > > >> > > Hi, > > > > how about only "exporting" a list of Objects to the user which are > > safely destroyable? i still think the destruction should be transparent > > to the user. in some cases it isn't possible to destroy > > character-objects (like Fonts, Sound-stuff, video etc. ), so if the > > destruction isn't transparent you have to guess if your pointer is still > > valid. > > > > The list of no more needed Character-objects could be returned by the > > SWFMovie_flush() method. All Character objects need refcounts then. The > > refcount should be incremented at somewhere SWFMovie_add() and > > decremented at write/complete if its safe to release the object. > > > > What do you think ? > > I started working on the simpler implementation. > What I need is just a way to kill all Ming objects created so far. > Calling Ming_cleanup() when finished working with a Movie or a set of > Movies would ensure there are no Ming objects allocated. You know when > you are calling Ming_cleanup() you won't try to use again the Ming > objects previously created. > > What you are proposing sounds a bit too complex to me, in > both user and developer terms. I'd start from the API. > If you show me how simple would it be for the user I'm ready > to change my mind (development cost remains though:) > > > --strk; > > > > > > Cheers > > Klaus |