Hi,

I have something like this :

      var myTestClass=Class.create({
        initialize:function(opt) {
          this.child=null;

          // do stuff that uses mem
          // like create and show divs
          // and so on

        },
        myFnc:function(param) {

        }
      });

With this class I build a 'tree'.
  (
    in real life I use other code to do this : the child is assigned
    from within the class, but that doesn't matter for my question
  )



     var myOne=new myTestClass();
     myOne.child=new myTestClass();
     myOne.child.child=new myTestClass();
     myOne.child.child.child=new myTestClass();


I don't know how much childs there are, yet I want to free all the
memory.

Main question :

  how can I do that ?


  can I do it by : myOne=null;


  should I free every instance ?
  I tried it with a loop, first adding all childs to an array (if I
set the 'parent'
  to 'null', I can't see what's in it anymore)

      var emptyList=new Array();
      var tmp=myOne;
      while (tmp) {
        emptyList.push(tmp);
        tmp=tmp.child;
      }
      for (var i=0; i<emptyList.length; i++) {
        emptyList[i]=null;
      }
  This doesn't work: the 'reference' to the instance in 'emptyList[n]'
is a copy, not a
  'reference' so I just use more memory and then empty it again, yet I
don't free the
  tree I've made in 'myOne'. (so far as I tested)


  can I destroy it from within 'myOne' (with a destory function or
something like that)
    (I tried this=null in the class but that doesn't work ;))


Thanx.

Kind regards,

mtjs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to