From 656795fac094add3dd49a42ccb6a9bcc078c4166 Mon Sep 17 00:00:00 2001 From: Simon Budig Date: Thu, 29 Apr 2004 19:47:24 +0000 Subject: [PATCH] when glibc is used, call mallopt, so that memory chunks >= 4k (= 64*64 2004-04-29 Simon Budig * app/main.c: when glibc is used, call mallopt, so that memory chunks >= 4k (= 64*64 pixels, 1bpp - the smallest full tile) get allocated via mmap. This ensures that after closing an image the memory allocated for image data gets returned to the system. Thanks to Phil Blundell for bringing mallopt to my attention. Please watch closely for performance problems. --- ChangeLog | 12 ++++++++++++ app/main.c | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 47756ebfe1..5e56047f54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-04-29 Simon Budig + + * app/main.c: when glibc is used, call mallopt, so that memory + chunks >= 4k (= 64*64 pixels, 1bpp - the smallest full tile) + get allocated via mmap. This ensures that after closing an image + the memory allocated for image data gets returned to the system. + + Thanks to Phil Blundell for bringing mallopt + to my attention. + + Please watch closely for performance problems. + 2004-04-29 Michael Natterer * app/actions/Makefile.am diff --git a/app/main.c b/app/main.c index 78c66c8a40..0360c62eae 100644 --- a/app/main.c +++ b/app/main.c @@ -32,6 +32,10 @@ #include #endif +#ifdef __GLIBC__ +#include +#endif + #ifndef WAIT_ANY #define WAIT_ANY -1 #endif @@ -240,6 +244,13 @@ main (int argc, use_shm = TRUE; #endif +#ifdef __GLIBC__ + /* Tweak memory allocation so that memory allocated in chunks >= 4k + * (64x64 pixel 1bpp tile) gets returned to the system when free'd (). + */ + mallopt (M_MMAP_THRESHOLD, 64 * 64 - 1); +#endif + batch_cmds = g_new (gchar *, argc); batch_cmds[0] = NULL;