Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Circular reference
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00615370
Message ID:
00615478
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
>Your solution works fine!
>
>I try this and seems work
>
>Release inside the object trigger the destroy events, outside don't trigger?
>

Rodrigo,
It comes down what you are releasing when you issue a release.

When you create an object, it occupies some address space. When you create a new variable (in this case goBusiness), it occupies another memory space. A link is created from goBusiness to the address of the actual object so that commands like goBusiness.Somemethod can be issued.

When you issue a "Release goBusiness", you are releasing the address of goBusiness not the actual object. The internal garbage collection of the object knows to decrement the number of variables referencing itself by one. If the number of references goes to 0, then the objects Destroy method fires. If multiple references have been set up (as in your circular reference example) the internal count doesn't get decremented all the way to 0 and the objects will still exist in memory.

The key is that you are not actually releasing the object. When you issue a "Release THIS" inside the object, the release is working on the memory space occupied by the object. All memory variables referencing that memory space are immediately killed.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform