Flex :: ModuleLoader Component Causing Memory Leak. How Can I Unload Modules Properly?
Jul 27, 2011
The application is too big to describe here, but I can tell you I have up to 20 modules or more that the client can use at any time. And if I go on loading screen after screen, my application can ocuppy 500MB and more.The script that I use to load and unload modules is:
public function createModule(modulo:String):void {
if(moduleLoader != null){
moduleLoader.unloadModule();[code]..............
I also found this topic but it doesn't fix my problem other topicI have a module loader that load other swc's but when I look at the memory off the application it seems that each time a module gets loaded the previous module doesn't get unloaded and so the memory increases..
This is how I load the modules: <module:ModuleViewLoader id="moduleViewLoader" moduleManager="{presenter.deviceModuleManager}"
I have a simple, reproducable memory leak associated with the Spark Combo box, however I'm convinced it must be something I'm doing wrong, rather than an SDK bug.
Note - this doesn't occur when the application is compiled against Flex Hero.It appears as though this is a bug, but I cannot believe that the ComboBox has a memory leak -- surely this would've been fixed before 4.1 was shipped? Update I've done further investigation into this, and believe the issue lies in a problem with the RichEditableText component that the ComboBoxSkin uses.
I'm trying to load windowed sub-application in another windowed application, The requirement is to replace one loaded application with another on user action.
I tried the documented method of unloadAndStop() on the swfLoader in the main windowed application, but somehow during memory profiling I could see the instances of those applications were maintained in the memory even after explicitly running garbage collection.
Where as If I make those windowed application as modules, and then try to load them using the Moduleloader things work smoothly and unloaded modules are removed from memory.
I have a custom control that contains a VideoDisplay control, and which loaded using the PopupManager.
Using the profiler, i've noticed that every time the my popup is loaded the memory for it gets allocated, but when it's closed the memory is never recovered.
There's nothing else holding a reference to the popup. And if I don't set the source of the VideoDisplay object, then there is no leak - but as soon as the source is set I get a leak.
I can't see any method to force close the stream or anything on the spark VideoDisplay control.
EDIT: I have tried setting the source to null before closing the popup but that doesn't change anything.
Also, I'm not holding any event listener to the video.
Edit 2: It doesn't happen if I replace the spark VideoDisplay with an mx VideoDisplay. Bug in the spark component?
I have a Flex 4.6 web game which displays 2 Lists with virtual layouts with 2 custom item renderers. The renderers consist mainly of BitmapImages displaying user avatars + few Labels.
The Lists are being updated often over TCP socket with gzipped JSON data. I merge that data into 2 ArrayCollections serving as dataProviders for the Lists. This seems to work well, the Lists do not flicker and are updated correctly (I've monitored debug traces a lot to get it right).
I am actually in the process of Architectural of our project. We have choosen Mate framework. The project is not so quite complex, but what advantages i would get over MXML when i choose Modules.
Main App - > Views - > Events - > Maps - > Services [PHP or Java]
When i come up with Modules based Architecture, it seems to be good but i doubt it should not end up with tight coupling and unwanted issues which may break the head later to solve.
Main APP - > Modules - > Module Interface -> Events - > Maps - > Services [PHP or Java]
What advantages i do get if i choose Modules over MXML Component? What is the prefered and the best way to Architect an FlexApplication? Since the Application is going to communicate with Backend, do we need to make the frontend more complex?
The IDs for all tags in an MXML component, no matter how deeply nested they are, generate public variables of the component being defined. As a result, all id properties must be unique within a document. This also means that if you specified an ID for a component instance, you can access that component from anywhere in the application: from functions, external class files, imported ActionScript files, or inline scripts.
Which is fine if your application is all contained within one MXML, but I'm having trouble referencing IDs of components within Modules, and then inside ViewStacks/Navigation Containers within a given Module.
If I can reference a module with FlexGlobals.topLevelApplication.myModule, shouldn't I be able to reference a Panel called myModulePanel with the following?
I'm very new to flash,and have been digging through google and this site for information on how to piece together an AS2 shooter game.Its going well enough, but I'm having slowdown issues the longer the games runs, and I was hoping someone here could point me in the right direction.To paste an enemy movie clip on the screen, i'm using this:
Code: var spawn =_root.attachMovie("monster1","monster1"+_root.getNextHighestDepth(),_root.getNextHighestDepth())[code]........
I need them stored in an array so that the player's shots can test weather or not they've hit any monster on the bullet's enter frame function, then call that monster's movie clip's take damage function. I'm using a for loop to do this:
Code: for(var i in _root.player.foes){ if (this.hitTest(_root.player.foes[i])){ _root.player.foes[i].takedamage();} }
I think the problem with the slowdown is that each time I place an enemy on the screen the array gets bigger and bigger. The slowdown only happens while the player is shooting, and I suspect the ever longer for loop with the hit testing is causing it.
I'm already removing the monster's movie clips as they get killed or exit the screen, I guess what I need is a way to reduce the size of the array at the same time, or at least tell the for loop not to do a hit test unless the monster is still alive.
I am making a custom renderer using the copyPixels function for my Haxe/Flash game. So I have this kind of code :
buffer.bitmapData.copyPixels(m_CurrentSkin, RECT3, POINT, null, null,true);
where :
-buffer is the bitmap where all my scene's objects are drawn
-m_CurrentSkinis the BitmapData that contains the current frame of the object to be drawn
Every time m_CurrentSkin contains a BitmapData that have never been drawn (the first time that an animation frame is drawn for example),I have a memory leak that is not garbage. However if m_CurrentSkin contains a BitmapData that have already been drawn (when the animation is played a second time for example), there isn't any memory leak.If I comment this line there is no leak so the problem comes from there.It seems that a copy of the BitmapData is cached in memory but I have checked in my code and there is no cacheAsBitmap explicitely set to true.
I'm making a photo browser. I load 15 photos as Images and add these Images to HGroup every time. When user presses 'next page', I first unload the existing Images by 'Image.unloadAndStop()' and 'Image.source=null', and then load new photos. However, it seems that the GC never works. The task monitor shows that the memory use of my AIR reaches as much as 1.2G! Some people said it's a bug of Image when you load a picture larger than 1.5M. Is it true?
I have a loader SWF that runs some code in the background and loads other SWFs. Using this code:
private function loadScreensaver():void { screensaverSWF = new Loader(); var req:URLRequest; switch(areaNumber){
[code]....
I load the screensaver and add it to the stage. Using MonsterDebugger I can see that memory steadily rises from around 80mb upwards until the application exits (Im using windows projector). What I can't work out is why, there is no code attached to the screensaver SWF, just some timeline animations of things fading in and out.
EDIT:I've kept testing and found where I have an image that starts of stage then tweens on and off and is removed. When it loops it adds to memory again, as if the first image is still kept. This is all done on the timeline.
I am trying to find out how to stop the memory leaks that I seem to get when making up dynamically loading picture slideshows. It is difficult to try and give a perfect example of this so I would rater try and show it in action. Here are 2 separate tutorials on how to build a slideshow, though they are slightly different I think this will illustrate my point, there is one problem and that is that the only browser I know of that will show this correctly is Safari,[code]....
Ok now in safari open up your Activity window and take a look at how these 2 different slideshows seem to operate, Link 1 seems to have a memory leak,because each time the picture loads a new instance of it, if this were automated it would be a far bigger issue, like the second url of Link 1.Now when I make my own slideshows I find that mine are also like the first and second links and not like the third.
i am working on this project wherein i instantiate an flvplayback at stage and let it play ,, after playing i instantiate 1-4 flvplaybacks on stage and the user kan nove choose a new film to watch .. but each time i instantiate the flvplayback(s) the project gets slower and slower .. the video gets bugggy and the sound is out of sync ..if anyone can see something wrong with the way i do it i would be ever so happy
While tracking down the source of a memory leak, I stumbled upon a strange issue with AS 3.0 and loading external flash movies. From what I can tell this somehow related to the custom classes stored inside the loaded movie. I have two versions of a basic file that contains one image on the stage (I also tried this with vector graphics with the same effect). One version has a custom document class (just a simple extends MovieClip with no additional code) and the other has no document class.
The graph below depicts the memory usage from loading the file without a document class.It performs the garbage collection as you would expect after each unload operation.However when I try to load and unload the same file with a document class, I get the following memory usage graph. As you can see, memory usage is slowly creeping up with each load operation.It almost seems that Flash is caching the class files, so I tried changing the application domain for the loaded content without success. Even if Flash was caching the class files I would assume that it would be able to detect that it had already cached the document class and simply re-load the cached version
I am making an application where I load a picture from the web at a rate of once per second. When I load a new picture I unload the old one the problem is that the old pictures are never completely erased from memory and the application keeps on consuming more and more memory until I'm guessing it eats all the memory in the cache (I haven't run it for that long yet :))
here is the code: what this does is load a picture when you click the screen, then unloads it when you click the picture. do it a few times and notice that the numbers (which show System.totalMemory) only go up but never go down to their original amount...
Code:
var url:String = "http://www.memorycity.com/shop/MBB/images/GIGABYTE_memory.jpg"; stage.addEventListener(MouseEvent.CLICK,onclick) var txt:TextField = new TextField()
I'm experiencing a few memory leaks each time my swf gets reloaded. I have closed the netstream, removed the listeners and the container, tried UnloadAndStop(); but in the end I'm still missing someting as some Mb leak anyways...Here goes my child swf source code:
Code: ////////// UrbanRevolution :MoD ////////// Built on "Video player a la Hulu" by Chris Brimelow http://chrisbrimelow.com ////////// FS function by noponies http://www.noponies.com/dev/as3_fsresize/[code]......
I' making a flash file with AS2 in Flash CS3. I put a FlVPlayback in stage and let it load a couple of FLV files from my local HDD and playing continuously. I use "addEventListener" to check the current running flash movie is completed. After complete event occur, I load another flv movie to paly again.Here, I noticed that memory usage is increasing every time a new flv file is loaded and played. I heard "addEventListener" in CS3 is causing the memory leak and not being detected by GC. [code]
I'm having what strikes me as a stupid problem, but I can't figure it out myself... it could be a subtle nuance of Flash or just some knowledge I don't have, anyway... I'm making a Flash game with a main menu and multiple levels. We didn't organize our project right (just self-taught college students doing it in our free time) so we made a level before the main menu. I ended up putting the entire level, code and all, into a MovieClip. It creates an instance of that MC when you start a level (I'm sure this was a terrible idea).
But it leaks when I delete the MovieClip and create a new one (i.e. quit the level to the main menu and then start it again). It originally leaked ~6MB each time you quit and started it again, but I've tightened it up to ~1MB, but I'd still like to fix that.
I know to Garbage Collect something you have to remove references, so I've Blanked all arraysNulled all referencesRemove all MCs dynamically added to the stage and any associated eventsRemoved every single MovieClip from the entire stage, including ones that weren't added dynamicallyNulled practically every object and variable I've only used weak-referenced events, and I've removed all of them anyway, but it's still leaking. There's way too much code for me to post all of it, so I guess I'm just wondering if anyone has any general ideas I haven't thought of.
I have create a simple timer with repeat count of 0, so it loops unlimited times.The timer repeats a function which calls for a PHP and displays data on the screen, so the data can be refreshed automatically.What I noticed though, is that the whenever the timer starts, it creats a memory leak on the system which makes the application memory usage to always go up.Is there any way to fix this?
I have got a memory leak problem in the example below(u can download the code from the link) http:[url]......
Running in Profiler:- What I am trying to do is creating new panels by selecting the Add new panel button.I am selecting option allow Close (check box).(After creating few panels and closing these panels i could find there is memory leak with the SuperPanel class) how to resolve this memory leak.I tried by changing optional parameters in addEventListener, but that didn't work.
Iam trying to debug someone elses AS3 application that is showing a memory leak. The application is built with PureMVC.I have managed to locate the place where the memory leak seems to start. There is a button that causes the application to launch a slideshow. This draws a new graph every 8 seconds or so by creating a Timer. In the Timer handle function the code uses sendNotifaction() to set off series of events which basically boil down to getting information from a server and drawing a new graph.Now if I comment out the sendNotification() the memory leak stops, but if I leave the senNotification() in but comment out the code that subsribes to it the memory usage starts to build up.So my question is can simply firing off a sendNotification() every 8 secs in PureMVC cause a memory leak, even if not other code runs from this?
I have an old project in AS2 with a video player that plays mp4s. I've noticed that FF tends to continue to eat up memory even after the video has stopped or has finished loading. I also am noticing jerky playback which I think has something to do with the memory leak.
ActionScript Code: var server_nc:NetConnection = new NetConnection(); server_nc.connect(null);
I am creating mcs in a Timer loop, and I am not keeping any references to them; I am using tweenmax ( but it has a great reputation for being clean, so I doubt that it is the culprit );
I have a serious memory leak problem. I think it's because of the use of etDefinitionByName() although I use removeChild and I put the reference to null. I made a example that illustrates this.
I have designed a site with a looping MP3 and video.
Problem is that the memory consumption of the Flash plugin goes up about 40mb every minute, and the site 'crashes' after a while. I would have thought that a single entity, that loops, would not have to re-load into memory, but this is what seems to be happening.
The looping video is approximately 800kb, and the MP3 is approximately 400kb.
It's caused by memory leak. Every time a slide is shown, the memory usage increases a few hundred kB. I've tried everything I could come up with, but even if I kick a whole lot of movieclips out, disable basically all AS3 and let only one slide loop, the memory usage still increases everytime the slide is shown again.Of course it helped to make the movieclips simpler, but the main problem remains: if you keep running the slideshow, it will slow down.
edit 1: #&^%@! Even when i copy one of the slides to a completely new file, with no external classes whatsoever, the problem remains. I think I know now what goes wrong:I make the movieclip loop by saying this.gotoAndPlay(1);Frame 1 is empty, the slide placed on frame 2. If I'd put the slide on frame 1, the mc wouldn't begin at the start and there is no animation (and no memory increase) because the mc has ended.I already figured that maybe every time the mc is shown again, Flash casts a new instance. To prevent that, everytime a slide ends, I remove it with removeChild(clip). That has no effect however, so I think that's unnecessary.
edit 2: even when the MCs are constantly on the stage and are restarted with clip.gotoAndPlay(1), the memory usage keeps growing.