ActionScript 3.0 :: Flash Should "local" Variables/object Ever Need To Be Marked For Garbage Collection
Jul 1, 2011
If I have a variable that is declared within a method of a class, should that variable EVER need to be marked for garbage collection (set to null).
for example:
Code:
public class MyClass extends MovieClip
{
public function MyClass():void
[code]....
I am making a 24/7 kiosk app and am noticing that the "pages" I load from the library using the above technique continually increases the memory usage (using Monster Debugger 3 and testing the SWF from within Flash Pro CS5 on a Mac.)
As I understand it "myVar" are the only references to each "SomeObject" object that gets instantiated. Shouldn't the fact that myVar is local mean that SomeObject should be available for garbage collection after each new page is loaded?
View 9 Replies
Similar Posts:
Jul 1, 2011
If I have a variable that is declared within a method of a class, should that variable EVER need to be marked for garbage collection (set to null).
For example:
Code:
public class MyClass extends MovieClip{
public function MyClass():void{
//constructor
myMethodThatLoadsAPage();
}private function myMethodThatLoadsAPage():void
[Code] .....
I am making a 24/7 kiosk app and am noticing that the "pages" I load from the library using the above technique continually increases the memory usage (using Monster Debugger 3 and testing the SWF from within Flash Pro CS5 on a Mac.) As I understand it "myVar" are the only references to each "SomeObject" object that gets instantiated. Shouldn't the fact that myVar is local mean that SomeObject should be available for garbage collection after each new page is loaded?
View 8 Replies
Feb 11, 2011
Objetcs created inside a function are automatically marked for garbage collection if not referenced anywhere else? Let´s say, I have a class called SubClass. in the constructor I create some displayObjects.Then I instatiate SubClass somewhere. When I remove this SubClass instance, will the objects inside be marked for garbage collection?
View 1 Replies
Mar 22, 2012
So if this is my document class, and the "Monster" class is a MC linked from the library.[code]...
View 6 Replies
Feb 9, 2011
How do I clean up after I've finished using the Camera object and Video Object?
Do I just write:
_cameraInstance = null;
_videoInstance = null;
View 1 Replies
Jan 10, 2012
ActionScript Code:
var clip:Sprite = new Sprite();
clip.name = "clip"
addChild(clip);
cleanup(clip)
function cleanup(mc):void {
mc.parent.removeChild(mc);
mc = null
trace(clip)
// clip is removed from stage but traces as [object Sprite]. It still exists!
}
How would I pass a MovieClip/Sprite/TextField through this function and remove it entirely?
View 4 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
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
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
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 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
May 4, 2011
This blog (and others) state that you should set object references to null inside your dispose() methods when cleaning up objects. However, Actionscript 3 (with Flash Player 9) uses mark and sweep to clear out circular references for you. So I am wondering: is there really any reason to null out your object references?
View 2 Replies
Jun 1, 2011
I want to know about the Object type specifically when it comes to garbage collection in Flash.
I know that items will be ready for garbage collection in situations like this:
[Code]...
View 2 Replies
Sep 26, 2011
I have memory leak in my project and I wonder how garbage collector working in Flash Media Server.I have 2 questions: Will FMS release objects from memory that have cycle references. For example when object A is has ref to Object B and vise versa.Why FMS still consumes memory after application unloaded by idle timeout. For example there were no users connected then fms unloaded app after 20 minutes. Memory usage left at the same level (for a long period of time).
View 1 Replies
Nov 16, 2009
my flash has lots of images and dispaly objects. Hence it costs high cpu usages. after using my flash for an hour, it is dieing.I am trying to reduce it. I have some questions here:
1. I create an array, or string at frame 1 for example, when I go back to frame 1, should I create a new array, or a new string?? Or is it better to make it empty array(eg:[]) or empty string("")? which way it reduces cup uasge more?
2. does anyone know how to force the flash to do garbage collection??
3. any other possible reasons that cause high cpu usage?
View 1 Replies
Jul 8, 2011
I am creating an CS5 flash application that is based largely on a library for loading MP3 files located on a user's computer using file references.
The issue I am having is that each time a new song is loaded, most of the memory is garbage collected but a small amount remains. In most cases this would be fairly unimportant, but the purpose of the application involves the user selecting a large number of mp3 files.
I am a bit new to AS3 and OOP, but I have come to the conclusion that the memory leak is within the library classes. I have tested the library using the smallest amount of my own code I could, and the problem remains. I did make minor changes to one of the library files, but as far as I can tell it is not the cause.Here is a link to the library, the actual download link is the "MP3FileReferenceLoaderLib.zip" link part way down the page:[URL] Here is the code I have for the main .as file:
Code:
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.FileFilter;
[code]....
View 4 Replies
Mar 25, 2011
I if create a sprite, and that sprite contains numerous child sprites (which themselves also contain child sprites), do I need to worry about garbage-collecting everything, or just the parent sprite? What if the child or grandchild sprites have listeners attached?
For example, let's say I have a class (a subclass of a Sprite) that creates a screen in an application.That screen contains numerous Sprites for all of the UI affordances on the screen (e.g., buttons, drop-down menus, textfields, etc.) Many of those sprites have event listeners on them.So, in my application, I have this:
var myscreen:MyScreenClass = new MyScreenClass();
this.addChild(myscreen);
Later, when the user is done with that screen, I remove it:
this.removeChild(myscreen);
myscreen = null;
Is that all I need to do? Or, do I need to go recursively through myscreen, removing all it's child Sprites and Event Listeners?In other words, if you GC a parent, are all it's children, grandchildren, great-grandchildren, etc. also GC'ed?(For what it's worth, I'm using weak-references in my event listeners...)
View 2 Replies
Aug 10, 2011
I'm trying to unit test memory management. So far I have a semi-workable solution using flash.sampler.getSamples to get the difference between the number of NewObjectSamples and DeleteObjectSamples which have the same id value.
The test looks something like this:
startSampling();
new Foo();
new Foo();
[Code].....
Since there are no references to Foo I'm assuming that all instances are being garbage collected, and my code is simply wrong due to my lack of understanding how sampling works. I am trying this instead of using weakly keyed dictionary because it seems it should be less of a hack, but now I'm starting to wonder if it's worth the trouble.
View 1 Replies
Jan 19, 2010
Just curious, If i nest a movieclip inside of another movieclip, and the nested movieclip is attached to a custom class. And that custom class has a Event.ENTER_FRAME listener. when I destroy the container movieclip, will flash get rid of the event listeners inside of nested movieclip's custom class ?
May seem like a silly question but flash has a tendency of not killing listeners along with the movieclip itself once it is removed from the stage(this is if your apply the movieclip via addChild). and its a hastle when things get too complex. My solution was to create a single loop for all my objects. Now ive come to a point where I am probably going to have to nest some movieclips inside of another so the position of the nested movieclip stays relative. the parent movieclip will be rotating and scaling so I rather nest it. But I got to know how flash handles moveiclips that are nested into a parent movieclip and has enter frame listeners.
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
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
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
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
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