Flash :: Memory Usage And Garbage Collection Of Objects?
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
Similar Posts:
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
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
Dec 7, 2006
When ever there are no longer any references pointing to an object in memory, that object is purged from memory and permanently forgotten by the player.
Code:
delete a; // Object has reference count of 1
delete b; // Object has reference count of 0, removed from memory
Note: remember, the delete operator only removes variable association, it does not delete objects in memory, the GC is responsible for that. Also delete will only work on non class member variables.
I have a class called MenuView which contains buttons. After a button from the menu is clicked, its content - which is contained in another class - is being attached to the existing class by the means of the new keyword, so basically it just creates SubClass inside the MenuView class (or instance of another class inside the MenuView Class object if you like):
Code:
_sign_content = new NewEntryView(width);
_sign_content.addEventListener("newEntry_submit", onNewEntrySubmit);
addChild(_sign_content);
NOTE: _sign_content is private property of the class of type NewEntryView (this class contains the content for the button clicked)
Inside this NewEntryView Class (which is being referrenced by the _sign_content property by now), there are textFields being attached to the DisplayList, eventListeners being called, subclasses being created, all that in different functions of the class.
Now when user clicks another button in the menu, i have to set _sign_content=null etc., so that GC can harvest it.
I do so this way from within MenuView class:
Code:
if(_sign_content != null) {
// remove container
removeChild(_sign_content);
[code]....
View 5 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
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
Jul 19, 2010
In AS3, after I've removed a display object container B from another display object container A and deleted all the references to B in A, does that mean that all memories previously held in B will all be released too or do I have to manually delete all the references to objects in B before I can delete B in A in order to free all the memory space held?One more question. I was kind of confused of when to use the delete statement and when to set a variable to null.
View 1 Replies
Aug 24, 2010
I wrote an application in flash AS3, and when I trace from flash the total memory usage of the total application is only about 9MB, But at the same time Task Manager Shows the memory usage as 110MB. Around 100MB difference.Flash Trace Method System.totalMemory difference of the Trace from the Beginning of the application to end of the application.
View 2 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
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
Feb 27, 2009
I've been in a trouble with "removeChild" for a while. I know there must be some great discussion around but just could not find some nice posts in details.
View 2 Replies
Sep 12, 2009
I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
View 15 Replies
Nov 12, 2009
How do I make Flex/ActionScript 3 objects eligible for garbage collection? What are the thumb rules?
View 5 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
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
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
Jul 6, 2009
How much memory in bytes can Flash normally handle? I have a fairly involved program that is running at 39MB usage and now may be causing some memory issues (I'm not sure it's the memory, since it was running smoothly up until I made a few code changes and now Flash freezes after making those changes). But anyway, I have been wondering about memory usage and Flash CS3 and felt like this was a good topic to dicuss. Is there a way to force an increase in available memory for Flash?
View 2 Replies
Aug 20, 2009
I am doing a flash getting data from mysql. My Database is quite big (200+MB) with lots of datas. here is my problems, after using my flash for some searching, maybe because of calling mysql to get too much data (like getting 900 records with their names and images), my memory usage increase to over 2 GB. Thus my flash is dead. I need to restart it. Is there any ways to reduce the memory usage?? Or it might be some other problems. I am quite new at my job, so it might be something that I forget to close ot remove.
View 2 Replies
Oct 16, 2010
When I run my swf locally in the Flash Player application, its memory usage starts at around 50 Mb, and though it definitely fluctuates, it generally stays centered at around 50 Mb. Then I embed the same swf in an html page and run it in my browser (firefox). Now the memory usage starts at 20 Mb, but increases at a near constant rate until it is over 100 Mb and I need to stop it. The swf is essentially unusable in the browser because of this.
What could be the cause of this huge difference in behavior? Where should I even begin when trying to make the swf functional in the browser? EDIT: I have found what was causing the problem (sort of). A certain type of object, which gets spawned a lot during the game, doesn't respond to removeChild() correctly. As a result these types of objects were building up on the stage (but invisible) and causing the memory usage to skyrocket. This doesn't occur when I test it in CS4 or in the standalone flash player application, only in the browser. It seems like a Flash bug.
View 2 Replies
Feb 25, 2011
Is there any way i can get CPU usage and CPU memory usage details in flex? I know that flash can't access any system resources.
View 2 Replies
Nov 2, 2009
I have a movie that am loading external 27 movie clips. after a while the flash projector crushes. when i look at the the task manager flash Mem usage is 171000k.
the more i upload the more the memory keeps increasing. i thought when u upload a movie clips in flash they keep replacing the one before and so the memory does not keep increasing?
--kharddie
var loaderScenario:Loader;
loaderScenario =new Loader();
loaderScenario.contentLoaderInfo.addEventListener(
[Code]....
View 0 Replies
Aug 10, 2010
My problem is going to be hard to outlay in detail due to NDA's I am bound to, but the gist is this..I have a swf application the progressively streams content from a cdn edge server.I have built a video player class and instantiate a new one for each new piece of footage I find.Naturally this requires good memory management to ensure no leaks..... and herein lies the problem (surprise).
I have unregistered all my event listeners (not using weak at present) and nulled all objects from my media player object.I slice it from my list and call a destroy method that cleans up all objects setting references to null. Once this is done I call System.gc().My profiling tools are showing that my memory usage is continuing to increase linearly for each new video clip. The jump is about 5mb each time the approx size of each video file.
Is the built in "Video" component on the stage (players all share the same one) a built in type?
View 3 Replies
Oct 4, 2010
I have a class just full of random STATIC functions and vars that I use often on alot of other classes. things like the classic randRange(min, max) function. . just silly things i dont want cluttering my code My question is does importing this class into other classes increase the memory used by instances of the class. Cause i may import this class of 30 objects and only use 2 of them. I'm thinking it doesn't. But i could be wrong as I haven't found much material on flash memory usage other than garbage collector stuff.
View 1 Replies