[Sofaswitch-svn] [commit] r412 - in sofaswitch/trunk/sofa: include/sofa src
Author: derek Date: Tue May 20 17:59:05 2008 New Revision: 412 Modified: sofaswitch/trunk/sofa/include/sofa/messages.h sofaswitch/trunk/sofa/src/messages.cxx Log: Tidy up the dumping of memory while a sofa utility is running.. Modified: sofaswitch/trunk/sofa/include/sofa/messages.h ============================================================================== --- sofaswitch/trunk/sofa/include/sofa/messages.h (original) +++ sofaswitch/trunk/sofa/include/sofa/messages.h Tue May 20 17:59:05 2008 @@ -373,6 +373,12 @@ /**Flag to indicate it is time to end this thread. It is only set by the MessageFrame::Terminate() method */ bool keepGoing; + +#ifdef PMEMORY_CHECK + /**The state of the memory at which we last did a dump. This variable is updated + each time we do a memory dump */ + static PMemoryHeap::State memoryState; +#endif }; //////////////////////////////////////////////////////////////////////////////// Modified: sofaswitch/trunk/sofa/src/messages.cxx ============================================================================== --- sofaswitch/trunk/sofa/src/messages.cxx (original) +++ sofaswitch/trunk/sofa/src/messages.cxx Tue May 20 17:59:05 2008 @@ -809,9 +809,12 @@ void MessageFrame::ProcessSetWriteFile(PStringArray &cmds, const PString & sender) { if (cmds.GetSize() != 2) { - PTRACE(3, cmds[0] << " Failed - Read file not correctly specified" - << sender); - return; + PStringStream error; + error << cmds[0] + << " Failed - Read file not correctly specified"; + PTRACE(3, error << sender); + SendThisMessageTo(error, sender); + return; } PTRACE(3, "Set the write file to be \"" << cmds[1] << "\""); SetWriteFile(cmds[1]); @@ -822,9 +825,11 @@ void MessageFrame::ProcessMemoryDump(PStringArray &cmds, PString & sender) { if (cmds.GetSize() != 2) { - PTRACE(3, cmds[0] << " Failed - Output file not specified" - << sender); - return; + PStringStream error; + error << cmds[0] << " Failed - Output file not specified"; + PTRACE(3, error << sender); + SendThisMessageTo(error, sender); + return; } PTRACE(3, "Dump current memory usage to \"" << cmds[1] << "\""); @@ -832,20 +837,29 @@ PTextFile outputFile; if (!outputFile.Open(cmds[1], PFile::WriteOnly, PFile::Create + PFile::Truncate)) { - PTRACE(3, "Failed to open the specified file " << cmds[1] << " to dump memory to"); - return; + PStringStream error; + error << "Failed to open the specified file " + << cmds[1] + << " to dump memory to"; + SendThisMessageTo(error, sender); + PTRACE(3, error); + return; } - - cerr << "Dump statistics to the file " << cmds[1] << endl; + PStringStream status; + status << "Dump memory usage info to the file " << cmds[1]; + cerr << status << endl; + SendThisMessageTo(status, sender); PMemoryHeap::DumpStatistics(); PStringStream result; - PMemoryHeap::State state; - PMemoryHeap::DumpObjectsSince(state, result); + PMemoryHeap::DumpObjectsSince(memoryState, result); outputFile.WriteLine(result); outputFile.Close(); + PMemoryHeap::GetState(memoryState); return; } + +PMemoryHeap::State MessageFrame::memoryState; #endif bool MessageFrame::SendDtmf(const PString & dtmfVals)
participants (1)
-
SofaSWITCH SVN