summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-08-27 16:52:00 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-08-27 16:52:00 +0900
commit0082c1b4eb0a25f01250b1cd54e855298aea4aae (patch)
treed10434d7b7d0b5922be196fbb49bbfd1f407deb6 /src/lib/ecore
parent56983ed0d4facc26a99f51e30f3ce294f3f908f5 (diff)
ecore: add infrastructure to get info from malloc_info to.
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/ecore.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 0979e1a1cf..d0e98ad895 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -31,14 +31,14 @@
31#include "Ecore.h" 31#include "Ecore.h"
32#include "ecore_private.h" 32#include "ecore_private.h"
33 33
34#if defined HAVE_MALLINFO 34#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
35#include <malloc.h> 35#include <malloc.h>
36#endif 36#endif
37 37
38static Ecore_Version _version = { VMAJ, VMIN, VMIC, VREV }; 38static Ecore_Version _version = { VMAJ, VMIN, VMIC, VREV };
39EAPI Ecore_Version *ecore_version = &_version; 39EAPI Ecore_Version *ecore_version = &_version;
40 40
41#ifdef HAVE_MALLINFO 41#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
42#define KEEP_MAX(Global, Local) \ 42#define KEEP_MAX(Global, Local) \
43 if (Global < (Local)) \ 43 if (Global < (Local)) \
44 Global = Local; 44 Global = Local;
@@ -47,6 +47,9 @@ static Eina_Bool _ecore_memory_statistic(void *data);
47static int _ecore_memory_max_total = 0; 47static int _ecore_memory_max_total = 0;
48static int _ecore_memory_max_free = 0; 48static int _ecore_memory_max_free = 0;
49static pid_t _ecore_memory_pid = 0; 49static pid_t _ecore_memory_pid = 0;
50#ifdef HAVE_MALLOC_INFO
51static FILE *_ecore_memory_statistic_file = NULL;
52#endif
50#endif 53#endif
51 54
52Eo *_ecore_parent = NULL; 55Eo *_ecore_parent = NULL;
@@ -287,9 +290,15 @@ ecore_init(void)
287#endif 290#endif
288 _ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL); 291 _ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL);
289 292
290#if HAVE_MALLINFO 293#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
291 if (getenv("ECORE_MEM_STAT")) 294 if (getenv("ECORE_MEM_STAT"))
292 { 295 {
296#ifdef HAVE_MALLOC_INFO
297 char tmp[1024];
298
299 snprintf(tmp, sizeof(tmp), "ecore_mem_stat.%i", getpid());
300 _ecore_memory_statistic_file = fopen(tmp, "w");
301#endif
293 _ecore_memory_pid = getpid(); 302 _ecore_memory_pid = getpid();
294 ecore_animator_add(_ecore_memory_statistic, NULL); 303 ecore_animator_add(_ecore_memory_statistic, NULL);
295 _ecore_memory_statistic(NULL); 304 _ecore_memory_statistic(NULL);
@@ -421,7 +430,7 @@ ecore_shutdown(void)
421 _ecore_signal_shutdown(); 430 _ecore_signal_shutdown();
422 _ecore_main_loop_shutdown(); 431 _ecore_main_loop_shutdown();
423 432
424#if HAVE_MALLINFO 433#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
425 if (getenv("ECORE_MEM_STAT")) 434 if (getenv("ECORE_MEM_STAT"))
426 { 435 {
427 _ecore_memory_statistic(NULL); 436 _ecore_memory_statistic(NULL);
@@ -430,6 +439,12 @@ ecore_shutdown(void)
430 _ecore_memory_pid, 439 _ecore_memory_pid,
431 _ecore_memory_max_total, 440 _ecore_memory_max_total,
432 _ecore_memory_max_free); 441 _ecore_memory_max_free);
442
443
444#ifdef HAVE_MALLOC_INFO
445 fclose(_ecore_memory_statistic_file);
446 _ecore_memory_statistic_file = NULL;
447#endif
433 } 448 }
434#endif 449#endif
435 ecore_mempool_shutdown(); 450 ecore_mempool_shutdown();
@@ -895,10 +910,14 @@ _systemd_watchdog_cb(EINA_UNUSED void *data)
895} 910}
896#endif 911#endif
897 912
898#if HAVE_MALLINFO 913#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
899static Eina_Bool 914static Eina_Bool
900_ecore_memory_statistic(EINA_UNUSED void *data) 915_ecore_memory_statistic(EINA_UNUSED void *data)
901{ 916{
917#ifdef HAVE_MALLOC_INFO
918 static int frame = 0;
919#endif
920#ifdef HAVE_MALLINFO
902 struct mallinfo mi; 921 struct mallinfo mi;
903 static int uordblks = 0; 922 static int uordblks = 0;
904 static int fordblks = 0; 923 static int fordblks = 0;
@@ -924,6 +943,12 @@ _ecore_memory_statistic(EINA_UNUSED void *data)
924 943
925 KEEP_MAX(_ecore_memory_max_total, mi.uordblks); 944 KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
926 KEEP_MAX(_ecore_memory_max_free, mi.fordblks); 945 KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
946#endif
947#ifdef HAVE_MALLOC_INFO
948 if (frame) fputs("\n", _ecore_memory_statistic_file);
949 fprintf(_ecore_memory_statistic_file, "=== Frame %i ===\n\n", frame++);
950 malloc_info(0, _ecore_memory_statistic_file);
951#endif
927 952
928 return ECORE_CALLBACK_RENEW; 953 return ECORE_CALLBACK_RENEW;
929} 954}