AFAIK, in object oriented languages, an object itself is never destroyed setting to null a pointer that refers to it (and it doesn't get "overwritten" when assigning that pointer to another instance).
In some OOL (C++) you have to make an explicit call to destroy in order to free the memory allocated by an object. This can lead to memory leaks if pointers are reused / go out of scope without calling destroy. Mordern languages (Java, .NET, ActionScript) are usually garbage-collection based, so you don't need to destroy anything.. a garbage collector is automatically executed in background by the VM, tracing object instances that are not referenced by any pointer yet, and destroying them. Bye Cosma --- In [email protected], "Ravi Kumar Gummadi" <[EMAIL PROTECTED]> 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 >

