Gnash
0.8.10
|
00001 #ifndef GNASH_JEMALLOC_H 00002 #define GNASH_JEMALLOC_H 00003 00004 #ifdef HAVE_CONFIG_H 00005 # include "gnashconfig.h" 00006 #endif 00007 00008 /* Compiling for user mode application, not operating system */ 00009 #define MOZ_MEMORY 00010 00011 #ifdef LINUX_HOST 00012 #define MOZ_MEMORY_LINUX 00013 #endif 00014 00015 #ifdef WIN32_HOST 00016 #define MOZ_MEMORY_WINDOWS 00017 #endif 00018 00019 /* OpenBSD and others are excluded here to mimic what Mozilla does. */ 00020 #if defined(FREEBSD_HOST) || defined(NETBSD_HOST) 00021 #define MOZ_MEMORY_BSD 00022 #endif 00023 00024 #ifdef DARWIN_HOST 00025 #define MOZ_MEMORY_DARWIN 00026 #endif 00027 00028 #ifdef SOLARIS_HOST 00029 #define MOZ_MEMORY_SOLARIS 00030 #endif 00031 00032 #ifdef WINCE_HOST 00033 #define MOZ_MEMORY_WINCE 00034 #endif 00035 00036 #ifdef WINCE6_HOST 00037 #define MOZ_MEMORY_WINCE6 00038 #endif 00039 00040 #ifdef ANDROID_HOST 00041 #define MOZ_MEMORY_ANDROID 00042 #endif 00043 00044 #if SIZEOF_VOID_P == 4 00045 # define MOZ_MEMORY_SIZEOF_PTR_2POW 2 00046 #elif SIZEOF_VOID_P == 8 00047 # define MOZ_MEMORY_SIZEOF_PTR_2POW 3 00048 #endif 00049 00050 #if 0 00051 /* Unfortunately, even though jemalloc has valgrind hooks, it still produces 00052 * false positives. See https://bugzilla.mozilla.org/show_bug.cgi?id=503249 00053 */ 00054 #define MOZ_VALGRIND 00055 #endif 00056 00057 #include "jemalloc.h" 00058 00059 #ifdef USE_STATS_MEMORY 00060 00061 /* Enable statistics tracking plus API in jemalloc. */ 00062 #define MALLOC_STATS 00063 00064 /* Borrowed from malloc.h, as this is Linux specific. This has been 00065 * added to jemalloc so the existing memory profiling in Gnash will 00066 * continue to work. Most of these fields aren't used by the Gnash 00067 * memory profiling, but we leave them here for a semblance of 00068 * portability. The only fields Gnash uses are arena, uordblks. and 00069 * fordblks. 00070 */ 00071 struct mallinfo { 00072 int arena; /* non-mmapped space allocated from system */ 00073 int ordblks; /* number of free chunks UNUSED */ 00074 int smblks; /* number of fastbin blocks UNUSED */ 00075 int hblks; /* number of mmapped regions UNUSED */ 00076 int hblkhd; /* space in mmapped regions UNUSED */ 00077 int usmblks; /* maximum total allocated space UNUSED */ 00078 int fsmblks; /* space available in freed fastbin blocks UNUSED */ 00079 int uordblks; /* total allocated space */ 00080 int fordblks; /* total free space */ 00081 int keepcost; /* top-most, releasable space UNUSED */ 00082 }; 00083 00084 struct mallinfo 00085 mallinfo(void) 00086 { 00087 struct mallinfo mi; 00088 jemalloc_stats_t stats; 00089 00090 jemalloc_stats(&stats); 00091 00092 /* clear unused fields */ 00093 mi.keepcost = mi.ordblks = mi.smblks = mi.usmblks = mi.fsmblks = 00094 mi.hblks = mi.hblkhd = 0; 00095 00096 mi.arena = stats.mapped; 00097 mi.uordblks = stats.allocated; 00098 mi.fordblks = stats.mapped - mi.uordblks; 00099 00100 return mi; 00101 } 00102 00103 #endif /* USE_STATS_MEMORY */ 00104 00105 #endif /* GNASH_JEMALLOC_H */