Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AddObject/RemoveObject
Message
From
22/03/2002 12:04:34
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00635975
Message ID:
00636119
Views:
21
>BTW, this whole discussion is revloving arround an essential OO issue. That being that objects that contain other objects MUST celan up after themselves.
>
>Your question about memory leaks is really only relevant because you have not made the form clean up its space on destruction. If you use AddObject the way it is intended then the form will automatically destroy the objects added. However, if you are using the array technique you described then YOU must clean up after yourself as the objects created are not truly objects contained in the form but rather are objects to which the form holds a reference. This is the difference between containership and aggregation, the array is using aggregation while the simple AddObject is using containership.
>
>In VFP the containership model will clean up automatically while you must clean up the aggregation.

Hilmar's method of using AddObject DOES work correctly, without need to clean up yourself. VfP unfortunately modifies the names of the objects it adds to the form, so the RemoveObject does not find them again - but they are still in the Controls array & are correctly cleaned up on releasing the form.
Len Speed
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform