Symbian
Symbian OS Library

FAQ-0487 Why does DBMS appear to have a memory leak?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: DBMS
Created: 04/11/2000 Modified: 06/06/2001
Number: FAQ-0487
Platform: ER5

Question:
Why do I appear to get a memory leak in a view?

Answer:
The following code can sometimes cause the EPOC Heap checking tools to report a memory leak:

__UHEAP_MARK;
setContract(CData &rCC);
__UHEAP_MARKEND;

However, this is not a bug. For efficiency reasons, a DBMS database will cache various parts of the database and data while it remains open. The cached objects are always deleted when the database is closed (hence there is no leak at the point of exiting your application), however opening a view may well result in allocating objects that are not freed immediately when the view is closed.

This does make it harder to test your code for memory leakages, as you cannot just test the setContract() function as above - you would also have to open and close the database within the __UHEAP_MARK and __UHEAP_MARKEND block to ensure that all DBMS objects are deleted.

See also Memory Leak Testing