Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to clean up leftover Objects?
Message
From
01/04/2010 13:19:43
 
 
To
26/03/2010 08:15:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01457283
Message ID:
01458414
Views:
68
Yep. This helps a lot.

Thanks, Doug.

>Hi Matt.
>
>>In the code I declare a public loBo variable to hold the object so I can make further use of it from the command window if I wanted to. After further testing, I RELEASE loBo, then I try to open the parent class of the class I tested so I can edit it, but it says: "Remove classes from memory?" and I click "Remove", then it says "Cannot modify a class that is in use".
>
>Instead of RELEASE loBo, use loBo.Release (you may have to add a Release method to the object). The difference is that RELEASE loBo releases the memory variable holding a reference to the object, but not necessarily the object itself if a reference to it is also stored somewhere else. For example, suppose loBo contains a reference to ObjectA, ObjectA contains (in a property) a reference to ObjectB, and ObjectB contains (in a property) a reference to ObjectA. RELEASE loBo releases the memory variable, but because ObjectB also contains a reference to ObjectA, ObjectA (and therefore ObjectB) can't be destroyed. However, since the memory variable is now gone, you have no way to reference either ObjectA or B.
>
>Instead, in the Release method of your objects, make sure you clean up any references that may be outstanding. For example, in ObjectA.Release:
>
>
This.oObjectB.Release()
>release This
>
>In ObjectB.Release:
>
>
This.oObjectA = .NULL.
>release This
>
>Now, loBo.Release() will release all references to both ObjectA and B.
>
>Doug
Previous
Reply
Map
View

Click here to load this message in the networking platform