Flex :: Garbage Collect Variable In It Even There Are Other Objects Binded To It?
Jan 22, 2011I'm wondering how to garbage collect a variable in Flex even if there are other objects binded to it.
View 1 RepliesI'm wondering how to garbage collect a variable in Flex even if there are other objects binded to it.
View 1 RepliesI'm working on a flash game that has developed an obvious memory leak. I do what I'm supposed to do with GC; remove all references to the object, nullify it, remove all listeners (or use weak listeners); but the leak is still present.
I've stumbled across this article: [URL].. It claims that objects that are too large will never be garbage collected. This theory fits well with my project since all of my game resides in a couple of huge MovieClips that are created and destroyed often.
Is there any merit to the claim that objects that are too large will never be garbage collected?
I'm struggling a bit to fully understand garbage collection. To be honest I don't understand why this just can't be taken care of automatically but hey - I'm not a programmer so what do I know... Now to my question - I have the following code:
Code:
var format:TextFormat = new TextFormat();
format.letterSpacing = -3.5;
huvud_txt.setTextFormat(format);
Is it enough to set format = null; to destroy the format object or is there some crossreference going on here so that I need to do something more? huvud_txt is a textfield on stage - it's not created with code...
If I dump a lot of sprites into a vector, then want to garbage collect and repopulate the vector, what is the best way to do this? My app will be reusing the same vector over and over and I'm a bit worried it may have performance issues.
[Code]....
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]......
How do I make Flex/ActionScript 3 objects eligible for garbage collection? What are the thumb rules?
View 5 RepliesI'm creating a kiosk with a place for visitor's comments. There are several sections to the kiosk each with their own stand-alone .swf file (not browser based; no html). I'm planning on using Shared Objects to collect the input from the visitors in each section and these will periodically be reviewed by museum staff before actually getting posted. My question is, can I create one .swf for museum staff that uses an array to review each of the SO's created by the individual sections or will a flash file ONLY read in one SharedObject forcing me to create a separate app for each section for the museum staff?
View 1 RepliesI have a problem..I am binding an array collection to a datagrid in flex. My problem is whenever i try to remove an item from the array collection.. the datagrid does not refresh the values....This is the code that I am using
[Code]....
eventsList is the datagrid that is bounded to showArray(an Array Collection)
I was thinking about Flash GC the other day and came up with a question about how reference counting would work in the following 4 class scenario (assume GuiMain is the movie's document class):
[Code]...
I have extended CheckBox class to use it as itemRenderer to centered it in DataGrid cell and reflect ArrayCollection changes. Here is the .as:
package myComponents
{
import flash.display.DisplayObject;
[code]......
I have checked and rechecked, and I do not know why these "buckets" aren't being killed when I run the reset menu function, a fresh set of eyes could really help.
Code:
package com.Views {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
[Code]...
i'm sure there are a lot of problems, but the only one I care about is destroying those buckets. inside the buckets, I have a listener for "removed from stage", and that kills all the listeners, etc, inside the buckets.
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 RepliesI'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 RepliesI'm looking for a way to collect the file dependencies from Flex ActionScript and MXML files. I was hoping that mxmlc could spit them out (like gcc's -M option), but its option list doesn't seem to have anything relevant. I could write a parser, but would prefer not to reinvent the wheel if it has already been done, particularly given the two very different languages involved. In particular, star imports and in-package implicit imports could be troublesome.
View 2 RepliesI 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]...
I'm forgetting now exactly how I should dispose of unneeded objects. In the past, every object/class I created had a public dispose() function which removes all added listeners inside it and called the kill/dispose function on any children of it that may need the same (so it worked its way down the tree, as this process can continue for as many children/grandchildren there are in the list). So basically, the code in the parent class would look like this:
Code:
childObj.removeEventListener(MouseEvent.MOUSE_DOWN, anotherHandler);
childObj.dispose();
childObj = null;
...and the childObj class would look like this:
[Code] .....
Do I need to set any variables/objects defined in the child class's class scope to null prior to setting the class itself to null? Or is this handled automatically when I set the class itself to null from the parent (assuming these class-scope-defined variables/objects have no listeners or child objects which need to be disposed themselves)?
I'm trying to set up a test that will tell me whether a variable exists in memory or not. I'm running into the problem of my nested function preserving the local variable it uses, called "shouldBeDead". Here's my best effort, which doesn't work for me because the "shouldBeDead" variable is still alive[code]...
View 4 RepliesWhen 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]....
I am implementing garbage collection within an AS3 app. In one part, several display objects are created within a loop like so:
for(var i:uint = 0; i <= this._exampleVector.length - 1; i++)
{
this._customText = new CustomTextObject(this._exampleVector[i].playlistText), this._customTextWidth);
[Code].....
When I try to make the _customText within the _customTextVector null, this does not work. It only makes the index inside the Vector null. how to do this or another method to garbage collect?
I am trying to create a simple form using Actionscript 3 that will collect data from a form, then pass that data to an asp file. I have attached the following code to the submit button,but this is not working.I'm not sure if I have to add anything else and I don't understand why this is not working. I'm trying to load all the variable info into one variable called email form.
submit_btn.onRelease = function() {
var emailform:text;
emailform.email_txt = email_txt.text;[code]......
If you have a variable that is a MovieClip, Sprite, String, Number, int, uint, or a Boolean, do you remove it's reference by adding:
myVariable = null;
OR delete(myVariable);
How do I align a movieclip, which width and height is user-defined, inside another object (this one is static, though). Top-left alignment is easy, x=0 and y=0, but what about center, center left, bottom left, etc? Math(.round) i suppose, but how?I want an object (static) inside the movieclip (user-defined) to stay aligned to, for instance, the top right corner, similiar to the minimize, maximize and close buttons at the top right of your browser.. The height and width data is pre-defined by the user in another file.But that does probably not make any difference...
View 3 RepliesI have that function in the class:
private function fireItemCreated(data: ByteArray): void {
setTimeout(function(): void {
var event: ItemCreatedEvent = new ItemCreatedEvent(data);
dispatchEvent(event);
}, 1000);
}
This function called to dispatch item created event when image thumbnail created.But it delays event on some time to prevent user interface freezes. And I'm guessing what could be happen if garbage collector executes after fireItemCreated function call but before timer event. Does the closure will be removed or it stays until it will be executed?
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.
Is there any way to collect all external assets (images, videos, etc) and put them in one selected folder?
View 2 RepliesI'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.
This thread is designed to help collect discussion on the Random Movement in AS3 tutorial.
View 2 Replies Let a qualified-user place a dot on a country map and this dot will be shown on the map. When other users come by they see dot's and those dot's trigger a image.
1 Create a map, duh
2 Use the mouse to get the coordinates (_x and _y position) onRelease will be the selected coordinates.
3 Create a preview-scene were the qualified user sees the placement of his dot.
4 If oke, a image upload scene is triggered (the selected _x and _y coordinates are hidden)
5 The qualified user selects a image on his computer.
6 Again a preview scene, now with the dot on the map and the selected image.
7 If oke the user sends the coordinates and image to the server (i will use php-files to upload the info and a mysql-db to store the info)
I am stuck with step 2. In the attach file you can see what i have so fare.The trace messages are the data i want to send to a php script. And think i must create an array in flash something like:
Code:
coords = new array();
for (i=0;i<=v;i++)[code]...
You gotta see the attach .fla to understand this. I have the values collected in "controller" movieClip.
Internally Flash obviously keeps a list of the primitives drawn using Graphics so I wondered if you have many such primitives in a Sprite, can you re-position/remove/alter individual items rather than clear and re-draw everything? Or is this deeper into the bowels of Flash than you're allowed (or recommended) to go?
View 4 RepliesI'm using Zend AMF to send my remote objects to Flex. I've defined a Constant class and created getASClassName() method. Then I've created Action script class in flex.
Objects are send successfully, but they are deserialized to generic Objects in Flex instead of specific ones. EDIT: On network monitor in Flex I can see that AMF value is set to com.my.project.valueobjects.Constant. Although array from event.result contains Objects.
[Code]...