4DQuiz


Memory Management with Objects View from small screen devices!  

Memory Management with Objects

The memory used by objects is global to the memory space of a single instance of 4D (Standalone, Client, or Server). This means that a single object may be shared between all 4D processes within a single instance of 4D, no matter in which 4D process it was created. On the other hand, a single object may not be shared between separate instances of 4D, either on the same machine or on different machines. This includes Client and Server.

If you lose track of an object handle without clearing the object — either by storing a handle in a local variable and leaving the method in which it was created, or by using a process variable and leaving the process in which it was created — the memory occupied by the object will remain and you will not be able to clear it. This is known as a leak, and it is a Bad Thing, especially if this process is repeated many times over.

To help you track down leaks, ObjectTools keeps track of all objects that have been created but not cleared. This list is available by calling OT GetHandleList. ObjectTools comes with a 4D method for creating a log file of all leaked objects, showing their complete contents. If you call the leak logger from the On Exit Database method, you can get a good idea of what objects were leaked and then remedy the situation.

During development, you may want to reset the database to an “original” state without closing and opening the database. ObjectTools provides a method called OT ClearAll which is provided for this purpose. OT ClearAll clears all objects that are still existing, no matter where or how they were created.

Note You should not rely on OT ClearAll as a way of managing object memory.



Topics of Interest
OT IsObject,OT Clear
Creation and Destruction Routines
 

Published date: Fri, 14 Jul 2006 17:44:50 GMT   → View XML Version

Edit this page now

© 2005 - 2006 4dquiz.com, All trademarks accepted. All Rights Reserved!
Site Index