memory leak problem

Login to reply to this topic.
Fri, 2007-02-23 14:17
Joined: 2005-01-18
Forum posts: 75
Hi, for the UI application, is that true that the Symbian framework will automatically check if there is a memory meak? So basically there is no need to use __UHEAP_MARK and __UHEAP_MARKEND macros, am I right??

BTW, about __UHEAP_MARK and __UHEAP_MARKEND, for example:

__UHEAP_MARK;

HBufC* test = HBufC::NewLC(2);
/*asynchronos call here and the test variable
   will be deleted in the callback */
__UHEAP_MARKEND;

do you guys think this can still cause a false memory leak sometimes?

Don't laugh at me, I am just a supernewbie


Fri, 2007-02-23 16:45
Joined: 2006-10-07
Forum posts: 131
Re: memory leak problem
Symbian framework places these macros at the beginning and the end of your program, so you see ALLOC panic when you exit and forget to deallocate something, that's where "automatic" checking comes from. It doesn't mean you do not need to use these macros, you should use them where appropriate. In your example, however, this checking doesn't make sense: it will always generate ALLOC panic, because the number of heap cells at __UHEAP_MARK and __UHEAP_MARKEND will always be different.


I, for one, always use it in my unit tests:
Code:
void
TestXXXX()
{
__UHEAP_MARK;
CObj *obj = CObj::NewLC();
obj->DoSomeTestL(...);
CleanupStack::PopAndDestroy(obj);
__UHEAP_MARKEND;
}
Mon, 2007-02-26 08:29
Joined: 2005-01-18
Forum posts: 75
Re: memory leak problem
Thanks, man Cheezy

Don't laugh at me, I am just a supernewbie

  • Login to reply to this topic.