ActionScript 3.0 :: Memory Usage When Loading External Movies?
Dec 13, 2010
I have a flash application running on some local machines. There are 3 movies the flash loads and plays. Each time a movie is played, it makes the amount of RAM the swf is using increase. This is being ran in a museum and users step through the 3 movies over and over and over, causing the swf to use gigabytes of RAM and eventually locking up the flash player.
Here's where I create the movie playback component.
ActionScript Code:
var flvPlayer:FLVPlayback = new FLVPlayback();
addChild(flvPlayer);
The 3 movies are on 3 different frames in the timeline, for each frame I have this code that loads each movie.
I use the cuepoints to display some text on screen. I also call a function that does flvPlayer.stop(); each time the user navigates away from a movie frame. So is the RAM usage growing because of the flvPlayer.source = "whatever" being triggered each time the movie is called up?
I have an interface that needs to load in external activity pages - there's quite a few of these. I've been trying to create an external class to take care of movie loads, but it has a bad memory leak. I've been reading about using unload() and unloadAndStop() but haven't gotten these to work (there are no noticeable differences in system memory usage or performance). Everything grinds to a halt once I've used up about 13+ Mb of memory.
The document class has lots of code (of course) so I'm just showing the code that relates here:
Code: package { public class Interface extends MovieClip { static public var _ui:MovieClip;
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.
Did a website, but at the end of it... i needed to translate everything So I simply made a duplicate translated all the text, and added a button on each that will jump between the languages. Button added to main stage. Inside button on DOWN action:
if (MovieClip(parent).mainContainer.numChildren!=0) MovieClip(parent).mainContainer.removeChildAt(0); var ii:int=parent.numChildren-1; trace(ii);
[code]...
I have tried to remove all children from the stage, but then upon loading, I get an error; looks like I removed the stage,timeline etc. So I had to leave the parent.numChildren at -1 to leave the mainContainer (but clean it inside). It works, but now Firefox memory increases each time I click on the Language Change button:
126K 208 K 288.5K 369.7K 450.0K
EDIT: The line stage.addChild() creates error:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at final_webMon_fla::MainTimeline/frame1()
The idea is very simple: I have a submain.swf with 5 buttons. Each button loads an external .swf loader.load(URLRequest);After playing first external swf, before I go to next one, I try to unload it1. remove all its associated listeners:com_loader.contentLoaderInfo.removeEventListener(Event.INIT-PROGRESS-C OMPLETE, idFunction);2. unload it:
I've tried loadMovie("exampledomain/sampleimagefilename", obj.mc); where "obj" is an object of a class who has a MovieClip variable "mc", and then using _root.attachMovie(obj.mc,"testInstanceName", _root.getNextHighestDepth()); to add it to the stage.That didn't produce any visual results whatsoever. To ensure the URL was being loaded properly, I changed loadMovie to _root.loadMovie, in which case the image was loaded (but, of course, replaced my entire Flash movie).
System.totalMemory gives the total memory used by the flash player and not one particular application. Is there any way I can get the flex application's memory usage in code/actionscript?
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?
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.
I'm struggling to understand this, so I'm hoping someone can explain how to further enhance the functionality of my simple unload function, or maybe just point out some best practices in unloading external content. The scenario is that I'm loading and unloading external swfs into my movie(many, many times over) In order to load my external content, I am doing the following:
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.
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(
how memory is assigned for an embedded graphic? I'm using an embed statement to include a 240kb splash screen into my code and it seems to massively increase the memory usage out of all proportion to its size.
ActionScript Code: [Embed(source = '../splash.png')]public var splashScr:Class; private var ss:Bitmap;
[Code].....
With a 1kb splash screen an ongoing trace of system memory bottoms out at ~3500kb, whereas with the 240kb screen it never drops below ~6500kb.
I need to create a hundred instances of a movie clip.Is it better to add functions for these movie clips in the movie clip class or in a separate class?For example I have move(), setPosition(), setRotation() functions, would this create these functions a hundred of time and take memory place or just reference the functions?
I have a flash file system created using Adobe Flash builder CS5 containing nested movie clips. I use Action Script 3 class (using Flash Builder) to go to different frames using gotoAndPlay() statements (these frames constitute different view states of the system). In my system I have around 10 view states starting from Welcome, Action1, Action2, ..., to EndOfAction(Bye).
In order to display these viewstates I use gotoAndPlay(). These viewstate are repeated sveral times in almost the same order. Each view state has multiple nested movie clips containing animations. Everything works fine during initial cycles. But after every cycle of viewstates, I find that the CPU usage and Memory usage are increasing. After around 10 cycles the use of CPU is such that the animations become very slow.
In the Action Script 3 the code will look like as following. switch (viewstate) { case "welcome": target.gotoAndPlay(welcomeLabel); break; case "action1": target.gotoAndPlay(action1Label); break; } Anybody could enlighten me what is happening here, and tell me how I can get rid of excessive, accumulative cpu and memory usage.
I am working on a touch screen project right now. There is a chance that the touchscreen will never be turned off, so I have to be very aware of the memory issue with the pc. I don't want the memory to keep building up and eventually it just freezes up the pc. Basically, I have separated each section into a separate swf. The idea is to load only the swf that is needed in order to optimize memory usage. I tested the app on a pc, when looking at the "processes" in the window task manager, it seems the memory used will just keep increasing as I navigate through the application, it seems to me it just keeps piling up external swfs in the application, but sometimes the memory will just suddenly decrease. And when the touchscreen application is idle, the memory will drop too.
The following code is what I used to load and unload the external swf. Did I do it right? Is there anything that may have left unnoticed that is still staying in the memory? Is there any other way to optimize the memory usage too? ActionScript Code: var prevLevel:* = this.parent; var currentPage:MovieClip; var oldPage:MovieClip; var bgID:String; [Code] .....
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?
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.
I have always the argument with my colleagues which authoring strategy to use. I always attached to the idea of authoring several swf files, and have them all loaded to the main swf when needed. And than attach Preloader to each swf that I load.
Others think that it should be only one swf with one preloader. And have all the navigation to use scenes or goto actions.
So the advantage of using my strategy is that users will not wait too long for one movie when its being loaded. And its more convenient to work on several fla with each have its own layers, symbols, etc
I've got a flex component which works pretty well but unfortunately turns into a disaster once used in a datagroup item renderer of about 40-50 items. Essentially it uses bitmapdata to take screenshot of a fully-rendered webpage in mx:HTML (this version of webkit rocks btw, miles better than flex 3). The code is pretty self-explanatory I think. [URL]. I've optimized it all I could, browsed, search for answers and already trimmed it down a lot, I'm desparate to reduce the memory usage (about 600mb after 100 draw). The Garbage collector has little effect.
I used to write programs in the android sdk for google phone. One of the android developers guide that I read says that it is more efficient to declare a const public static const NO:String = "no";
This has been a long-standing curiosity of mine, and I haven't gotten around to profiling to find out, and haven't seen it asked yet (for AS3):Let's say that I have a class:
class MyClass { public function myMethod():String { return "some return value";
I have a question about the Spark DataGrid and how it works in terms of garbage collection. What I'm finding is that if I dynamically add and remove columns from the DataGrid at runtime, the GridColumns and ItemRenderers never get freed from memory.
For instance, if I have a list with 10 items and I create 10 columns, there will be 100 ItemRenderers and 10 GridColumns. If I remove all of the columns, they are still there.
i want to load an external swf movie into the main swf movie. now ive been using the loadmovie script and it works fine but the loaded movie comes up in the top left of my site so my ? is, how can i specify the location of where my loaded movie ends up
I got some movies loading in a container, but the movies stay open, I want to be able to "close" the container, or hide it when I click on other navigation buttons that are included in my main timeline.
I read the tuts on dynamic loading etc (the one about external stuff like mp3s, jpgs, swfs; and the one with the transitions). I'm messing around with it in MX and all works fine, except the problem I have is I cant check it locally! the bandwidth simulator and profiler doesnt seem to work with loading external content, the movie appears immediately.
So I tried loading the swf from the web (i.e. URL = file://[URL]) that gave errors "opening file" (the movie is there though). my only solution so far is to keep uploading my movie everytime I wanna check it!!! which is CRAP! I dont have a network at home, so cant really use those bandwidth simulators I saw on the sticky. basically I juz wanna load an external movie, and see how the parent movie handles it (i.e. progress is kept track of correctly, loaded notifications work etc.) how can I check all this locally?
I got this tutorial about external movie loading. It works but it seems that their is a little problem with it. How do you keep the button from loading an external movie once it's loaded already?
[URL]
Let's BUTTON-1 loaded MOVIE-1, now when you click on BUTTON-1 again it will load the movie even if it's loaded. How do you do it like only when another button is clicked will it load the movie for that button.
I have been working on an Actionscript 2.0 project that basically loads external images.Everytime i load and unload a new image, memory increases to 1 or 2 MBsIf all the images are in cache, then it increased to 4 or 8 KBsIn the unloading of images, I have removed loader and the container of the image.