Let me get this straight... did you suggest not to use local variables? "My suggestion; don't use it. And when you do (meaning you create local variables)"
What do you suggest instead? I'm not making every variable a member variable... Thanks for the info on the Activation object. I will null out my local variables at the end of the function, but it sure seems weird to suggest not to use them at all! Also, seems like a pretty bad shortcoming not to have a deconstructor or finalizer or anything. One last question, does calling delete on an object release any Activation objects created for it? thanks, Thunder --- In [email protected], "JesterXL" <[EMAIL PROTECTED]> wrote: > > Nope. Some people used onUnload for MovieClips, but I wouldn't touch that > method with a 10ft-pole. > > From the MM docs: > > "The Activation object. (A temporary object that is automatically created > when a function is called that holds the local variables called in the > function.)" > > The Activation Object can actually live on long after the function has > finished being removed from the stack. This is an ethereal plane that is > useful for getting around scope challengs people had in the early days of > ActionScript 2 development. > > My suggestion; don't use it. And when you do (meaning you create local > variables), set them to null at the end of the function. > > function cow() > { > var a:String = "moo"; > a = null; > } > > ----- Original Message ----- > From: "thunderstumpgesatwork" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Monday, February 20, 2006 12:56 PM > Subject: [flexcoders] Re: Object cleanup and memory usage "Best Practices" > (2.0b1) > > > Thanks for the tips. I a couple questions about your comments. > > - question regarding number 3,5... is there a deconstructor in > ActionScript that I can place cleanup code? > > - number 6 what do you mean by activation object? Do you mean > RemoteObject? if so, could you please explain how to clean it up > properly, as I need to use it, and there was no documentation on how > to clean it up. > > Thanks! > > --- In [email protected], "JesterXL" <jesterxl@> wrote: > > > > 6 rules of thumb: > > > > 1. never trust an alpha for benchmarking > > > > 2. never trust a beta for benchmarking > > > > 3. if it's a member variable, delete it: > > > > delete myVar; > > > > 4. if it's a local variable, null it at the end of the function: > > > > function cow() > > { > > var a:String = ""; > > a += "one"; > > a += "two"; > > a = null; > > } > > > > 5. remove your event listeners before destroying the objects you > registered > > with > > > > 6. do not use the activation object unless you know how to clear it > later > > (most people I've seen in AS2 never do, so try not to use it period). > > Example is xml.onLoad where the xml is created as a local variable in a > > function. It'll live on even though it's a local variable. > > > > ----- Original Message ----- > > From: "thunderstumpgesatwork" <thunder.stumpges@> > > To: <[email protected]> > > Sent: Saturday, February 18, 2006 7:02 PM > > Subject: [flexcoders] Object cleanup and memory usage "Best Practices" > > (2.0b1) > > > > > > Hi all, > > > > I've been coding in Flex now for a few months (basically since the 2.0 > > Alpha came out) and I've been having a heck of a problem with memory > > leaks. > > > > I was curious if there's any kind of rules or best practices to use > > for cleaning up AS objects (destructors? finalize()? or other?) This > > is especially pertinent because I am using lists/hash's, charts, and > > RPC Services. > > > > I couldn't really find any documentation regarding clean-up and memory > > leaks. Does anyone out there have any experiences/knowledge to share? > > > > Below, I'll outline my architecture, and note that I have no > > cleanup/de-construction code right now at all, other than setting > > variable references to new objects or null. Sorry it's pretty long, so > > if you want to stop reading here and provide any ideas you have, feel > > free =) > > > > thanks, > > Thunder > > _____________ > > > > > > Basically I am running dynamic DB queries through a singleton > > RemoteObject called by a "ChartResults" class that holds the results > > (e4x XML) of the query and metadata info related to it. I have > > employed the "Asynchronous Completion Token" documented approach to > > allow the ChartResults classes to pick out only their calls from the > > singleton R.O. > > Is this detrimental to performance if there are anywhere from 4-10 SQL > > calls possibly going through the one RemoteObject? (note - that's an > > upper limit during initial startup only) > > > > The ChartResults class caches information as it is retrieved from the > > results (often after performing filtering/sorting, etc). > > > > When a new query result comes in, the I clear all the cache > > items by setting the hash objects or Array to null or new Object/Array > > respectively. > > > > 1 - Does setting a property referencing a Collection to null also > > release the source Array held in it? > > > > 2 - Do I also need to set each item in the Array to null? > > > > 3 - If a hash Object had many different XMLList properties cached, > > do I need to iterate and null all these properties using introspection? > > > > Also, on the Chart side, I have been deleting the series array and > > creating a new one when re-populating the chart (if it is showing > > entirely new/different data). > > > > 4 - Do I need to do any cleanup of the series items maybe? > > > > 5 - Are the Series getting cleaned up and releasing their dataProvider > > objects? > > > > Somewhere I am leaking memory badly as the number of chart queries > > goes up and up... > > > > Thanks again! > > Thunder > > > > > > > > > > > > > > -- > > Flexcoders Mailing List > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > > Yahoo! Groups Links > > > > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

