diff -r 35cb3fe43f60 -r d0e1c40de386 commands/leak/leak.cpp --- a/commands/leak/leak.cpp Thu Aug 12 16:38:42 2010 +0100 +++ b/commands/leak/leak.cpp Fri Aug 13 13:09:59 2010 +0100 @@ -12,6 +12,9 @@ #include "leak.h" #include +#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR +#include +#endif const TInt KMinChunkSize = 4 * 1024; const TInt KMaxChunkSize = 512 * 1024 * 1024; @@ -26,6 +29,12 @@ CCmdLeak::~CCmdLeak() { +#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR + if (iLoggingAllocator) + { + // Hmm how do I clean up a logging allocator created with RLoggingAllocator::New()? + } +#endif iChunk.Close(); if (iChunkHeap) { @@ -67,10 +76,21 @@ } } + if (iUseLoggingAllocator) iUseHeap = ETrue; // Using the logging allocator implies the --heap option + if (iUseHeap) { iChunkHeap = UserHeap::ChunkHeap(NULL, KMinChunkSize, 256*1024*1024); if (!iChunkHeap) LeaveIfErr(KErrNoMemory, _L("Couldn't create chunk heap")); + iAllocatorToUse = iChunkHeap; + +#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR + if (iUseLoggingAllocator) + { + LeaveIfErr(RLoggingAllocator::New(0, iChunkHeap, iLoggingAllocator), _L("Couldn't create logging allocator")); + iAllocatorToUse = iLoggingAllocator; + } +#endif } else { @@ -137,6 +157,11 @@ _LIT(KOptRetry, "retry"); aOptions.AppendBoolL(iRetry, KOptRetry); + +#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR + _LIT(KOptUseLoggingAllocator, "logging-allocator"); + aOptions.AppendBoolL(iUseLoggingAllocator, KOptUseLoggingAllocator); +#endif } void CCmdLeak::ArgumentsL(RCommandArgumentList& aArguments) @@ -153,9 +178,9 @@ TInt CCmdLeak::LeakStep(TInt aAmount) { TInt err = KErrNone; - if (iChunkHeap) + if (iAllocatorToUse) { - TAny* cell = iChunkHeap->Alloc(aAmount); + TAny* cell = iAllocatorToUse->Alloc(aAmount); if (!cell) err = KErrNoMemory; } else