ecore: add infrastructure to get info from malloc_info to.
This commit is contained in:
parent
56983ed0d4
commit
0082c1b4eb
|
@ -1893,7 +1893,7 @@ AC_MSG_RESULT([${have_isfinite}])
|
||||||
|
|
||||||
# mallinfo, timerfd_create, clock_gettime
|
# mallinfo, timerfd_create, clock_gettime
|
||||||
|
|
||||||
AC_CHECK_FUNCS_ONCE([mallinfo timerfd_create clock_gettime])
|
AC_CHECK_FUNCS_ONCE([mallinfo timerfd_create clock_gettime malloc_info])
|
||||||
|
|
||||||
if ! test "x${ac_cv_func_clock_gettime}" = "xyes" ; then
|
if ! test "x${ac_cv_func_clock_gettime}" = "xyes" ; then
|
||||||
AC_CHECK_LIB([rt], [clock_gettime],
|
AC_CHECK_LIB([rt], [clock_gettime],
|
||||||
|
|
|
@ -31,14 +31,14 @@
|
||||||
#include "Ecore.h"
|
#include "Ecore.h"
|
||||||
#include "ecore_private.h"
|
#include "ecore_private.h"
|
||||||
|
|
||||||
#if defined HAVE_MALLINFO
|
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Ecore_Version _version = { VMAJ, VMIN, VMIC, VREV };
|
static Ecore_Version _version = { VMAJ, VMIN, VMIC, VREV };
|
||||||
EAPI Ecore_Version *ecore_version = &_version;
|
EAPI Ecore_Version *ecore_version = &_version;
|
||||||
|
|
||||||
#ifdef HAVE_MALLINFO
|
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
|
||||||
#define KEEP_MAX(Global, Local) \
|
#define KEEP_MAX(Global, Local) \
|
||||||
if (Global < (Local)) \
|
if (Global < (Local)) \
|
||||||
Global = Local;
|
Global = Local;
|
||||||
|
@ -47,6 +47,9 @@ static Eina_Bool _ecore_memory_statistic(void *data);
|
||||||
static int _ecore_memory_max_total = 0;
|
static int _ecore_memory_max_total = 0;
|
||||||
static int _ecore_memory_max_free = 0;
|
static int _ecore_memory_max_free = 0;
|
||||||
static pid_t _ecore_memory_pid = 0;
|
static pid_t _ecore_memory_pid = 0;
|
||||||
|
#ifdef HAVE_MALLOC_INFO
|
||||||
|
static FILE *_ecore_memory_statistic_file = NULL;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Eo *_ecore_parent = NULL;
|
Eo *_ecore_parent = NULL;
|
||||||
|
@ -287,9 +290,15 @@ ecore_init(void)
|
||||||
#endif
|
#endif
|
||||||
_ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL);
|
_ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL);
|
||||||
|
|
||||||
#if HAVE_MALLINFO
|
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
|
||||||
if (getenv("ECORE_MEM_STAT"))
|
if (getenv("ECORE_MEM_STAT"))
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MALLOC_INFO
|
||||||
|
char tmp[1024];
|
||||||
|
|
||||||
|
snprintf(tmp, sizeof(tmp), "ecore_mem_stat.%i", getpid());
|
||||||
|
_ecore_memory_statistic_file = fopen(tmp, "w");
|
||||||
|
#endif
|
||||||
_ecore_memory_pid = getpid();
|
_ecore_memory_pid = getpid();
|
||||||
ecore_animator_add(_ecore_memory_statistic, NULL);
|
ecore_animator_add(_ecore_memory_statistic, NULL);
|
||||||
_ecore_memory_statistic(NULL);
|
_ecore_memory_statistic(NULL);
|
||||||
|
@ -421,7 +430,7 @@ ecore_shutdown(void)
|
||||||
_ecore_signal_shutdown();
|
_ecore_signal_shutdown();
|
||||||
_ecore_main_loop_shutdown();
|
_ecore_main_loop_shutdown();
|
||||||
|
|
||||||
#if HAVE_MALLINFO
|
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
|
||||||
if (getenv("ECORE_MEM_STAT"))
|
if (getenv("ECORE_MEM_STAT"))
|
||||||
{
|
{
|
||||||
_ecore_memory_statistic(NULL);
|
_ecore_memory_statistic(NULL);
|
||||||
|
@ -430,6 +439,12 @@ ecore_shutdown(void)
|
||||||
_ecore_memory_pid,
|
_ecore_memory_pid,
|
||||||
_ecore_memory_max_total,
|
_ecore_memory_max_total,
|
||||||
_ecore_memory_max_free);
|
_ecore_memory_max_free);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_MALLOC_INFO
|
||||||
|
fclose(_ecore_memory_statistic_file);
|
||||||
|
_ecore_memory_statistic_file = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ecore_mempool_shutdown();
|
ecore_mempool_shutdown();
|
||||||
|
@ -895,10 +910,14 @@ _systemd_watchdog_cb(EINA_UNUSED void *data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_MALLINFO
|
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO)
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_memory_statistic(EINA_UNUSED void *data)
|
_ecore_memory_statistic(EINA_UNUSED void *data)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MALLOC_INFO
|
||||||
|
static int frame = 0;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MALLINFO
|
||||||
struct mallinfo mi;
|
struct mallinfo mi;
|
||||||
static int uordblks = 0;
|
static int uordblks = 0;
|
||||||
static int fordblks = 0;
|
static int fordblks = 0;
|
||||||
|
@ -924,6 +943,12 @@ _ecore_memory_statistic(EINA_UNUSED void *data)
|
||||||
|
|
||||||
KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
|
KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
|
||||||
KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
|
KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MALLOC_INFO
|
||||||
|
if (frame) fputs("\n", _ecore_memory_statistic_file);
|
||||||
|
fprintf(_ecore_memory_statistic_file, "=== Frame %i ===\n\n", frame++);
|
||||||
|
malloc_info(0, _ecore_memory_statistic_file);
|
||||||
|
#endif
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue