From d2ff520ae44eaa9c21bb5c5069ff393b0b99eb60 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 29 May 2014 18:21:08 +0300 Subject: [PATCH] Add diagnostics for using private heap on MS-Windows during dumping. src/w32heap.c (report_temacs_memory_usage): New function. src/unexw32.c (unexec) [ENABLE_CHECKING]: Call report_temacs_memory_usage. src/w32heap.h (report_temacs_memory_usage): Add prototype. --- src/ChangeLog | 9 +++++++++ src/unexw32.c | 4 ++++ src/w32heap.c | 13 +++++++++++++ src/w32heap.h | 1 + 4 files changed, 27 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 5189712d490..463f5750652 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2014-05-29 Eli Zaretskii + + * w32heap.c (report_temacs_memory_usage): New function. + + * unexw32.c (unexec) [ENABLE_CHECKING]: Call + report_temacs_memory_usage. + + * w32heap.h (report_temacs_memory_usage): Add prototype. + 2014-05-29 Paul Eggert Don't substitute sigprocmask for pthread_sigmask (Bug#17561). diff --git a/src/unexw32.c b/src/unexw32.c index 60b926b2499..7cbd95a46fe 100644 --- a/src/unexw32.c +++ b/src/unexw32.c @@ -728,6 +728,10 @@ unexec (const char *new_name, const char *old_name) abort (); strcpy (p, q); +#ifdef ENABLE_CHECKING + report_temacs_memory_usage (); +#endif + /* Make sure that the output filename has the ".exe" extension...patch it up if not. */ p = out_filename + strlen (out_filename) - 4; diff --git a/src/w32heap.c b/src/w32heap.c index 7cce7c50319..be097901747 100644 --- a/src/w32heap.c +++ b/src/w32heap.c @@ -448,6 +448,19 @@ free_before_dump (void *ptr) } } +#ifdef ENABLE_CHECKING +void +report_temacs_memory_usage (void) +{ + /* Emulate 'message', which writes to stderr in non-interactive + sessions. */ + fprintf (stderr, + "Dump memory usage: Heap: %" PRIu64 " Large blocks(%lu): %" PRIu64 "\n", + (unsigned long long)committed, blocks_number, + (unsigned long long)(dumped_data + DUMPED_HEAP_SIZE - bc_limit)); +} +#endif + /* Emulate getpagesize. */ int getpagesize (void) diff --git a/src/w32heap.h b/src/w32heap.h index 84a26f958d0..18b6c85c2de 100644 --- a/src/w32heap.h +++ b/src/w32heap.h @@ -41,6 +41,7 @@ extern void *mmap_realloc (void **, size_t); extern void mmap_free (void **); extern void *mmap_alloc (void **, size_t); +extern void report_temacs_memory_usage (void); /* Emulation of Unix sbrk(). */ extern void *sbrk (ptrdiff_t size); -- 2.39.2