Flint Particle System Forum - 1.0.2 Bug: Emitter's Subject to Garbage Collection2010-12-25T16:15:09+00:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
1.0.2 Bug: Emitter's Subject to Garbage Collectionhttp://flintparticles.org/forum/comments.php?DiscussionID=25&Focus=122#Comment_1222008-05-08T01:43:57+01:002008-05-20T10:05:55+01:00ericrhttp://flintparticles.org/forum/account.php?u=17
In Flint 1.0.2 [at least] developers must store a reference to each Emitter object they instantiate. This is due to the fact that no reference to the Emitter is kept in the Display Hierarchy. ...
must store a reference to each Emitter object they instantiate. This is due to the fact that no reference to the Emitter is kept in the Display Hierarchy. Currently, as is visible in all demos, we get the following scenario:
Nowhere does a reference to the Emitter get stored.
I would make a motion for a re-implementation of the Emitter/Renderer setup. I would suggest [naïvely] adding an _emitters:Array field to the Renderer class. This kind of makes sense, too. Emitters are simply the logic behind the Renderer. Why not have two Renderers reference a single emitter (or multiple, for that matter)? The only thing that would need to change in the Emitter class is the following line: _renderer.renderParticles( _particles ); Which could change to: dispatchEvent( new FlintEvent( FlintEvent.PARTICLES_UPDATED ) ); (Alternatively you could use the ENTER_FRAME event with the Renderers and mess around with priorities or rely on the fact that you might be one frame behind the emitter... either way you're fine, really.)
Adding an emitter to the renderer would have the effect of registering the renderer for that "PARTICLES_UPDATED" event (as well as storing a reference to the Emitter in the renderer object, which is added to the Display Hierarchy and thus not a candidate for garbage collection).
Current Workaround: Store a reference to your Emitter objects as a Class variable (gah).]]>
1.0.2 Bug: Emitter's Subject to Garbage Collectionhttp://flintparticles.org/forum/comments.php?DiscussionID=25&Focus=123#Comment_1232008-05-08T01:49:42+01:002010-12-25T16:15:09+00:00ericrhttp://flintparticles.org/forum/account.php?u=17
Note: I would not advocate a circular reference (link the Emitter to the Renderer and the Renderer to the Emitter) as that would just increase the likeliness of memory leaks in peoples' programming.
Note: I would not advocate a circular reference (link the Emitter to the Renderer and the Renderer to the Emitter) as that would just increase the likeliness of memory leaks in peoples' programming.]]>
1.0.2 Bug: Emitter's Subject to Garbage Collectionhttp://flintparticles.org/forum/comments.php?DiscussionID=25&Focus=124#Comment_1242008-05-08T09:04:36+01:002008-05-08T10:30:44+01:00Richardhttp://flintparticles.org/forum/account.php?u=1
Yes, there is a bug in the examples. I've now corrected them all to keep a reference to the emitter to prevent garbage collection (although, strangely, they all worked anyway - the vagaries of ...
I don't, however, consider this a bug in the Emitter. Any object in flash is garbage collected if there are no references to it. An emitter is no different to other objects in this respect.
I am planning a more substantial restructuring of the relationship between the renderer and the emitter, to coincide with the release of the 3D version of Flint (this version will still support 2d as well).
The changes will allow multiple renderers to display a single emitter and multiple emitters to be displayed by a single renderer. I'll write more about it and we can have a discussion when I have an alpha version to show.]]>
1.0.2 Bug: Emitter's Subject to Garbage Collectionhttp://flintparticles.org/forum/comments.php?DiscussionID=25&Focus=125#Comment_1252008-05-08T16:01:47+01:002010-12-25T16:15:09+00:00ericrhttp://flintparticles.org/forum/account.php?u=17
Fantabulous! I can't wait to hear about the upcoming changes! The new functionality sounds both efficient and extremely useful. :)
I agree that this isn't a bug in the Emitter. It is merely an ...
I agree that this isn't a bug in the Emitter. It is merely an oddity resulting from the current architecture.]]>