From d2780443c64e058f0840c3ab7ea6a0a8c12e7343 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 19 Oct 2012 22:09:33 +0000 Subject: Use leakfinder in debug builds to dump all currently used memory via the "dumpmem" console command. git-svn-id: http://mc-server.googlecode.com/svn/trunk@984 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Server.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/Server.cpp') diff --git a/source/Server.cpp b/source/Server.cpp index 8b1fd3c1e..ea25392a5 100644 --- a/source/Server.cpp +++ b/source/Server.cpp @@ -38,6 +38,20 @@ extern "C" { +// For the "dumpmem" server command: +/// Synchronize this with main.cpp - the leak finder needs initialization before it can be used to dump memory +#define ENABLE_LEAK_FINDER + +#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) + #pragma warning(push) + #pragma warning(disable:4100) + #include "LeakFinder.h" + #pragma warning(pop) +#endif + + + + typedef std::list< cClientHandle* > ClientList; @@ -528,6 +542,15 @@ void cServer::ServerCommand(const AString & a_Cmd) return; } + #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) + if (split[0].compare("dumpmem") == 0) + { + LeakFinderXmlOutput Output("memdump.xml"); + DumpUsedMemory(&Output); + return; + } + #endif + if (split.size() > 1) { if (split[0].compare("say") == 0) -- cgit v1.2.3