From 0e6ae3da5c18fb7a9bbefe940d19bb4199f7c1a0 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 10 Feb 2008 19:00:14 +0000 Subject: [PATCH] Added memory-information when MEMLEAK is activated. --- src/commands/cmd_refresh.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/commands/cmd_refresh.c b/src/commands/cmd_refresh.c index 3d2ab5b7d..fba40baac 100644 --- a/src/commands/cmd_refresh.c +++ b/src/commands/cmd_refresh.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2007 David A. Capello + * Copyright (C) 2001-2008 David A. Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,12 @@ #ifndef USE_PRECOMPILED_HEADER +#include #include +#if defined ALLEGRO_WINDOWS && defined MEMLEAK +#include +#include +#endif #include "jinete/jsystem.h" @@ -36,6 +41,19 @@ static void cmd_refresh_execute(const char *argument) jmouse_show(); app_refresh_screen(); + + /* print memory information */ +#if defined ALLEGRO_WINDOWS && defined MEMLEAK + { + PROCESS_MEMORY_COUNTERS pmc; + if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) { + printf("----\n"); + printf("current memory: %.16g KB (%lu)\n", pmc.WorkingSetSize / 1024.0, pmc.WorkingSetSize); + printf("peak of memory: %.16g KB (%lu)\n", pmc.PeakWorkingSetSize / 1024.0, pmc.PeakWorkingSetSize); + fflush(stdout); + } + } +#endif } Command cmd_refresh = {