[Gambas-user] Do embeded objects get released too upon destruction ?
nando
nando_f at ...951...
Sat Jul 23 20:29:37 CEST 2011
Ok, so the following line...
DIM Q AS NEW myClass[5]
would need...
FOR i = 0 TO 4
myClass[i] = NEW myClass
NEXT
to instantiate each myClass object.
The _init would then execute creating the string objects
Does this line...
myClass[5] = NULL
do a deep unreference to the embedded strings too?
---------- Original Message -----------
From: "nando" <nando_f at ...951...>
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Sent: Sat, 23 Jul 2011 14:24:17 -0400
Subject: Re: [Gambas-user] Do embeded objects get released too upon destruction ?
> Does not the following line make the class "_init" execute with
> each new instance of the class?
>
> DIM Q AS NEW myClass[5] ' constructor executes 5 times
>
> Then, with each new instance there is the NEW object array with HELLO 100 times
>
> When the reference to myClass is gone, as in:
>
> myClass[2] = NULL
>
> Is there a deep unreference to the embedded objects?
>
> ---------- Original Message -----------
> From: Benoît Minisini <gambas at ...1...>
> To: nando_f at ...951..., mailing list for gambas users
> <gambas-user at lists.sourceforge.net>
> Sent: Sat, 23 Jul 2011 15:26:56 +0200
> Subject: Re: [Gambas-user] Do embeded objects get released too upon destruction ?
>
> > > Question:
> > >
> > > If I have a class 'myClass' with the following:
> > >
> > > DIM k = NEW OBJECT[100]
> > >
> > > PUBLIC SUB _init()
> > >
> > > DIM i AS INTEGER
> > >
> > > FOR i = 1 TO 100
> > > k[i] = NEW STRING[] 'add a string array
> > > k[i].add("HELLO") 'add one element with "HELLO"
> > > NEXT
> > >
> > > END
> > >
> > >
> > > Somewhere else I have:
> > >
> > > DIM Q AS NEW myClass[5] ' constructor executes 5 times
> >
> > No : you are creating an array of myClass references, but you are not creating
> > any myClass object at all.
> >
> > And this is a normal array, not an embedded one.
> >
> > >
> > > Q[2] = NULL '<---will the embeded string memory get freed too
> > > when the myClass object is freed ??
> >
> > What is "string memory" ?
> >
> > Anyway a myClass object will be freed as soon as nothing has a reference on
> > it.
> >
> > Regards,
> >
> > --
> > Benoît Minisini
> >
> > ------------------------------------------------------------------------------
> > Storage Efficiency Calculator
> > This modeling tool is based on patent-pending intellectual property that
> > has been used successfully in hundreds of IBM storage optimization engage-
> > ments, worldwide. Store less, Store more with what you own, Move data to
> > the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> ------- End of Original Message -------
>
> ------------------------------------------------------------------------------
> Storage Efficiency Calculator
> This modeling tool is based on patent-pending intellectual property that
> has been used successfully in hundreds of IBM storage optimization engage-
> ments, worldwide. Store less, Store more with what you own, Move data to
> the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------
More information about the User
mailing list