Actionscript 3 :: Garbage Collection Doesn't Work?
Nov 22, 2010
I have a TitleWindow component that I'm displaying via PopUpManager.addPopUp(). When I close the component, I'm calling the closePopUp Event which sets the object's variable to null, as follows:
// application
private var myObject:MyObject;
private function openPopUp():void[code].....
However in debug mode I can see myObject being set to null, but the memory usage doesn't decrease. When I open the component again, the memory usage remains the same as before.I would have thought when the myObject variable is set to null, GC recycles the object and frees up memory.
View 2 Replies
Similar Posts:
Nov 6, 2011
I understand that Objects not referenced by anything are garbage collected, and have been making sure to null out referenced to objects when I'm done with them. What I want to know are a few things:Do only Objects need to be null-referenced?How often does garbage collection usually run? Does it tend to run when processor demand is low? Is there a way I can tell garbage collection to run manually, such as when I'm done with a playing field full of sprites? This is not really needed if garbage collection tends to run when processor use is low, since it will run anyway at the times I'd like it to.Objects created just for the scope of an if or for statement etc, unless they are assigned a reference elseware, are eligible for garbage collection, right?
View 2 Replies
Jun 25, 2009
It is known that a display Object removed from the display list will be garbage collected only if any event listener associated with it is removed.What I would like to know, but could not anywhere find an answer to, is that for a class that we create which extends, say Sprite, and uses and manipulates various other display elements within it, while removing an instance of this class from the display list is it sufficient to remove the event listeners associated with the instance of the class, or do we necessarily have to remove all internal event listeners of the class definition associated with the display objects that the class uses and manages.
View 1 Replies
Oct 16, 2010
[code]At the time when Camera.getCamera(1) is attached to vid1, is Camera.getCamera(0) destroyed internally or still in memory?
View 2 Replies
Feb 16, 2009
I have a question about garbage collection: I am using a MVC pattern for a photo gallery website.Every view displays a thumb viewer/controller and an image loader. Each view extends an abstract class that has a close() method that looks like this
PHP Code:
//AbstractViewer class
public function close():void {
[code].....
View 2 Replies
Sep 25, 2008
No matter what I do I cannot solve a tween AS3 Garbage Collection problem I am having that is wreaking havoc on my tween instances working correctly/consistently. Some Sprites never tween at all, some do but only part way. And it effects different ones almost each time.
I have read a fair amount recently on AS3 Garbage Collection and improperly referenced Tweens and other asynchronous instances getting picked up in mid process. I am experiencing the signature inconsistent behaviour that the I have read of.
I have tried using class level Static and non static properties to store references to my Tween instances so they will not be marked for GC. No luck. I have placed references to them in Class level Arrays, I have also used TweenMax's static to() Method that insures that it will shield it from GC and its alt. non Static
constructor instantiation, with persist:true. I also implemented another custom package; GCSafeTween(), other users said it does as it should, but it's not working in my case.
To test the GC problem, I edited the two eventListerners() in the Adobes' fl.transitions.Tween so that their default weakReference property was false. Doing this made the Tween work correctly. But that's a terrible solution.
View 23 Replies
Mar 31, 2012
A flash file loads a swf that has flash video using a loader request, which once loaded, wont unload and slows things unbearbley. I understand that once unloaded the flv will keep playing until Flash disposes of it.
View 2 Replies
Apr 20, 2010
I'm building a large flash site (AS3) that uses huge FLVs as transition videos from section to section. The FLVs are 1280x800 and are being scaled to 1680x1050 (much of which is not displayed to users with smaller screens), and are around 5-8 seconds apiece. I'm encoding the videos using On2's hi-def codec, VP6-S, and playback is pretty good with native FLV players, Perian-equipped Quicktime, and simple proof-of-concept FLV playback apps built in AS3.
The problem I'm having is that in the context of the actual site, playback isn't as smooth; the framerate isn't quite as good as it should be, and more problematically, there's occasional jerkiness and dropped frames (sometimes pausing the video for as long as a quarter of a second or so). My guess is that this is being caused by garbage collection in the Flash player, which happens nondeterministically and is therefore hard to test and control for.
I'm using a single instance of FLVPlayback to play the videos; I originally was using NetStream objects and so forth directly but switched to FLVPlayback for this reason. Has anyone experienced this sort of jerkiness with FLVPlayback (or more generally, with hi-def Flash video)? Am I right about GC being the culprit here, and if so, is there any way to prevent it during playback of these system-intensive transitions?
View 3 Replies
Dec 22, 2010
I put together a quick sample just to test out the garbage collection convenience functions in casalib.
All seems to work well (i.e, objects are removed from the stage, listeners are stopped) however I am using Mr. Doob's stats display and it looks like my memory usage isn't going down after the destroy method is called?
[Code]...
Are my items actually being marked for garbage collection? What am I doing incorrectly?
View 1 Replies
Oct 14, 2010
i want to know what types of objects should be removed for garbage collection? i m working on a bit long project. i've made it in flash application. i've 5 frames. each frame contains scripts. i've declared public variables as well as private and local. obviously assigned some eventlistener and so.. while moving from one frame to another, i want to remove unnecessary objects to garbage collection.whatever i understood, i nullified all the public variables and removed all the public eventlisteners (eventListeners which are in functions, I believe those can only be removed within that function). Objects (incl movieclips and all these) which were added dynamically, i removed them using removeChild() method..
View 5 Replies
Sep 15, 2009
I have an object that contains a timer. I do addEventListener on the timer and start the timer.At some point the object is deleted but I find that the timer keeps firing (using trace statements).What I don't get is, how come when I delete the only object that has a reference to that timer, the timer doesn't go away along with the event? Or do I have to do a removeEventListener() on the timer before removing the object for it to go away?
View 1 Replies
Mar 3, 2010
Code:
var a:MovieClip = new MovieClip();
var dict:Dictionary = new Dictionary(true);
[code].....
View 1 Replies
Jun 14, 2010
I've written a very simple swf loader/unloader that does not seem to remove from memory the loaded swf after it is no longer on the stage. There are several blog entries I've found regarding this, and none of their solutions have seemed to work. Adobe's Livedocs example of loading in an external swf and removing still has this issue as well. Perhaps I'm missing a simple step?Here's what I've got. Feel free to dump this code into your Flash app. All you need to do is make the 2 buttons (LOAD & UNLOAD) and the .SWF you want to load in as a test.
Code:
var url;
var urlRequest;
[code]....
View 6 Replies
Nov 8, 2010
I know that there have been questions asked about garbage collection and memory management and after hours of searching through the internet I frustratingly haven't been able to find a solution to my problem.So here it is:I have a function that reads an XML files and creates thumbnail instances of a class. The class contains the usual information as well as two listeners for MOUSE_OVER and MOUSE_OUT. The thumbnails are movieclips and are placed in a sprite container/holder. The container/holder is created with code:
Code:
var containerProjects:Sprite = new Sprite();//Creates sprite to contain projects
spriteGallery.addChild(containerProjects);//Adds container to main container
[code].....
View 2 Replies
May 16, 2011
I'm running Flash CS4 and compiling a project for Flash 10, at least for the time beingThe short of my question is this: do TextFields have a memory leak? I was trying to track down leaks in my code (my code is a morass of comments and virtually - no, scratch that, with the exception of the below, nothing is actually running) and couldn'tut notice that every time my placeholder visuals (squares with "Idle0", "Idle1" written on them in text fields) animated, I would lose memory like someone had jabbed a hole in my code! Even stop()-ed, the three text fields I have on/off screen seem to cost me a few kilobytes every few frames or so - depending on what I'm doing - compared to a sprite with poor mockups track this down.
View 6 Replies
Nov 24, 2010
I have some odd behavior while removing a MovieClip. I create a MovieClip (character) in an empty project on an empty stage (the movieclip is made up of several other clips for arms, legs etc.)[code]Then it keeps climbing for a while and then jumps back down to:126095360.Then it keeps climbing again -> jumping back -> climbing - jumping back. But each time it jumps back it has a little extra memory added. I can understand the first time memory increases after adding and removing the movieclip. Obviously the Garbage Collector needs some time before kicking in. However, why does it start to increase again and again?I noticed the memory usage instantly jumps back once I remove the MovieClip. However, It will still be increasing afterwards.
View 4 Replies
Mar 16, 2009
I'm developing a touchscreen application in AS3, and I havesome problems because the applications reaches 1,5 Gigabyte ofmemory if it's keep running for an hour.this memory size is because I show some videos in streaming,one after another (not in the same), and then they are not garbagecollected: I set the references to the videos to null and I removethe listeners, but flash seems to keep them in memory. I tried todelete the code section about the videos, and I have no problemswith memory (I also load some external images with the videos), soI'm pretty sure they're guilty in some way...I read that there's a bug in flash so displayobjects are notgarbage collected even if you remove the pointers to them: is it
View 1 Replies
Nov 7, 2008
I have done a lot of searching / reading to find out how to clear my memory. But I still can't really work out how to clear the memory, it just never seems to come down. I have a few MovieClips that contain other MovieClips with pngs inside them being added to the stage.
As fare as I can tell all Event listeners are removed and refrences I remove the clip, with removeChild I "null" the variable I am using the "LocalConnection()" hack to try and force a clean up, but no movement on the memory count. Are there any examples of a *.png being added and removed from the memory?
View 7 Replies
Mar 7, 2011
i've list-based components. when i no longer require them, i just use removeChild() method. i've applied setStyle() method to them. i'm a bit consufed, do i really need to use clearStyle() method or without doing it, flash will take them in garbage collection?
View 2 Replies
Mar 1, 2010
i'm trying to remove a tween object after it has complete so the memory can be freed by garbage collection.in this example i'm passing the fadeIn function a UILoader object that is cast as a sprite so that it fades in when it is finished loading. when the tween finishes animating, i want to remove the tween object. i've included the compiler errors as comments.
function fadeIn(e:Sprite):void
{
var myTween:Tween = new Tween(e, "alpha", None.easeNone, 0.0, 1.0, 0.2, true);
[code]....
View 2 Replies
Apr 28, 2010
May I know what is the proper way to keep track of display objects created and hence allow me to remove it efficiently later, for garbage collection. For example:
for(i=0; i<100; i++){
var dobj = new myClass(); //a sprite
addChild(dobj);
[code]......
View 3 Replies
Nov 16, 2010
when launching the following code in ADL, why does the square continue to rotate?[code]i have added a REMOVED_FROM_STAGE event listener, but this will only work on display objects.is this problem specific to ENTER_FRAME event?
View 2 Replies
Jul 11, 2011
Yesterday when playing a game (Balloons Tower Defense 3) I noticed that the game started to slow down over time and then randomly speed up very quickly. Looking at the memory usage dropping each time I assumed it was the GC running.
As a legitimate question, is there anyway to force Flash to GC from, say, Firefox? Perhaps there's an addon or a command you can run that will do this? I know that you can do System.gc() but this game isn't mine so I can't modify the source with a "Click here to GC" button.
View 2 Replies
Oct 7, 2011
Does anyone know if it's possible to apply garbage collection to the new StageVideo component in AS3? I have tried with no success! Code is below:
if ( this._stageVideo == null )
{
this._stageVideo = stage.stageVideos[0]; this._stageVideo.addEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
}
[Code]...
View 2 Replies
Oct 18, 2011
I'm building an Adobe AIR desktop app with Flash CS5 that makes a lot of use of bitmapdata, bytearrays and base64 strings. After a while the memory usage of the app doubles. Is it recommended to use system.gc() to free memory at that point or is that bad practice?
View 2 Replies
Oct 30, 2011
I've a question about garbage collection in flash.I'm making a game using with Flash AS3. This game will stay open for a few hours, like 5 - 6 hours. People will play it again and again in these hours. I have 15 loader in my flash game and don't want to have a problem with Garbage Collection. I'm uninstalling every load object when it is not necessary but i'm not sure do i have trouble about this garbage collection?
View 1 Replies
Nov 4, 2011
I'm using a Dictionary with weak keys to test if an object has been garbage collected. When all references to the object outside of the dictionary are removed, I expect the dictionary to no longer be populated. It seems to work for an Object, but for a Sprite it indicates that the garbage collection hasn't taken place.[code]...
View 1 Replies
Dec 17, 2009
I've been thinking about how the garbage collection work for a while now and have to ask if its necessary to removeEventListeners before you null a class like this:
ActionScript Code:
var _nc:NetConnection;
function init():void
{
[Code]....
Obviously I can skip the removeEventListener but will it affect the memory usage if I don't remove it?
View 3 Replies
Feb 1, 2010
I am creating drops, which is a movie clip
->drop: Drop = new Drop();
and adding those to the drops vector
->dropsVector.push(drop);
where,
->dropsVector:Vector.<MovieClip> = new Vector.<MovieClip>();
so for garbage collection,what all should i do?Splicing the dropsVector just splices the length to 0, but does not affect the memory.How do i empty the memory occupied by 'drop'?
View 7 Replies
Feb 9, 2010
I am concerned about the garbage collection in my projects. Whatever dynamic memory i am allocating, never seems to free up and it just keeps adding (i check in Windows Task Manager). e.g. I am adding bricks (movie clip) this way:
[Code]...
View 6 Replies