[Gambas-user] Dynamic Objects

Benoît Minisini gambas at ...1...
Fri Apr 3 11:12:03 CEST 2009


> Rodney Rundstrom ha scritto:
> > Thanks for that I'll work thought over the next few day. One last
> > question on dynamic object (I think) how do we delete them and release
> > the memory?
>
> This is a matter unclear to me, anyway: an object is freed when no
> reference to it are in effect. 

What is unclear in the last sentence?

> When you instantiate a visual control,
> its parent gets a reference to the object. I don't know how to delete
> that reference (perhaps a Delete() method of its Children property?).
> For forms, a Persistent property says what to do when the form is
> closed, either hide it or destroy it. For other objects, I don't know -
> better someone else replies to you.
>
> Regards,
> Doriano
>

When an object exists only in the Gambas interpreter, like a Collection for 
example, then it is referenced only by other Gambas objects. It is destroyed 
when you release the last reference on it.

But for objects existing outside of the Gambas interpreter, it is different. 
GUI controls are in that case: they are internally referenced by the QT 
library, so they are not destroyed when you have no reference on them anymore: 
the GUI widget must be destroyed too. Hopefully, as you noticed, there is a 
Delete() method that asks the GUI to destroy a widget if you need.

Hope things are clearer...

Regards,

-- 
Benoît




More information about the User mailing list