Please tell me how to use __UHEAP_CHECK to check memory allocation

Login to reply to this topic.
Tue, 2008-03-04 05:22
Joined: 2008-03-04
Forum posts: 2

I want to use __UHEAP_MARK, __UHEAP_CHECK(), and _UNHEAP_ENDMARK to check the memory allocation.
I used it like this:
__UHEAP_MARK;
CMyClass* iMyClass = CMyClass::NewL();
__UHEAP_CHECK(1);

CMyClass is a class which is defined by myself, but when I run it in debug model, there was a panic at __UHEAP_CHECK(1), I want to know whether the reason is that the parameter should not be "1", i.e,the expected number of allocated cells is not 1, or not.

And, please teach me how to use these, it's better to show me some examples which are related with self-defined class.

The last question is, as the descriptions given in the SDK, "If checking fails, the function raises a panic. Information about the failure is put into the panic category, which takes the form: "ALLOC COUNT\rExpected aaa\rAllocated bbb\rLn: ccc ddd", but my panic is not like this, it just shows "ALLOC COUNT\rExpe 1",there is not other informations, I wonder if my use of them is wrong.

PS: The NewL() func of my class CMyClass is just:
CMyClass* CMyClass::NewL()
{
CMyClass* self = NewLC();
CleanupStack::Pop();
return self;
}

CMyClass* CMyClass::NewLC()
{
CMyClass* self = new (ELeave) CMyClass;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}

CMyClass* CMyClass::ConstructL()
{
// do nothing, empty
}


Tue, 2008-03-04 11:17
Joined: 2008-01-03
Forum posts: 21
Please tell me how to use UHEAP_CHECK to check memory allocation

i tried the code that u have given
it should not give any panic at __UHEAP_CHECK(1) in carbide 1.1
may be u have not deleted the pointer " iMyClass" before writing _UNHEAP_MARKEND

n there in no _UNHEAP_ENDMARK rather there is _UNHEAP_MARKEND
u can refer the folowing links for
(1) .__UHEAP_CHECK(aCount )

http://www.symbian.com/developer/techlib/v8.1bdocs/doc_source/reference/reference- cpp/N101B6/__UHEAP_CHECKDefine.html

(2). __UNHEAP_MARKEND
http://www.symbian.com/developer/techlib/v8.1adocs/doc_source/reference/reference-cpp/n101ba/MemoryAllocation/UHEAPMARKENDMacro.html

the important line is (This macro must match an earlier call to __UHEAP_MARK.)

(3) __UNHEAP_MARK
http://www.symbian.com/Developer/techlib/v70sdocs/doc_source/reference/cpp/MemoryAllocation/UHEAPMARKMacro.html

  • Login to reply to this topic.