realbasic-nug
[Top] [All Lists]

Re: Object Clean Up ?

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Object Clean Up ?
From: "Aaron Ballman" <aaron at realsoftware dot com>
Date: Mon, 31 May 2004 00:13:40 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
List-help: <mailto:realbasic-nug-request@lists.realsoftware.com?subject=help>
List-id: REALbasic NUG <realbasic-nug.lists.realsoftware.com>
List-post: <mailto:realbasic-nug@lists.realsoftware.com>
References: <BAY9-F51ay7QmxhU5fT0001def4 at hotmail dot com>
> If I declare a function (for example), then I dimention and use an
> "OLEObject" variable within that function -- how concerned should I be
about
> cleaning up that variable by setting it to "Nil"?  Should I not worry
about
> it because REALbasic's "garbage collection" is so good and/or the variable
> goes out of scope once execution leaves the function and the object is
> cleaned up automatically?  Or should I take the VB5/VB6 stance and set
*ALL*
> objects I instantiate equal to "Nil" in order to clean them up and free
> their memory?

Once the variable goes out of scope, it will be automatically destroyed.
Basically, things in RB are reference counted.  When the reference count
goes to 0, the object is destroyed.  So you don't have to nil things out
explicitly unless you have a circular reference.

So I wouldn't worry about nil'ing your objects.  For most cases, it's
unneeded.

HTH!

~Aaron

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>