diff -r 000000000000 -r dd21522fd290 webengine/osswebengine/MemoryManager/Inc/MemoryLogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webengine/osswebengine/MemoryManager/Inc/MemoryLogger.h Mon Mar 30 12:54:55 2009 +0300 @@ -0,0 +1,125 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef _MEMORYLOGGING_H +#define _MEMORYLOGGING_H + +// INCLUDES + +#include +#include +#include +#include + +#ifdef OOM_LOGGING +// CONSTANTS + +_LIT( KMEMLogDir, "WebCore"); +_LIT( KMEMLogFile, "Memory.log"); +_LIT8( KFuncMemLogBegin, "BEGIN: %S @ %S/%d InSize -> %d" ); +_LIT8( KFuncMemLogEnd, "END: Peek -> %d Diff -> %d Accumulated Peek -> %d" ); +_LIT8( KTab, "\t" ); + +// MACROS + +#define MEM_LOG(a) { _LIT8(temp, a); RFileLogger::Write(KMEMLogDir, KMEMLogFile, EFileLoggingModeAppend, temp); } +#define MEM_LOGF FPrint + +// FUNCTION DECLARATIONS + +inline void FPrint(const TRefByValue aFmt, ...) +{ + VA_LIST list; + VA_START(list,aFmt); + RFileLogger::WriteFormat(KMEMLogDir, KMEMLogFile, EFileLoggingModeAppend, aFmt, list); +} + +// CLASS DECLARATION + +/** +* A utility class to record the memory usage inside a function +* @lib memman.lib +* @since 3.1 +*/ +class FunctionLogger + { + public: + inline FunctionLogger( const TDesC8& func, const TDesC8& file, TInt line, TInt size ); + inline ~FunctionLogger(); + + TInt _peek; + TInt _used; + TInt _accum; + TInt _inSize; + static RPointerArray loggers; + }; + +// MEMBER FUNCTIONS + +//----------------------------------------------------------------------------- +// FunctionLogger::FunctionLogger +//----------------------------------------------------------------------------- +inline FunctionLogger::FunctionLogger( const TDesC8& func, const TDesC8& file, TInt line, TInt size ) + : _peek( 0 ), _used( 0 ), _accum( 0 ) + { + TBuf8<512> buf; + + // indent + for( TInt i=0; i buf; + + // indent + for( TInt i=0; i 0 ) + for( TInt i=0; i_accum += _peek; + } +#else // OOM_LOGGING +#define MEM_LOG {} +#define MEM_LOGF {} +#endif + +#endif +// END OF FILE \ No newline at end of file