imclover07 / away3d

Automatically exported from code.google.com/p/away3d
0 stars 0 forks source link

Memory leaks due to stage RESIZE EventListener in View3D!!! #118

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new View3D instance without overwriting the "stats" property  
passed via the init object. So the "stats" property will be preset to "true".

What is the expected output? What do you see instead?
All works as expected. The View3D will be rendered accordingly. 
But if you try to dispose all existing away3D objects to clean up memory
and release system resources there will always remain some references to
all instantiated View3Ds. This is always the case even if you are
absolutely sure that you removed all instances from the display hirachy,
cleaned everything up and set all references to null so that the garbage
collector should remove them from memory!

What version of the product are you using? On what operating system?
I´m using Windows 7 as operating system and the latest away3d svn
revision(2527).

Please provide any additional information below.
After I runed some profiling sessions with the Flex Profiler Tool on my
application I noticed that there always remain some references to
instatiatied View3Ds. Even if there get disposed and are cleared properly!
By looking deeper through the stacktraces and reference-tree of several
memory-snapshots it seemed that the cause was a stage EventListener for the
Event.RESIZE at code-line 252 in View3D.as. This Listener will always be
set if the "stats" property of the View3D is not overwritten to "false". I
think this is a really uncommon case because the default is "true" and few
developers aren´t aware that this property even exists. 
This issue can easily be solved if you set the EventListener to weak
reference by replacing the following code-line (252):

stage.addEventListener(Event.RESIZE, onStageResized);

with:

stage.addEventListener(Event.RESIZE, onStageResized, false, 0, true);

After this is done all references are removed accordingly and the garbage
collector can clear up the memory so the occurance of memory leaks is
prevented.

Original issue reported on code.google.com by cacafu...@googlemail.com on 26 May 2010 at 9:32

GoogleCodeExporter commented 9 years ago
fixed and updated in latest trunk revisions:

http://code.google.com/p/away3d/source/detail?r=2673
http://code.google.com/p/away3d/source/detail?r=2674

Original comment by rob.bate...@gmail.com on 4 Jul 2010 at 8:16