Hi jeffry,
The are public functions ! :-( Regards Ravi ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jeffry Houser Sent: Thursday, June 07, 2007 5:46 PM To: [email protected] Subject: Re: [flexcoders] Parameter passing !! I am shocked I think you missed his point. He sent in obj as a parameter to a function. So objParam should be a reference to obj; and nulling one should definitely null the other. I do notice that the functions in the example are not declared as functions with the "public function" keywords. Could that be a contributing factor to the problem? Roman Protsiuk wrote: > > > objParam is not the same reference to created object as obj. Whenever > you set objParam to null it becomes null (try checking it out in your > deleteObject method). But who said the obj should become null? To > prepare obj for garbage collection you should set obj to null. > > R. > > On 6/7/07, *Ravi Kumar Gummadi* <[EMAIL PROTECTED] <mailto:ravigummadi%40ivycomptech.com> > <mailto:[EMAIL PROTECTED] <mailto:ravigummadi%40ivycomptech.com> >> wrote: > > > Hi all > > How does flex handle parameter passing, as I understand, it is by Pass > by reference. But I was having some memory leaks and playing around a > few tweaks and the following snippet completely took me by surprise. > > // CODE START > > <script> > > public var obj:Object; > > createObject(){ > > obj = {test:"1234",test2:"5678"}; > } > > checkObject(objParam:Object){ > trace(objParam); > } > > deleteObject(objParam:Object){ > objParam = null; // I tried objParam = undefined as well > } > > </script> > > <mx:Button id="create" click="createObject()" /> > <mx:Button id="check" click="checkObject(obj)" /> > <mx:Button id="delete" click="deleteObject(obj)" /> > > // END > > Now 1. I created the object by click on create > 2. Then check for the existence of it (Traces [object object].. This > is fine) > 3. Then clicked delete. > 4. Then again click on check... (Traces [object] [object] > !!!!!!!!!!!!!!!!!!!!! But since its passed by reference it should be > NULL) > > Somewhere I read that it setting to NULL changes the reference count, > does that mean in each of my function I need to set all the params to > null at the end of it so that refercne count is reduced and raady for > garbage collection!! ( That doesn't quite a sense !!) > > Regards > Ravi > -- Jeffry Houser, Technical Entrepreneur, Software Developer, Author, Recording Engineer AIM: Reboog711 | Phone: 1-203-379-0773 -- My Company: <http://www.dot-com-it.com <http://www.dot-com-it.com> > My Podcast: <http://www.theflexshow.com <http://www.theflexshow.com> > My Blog: <http://www.jeffryhouser.com <http://www.jeffryhouser.com> >

