AW: AW: [Flashcoders] - Array memory performance
Thanx fort he answer, it was very helpful. The main thing was that in C++ you don't have a GC, now that I know Flash has one, the rest is just fine :-) I now realised what crap I wrote on that push(z)-line... gosh!!! Even in C++ I would have got an error by the compiler! Thnx a lot! -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Jeremy Sachs Gesendet: Freitag, 18. Mai 2007 02:06 An: flashcoders@chattyfig.figleaf.com Betreff: Re: AW: [Flashcoders] - Array memory performance Hmm... what do you mean here by configurator, Cryzto? Well my plan was to fill up the array with object's-name that are visible in the configurator (active ones)... Remember that some objects have name as a property- it's a String. If by name you mean the name of the reference you're using when you're referring to an object, then you mean the definition. See, every data type in Flash is an object, and the variables you're creating are all just references to the objects. By assigning a new Array object to my_array, you're automatically deleting the reference to the old Array (so the line where you delete my_array isn't actually necessary). If that was the only reference to it, it'll be cleaned up by the GC. I believe that Arrays and other simple data types are deallocated almost immediately. More complicated objects tend to take a little longer. There's a lot of info out there regarding the GC, but what it comes down to is, you never know exactly when the GC will run, or whether it'll remove all your garbage. It's a leap of faith. But you can help the GC operate faster by removing all the references to the objects you want to delete. For instance, if you write: var a:Array = new Array(); var b:Array = a, c:Array = b, d:Array = c; ...then you've got four references to the same Array object. That Array won't be deallocated until each reference is deleted or set to equal null. Sorry, but I don't know which assignement you exactly refer to, do you mean my_array.push(z)=z; ? Yes, push() is a method of Array objects that takes a value passed to it and adds an element with that value to the very end of the array. You don't need the =z, which, well, doesn't make much sense in the first place. :D I hope that helps. Regards, Rezmason ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.7.3/809 - Release Date: 17.05.2007 17:18 -- Ich verwende die kostenlose Version von SPAMfighter für private Anwender, die bei mir bis jetzt 845 Spammails entfernt hat. Bezahlende Anwender haben diesen Hinweis nicht in ihren E-Mails. Laden Sie SPAMfighter kostenlos herunter: http://www.spamfighter.com/lde ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
AW: [Flashcoders] - Array memory performance
Thnx for the info Attila. Well my plan was to fill up the array with object's-name that are visible in the configurator (active ones) cause the invisibles ( _alpha = .25 ) are not important for the user (inactive ones). The thing with the low-level memory ist hat I don't know how Flash handles it, in C++ the Developer ist he one to manage that problem. But I guess u're saying it works more or less like Java (with a garbage-collector) since it works on VM. Yes, it is wrong of course, since only a variable or property can be on the left side of an assignment. What do you want to do with this? I don't understand it at all. push() returns the new length of the array - what do you want to assign to it? Sorry, but I don't know which assignement you exactly refer to, do you mean my_array.push(z)=z; ? It's only a test-code to show me a value has been stored in the array. Thnx 4 that quick answer Attila. Cryzto ;-) -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Rákos Attila Gesendet: Freitag, 18. Mai 2007 00:27 An: Cristo @ cryzto.ch Betreff: Re: [Flashcoders] - Array memory performance Ccc Is in the following code something wrong: Ccc Ccc var my_array:Array = new Array(); Ccc Ccc for (var z=0; zx; z++){ Ccc my_array.push(z)=z; Ccc } Yes, it is wrong of course, since only a variable or property can be on the left side of an assignment. What do you want to do with this? I don't understand it at all. push() returns the new length of the array - what do you want to assign to it? Ccc Im rather skilled in C++, and there I have to do that for not overfilling Ccc dynamic memory (heap)! What do you have to do there? In general you don't have to care about low-level memory management in Flash at all, the VM is responsible for such tasks. Ccc I want to fill up an array and later empty it so i can fill it again from Ccc scratch, Important is I dont want to empty the array element by element Ccc using a loop. No loop is required, a simple splice(0) is enough. Or you can create a new array instance, too - of course. Attila ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.7.1/807 - Release Date: 16.05.2007 18:05 -- Ich verwende die kostenlose Version von SPAMfighter für private Anwender, die bei mir bis jetzt 452 Spammails entfernt hat. Bezahlende Anwender haben diesen Hinweis nicht in ihren E-Mails. Laden Sie SPAMfighter kostenlos herunter: http://www.spamfighter.com/lde No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.7.1/807 - Release Date: 16.05.2007 18:05 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: AW: [Flashcoders] - Array memory performance
Hmm... what do you mean here by configurator, Cryzto? Well my plan was to fill up the array with object's-name that are visible in the configurator (active ones)... Remember that some objects have name as a property- it's a String. If by name you mean the name of the reference you're using when you're referring to an object, then you mean the definition. See, every data type in Flash is an object, and the variables you're creating are all just references to the objects. By assigning a new Array object to my_array, you're automatically deleting the reference to the old Array (so the line where you delete my_array isn't actually necessary). If that was the only reference to it, it'll be cleaned up by the GC. I believe that Arrays and other simple data types are deallocated almost immediately. More complicated objects tend to take a little longer. There's a lot of info out there regarding the GC, but what it comes down to is, you never know exactly when the GC will run, or whether it'll remove all your garbage. It's a leap of faith. But you can help the GC operate faster by removing all the references to the objects you want to delete. For instance, if you write: var a:Array = new Array(); var b:Array = a, c:Array = b, d:Array = c; ...then you've got four references to the same Array object. That Array won't be deallocated until each reference is deleted or set to equal null. Sorry, but I don't know which assignement you exactly refer to, do you mean my_array.push(z)=z; ? Yes, push() is a method of Array objects that takes a value passed to it and adds an element with that value to the very end of the array. You don't need the =z, which, well, doesn't make much sense in the first place. :D I hope that helps. Regards, Rezmason ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: AW: [Flashcoders] - Array memory performance
Jeremy Sachs wrote: Hmm... what do you mean here by configurator, Cryzto? Well my plan was to fill up the array with object's-name that are visible in the configurator (active ones)... Remember that some objects have name as a property- it's a String. If by name you mean the name of the reference you're using when you're referring to an object, then you mean the definition. See, every data type in Flash is an object, and the variables you're creating are all just references to the objects. By assigning a new Array object to my_array, you're automatically deleting the reference to the old Array (so the line where you delete my_array isn't actually necessary). If that was the only reference to it, it'll be cleaned up by the GC. I believe that Arrays and other simple data types are deallocated almost immediately. More complicated objects tend to take a little longer. There's a lot of info out there regarding the GC, but what it comes down to is, you never know exactly when the GC will run, or whether it'll remove all your garbage. It's a leap of faith. But you can help the GC operate faster by removing all the references to the objects you want to delete. For instance, if you write: var a:Array = new Array(); var b:Array = a, c:Array = b, d:Array = c; ...then you've got four references to the same Array object. That Array won't be deallocated until each reference is deleted or set to equal null. Sorry, but I don't know which assignement you exactly refer to, do you mean my_array.push(z)=z; ? Yes, push() is a method of Array objects that takes a value passed to it and adds an element with that value to the very end of the array. You don't need the =z, which, well, doesn't make much sense in the first place. :D I hope that helps. Regards, Rezmason ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com To Rezmason: The simple data types are called primitives. These include Numbers, ints, uints, Strings. Complex data types include everything else (Objects, Arrays etc.) Primitives are cleaned up immediately (using the delete keyword or null) For more information you can find a great article on Garbage Collection (GC) and Resource Management here: http://www.gskinner.com/talks/resource-management/ Cheers, Nick ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com