realbasic-plugins
[Top] [All Lists]

Class destructors

To: REALbasic Plugins <REALbasic-Plugins at lists dot realsoftware dot com>
Subject: Class destructors
From: Norman Palardy <palardyn at shaw dot ca>
Date: Mon, 14 Mar 2005 14:52:24 -0700
Cc:
Delivered-to: REALbasic-Plugins at lists dot realsoftware dot com
I'm working on a plugin

In the plugin I have defined a class (class1) and one of the methods returns another class (class2) which is in the plugin.

The Class1 instance may have 1 or more Class2 instances (depending on a bunch of things at runtime)

When I do

        dim class1Var as Class1
        dim class2Var as Class2
        dim i as integer

        class1Var = new Class1

        for i = 1 to Class1.Count

                class2Var = class1.Value(i)

        next

what I'm seeing is that class1Var's is properly constructing the class2 instance to be returned. BUT, class2Vars destructor is not being called IF there already is an instance.
So the darn loop leaks.

But if I do

        dim class1Var as Class1
        dim class2Var as Class2
        dim i as integer

        class1Var = new Class1

        for i = 1 to Class1.Count

                class2Var = class1.Value(i)

                class2Var = nil
        next

this does not leak because the instance's destructor gets called.

Does that make sense ?

How do I fix this kind of issue ?

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

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

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