diff options
author | Christopher Ferris <cferris@google.com> | 2014-08-06 17:49:02 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2014-08-21 14:48:43 -0700 |
commit | e5d3dcfe0dbd2515afaa88f1b77c1eb0b88a40c0 (patch) | |
tree | 4bccd54fce5e428254831188267aabb22cae6491 /android | |
parent | 615fe54259e545c33275753a316c2bfd1198b4f0 (diff) | |
download | jemalloc-e5d3dcfe0dbd2515afaa88f1b77c1eb0b88a40c0.tar.gz |
Expose interface for jemalloc stats.
Bug: 16874689
Change-Id: Ia63b46f35a4f74fa67405851aa8356c6b1febfd5
Diffstat (limited to 'android')
-rw-r--r-- | android/src/je_mallinfo.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/android/src/je_mallinfo.c b/android/src/je_mallinfo.c index 56001af..559cbbd 100644 --- a/android/src/je_mallinfo.c +++ b/android/src/je_mallinfo.c @@ -49,3 +49,57 @@ struct mallinfo je_mallinfo() { mi.usmblks = mi.uordblks; return mi; } + +size_t __mallinfo_narenas() { + return narenas_auto; +} + +size_t __mallinfo_nbins() { + return NBINS; +} + +struct mallinfo __mallinfo_arena_info(size_t aidx) { + struct mallinfo mi; + memset(&mi, 0, sizeof(mi)); + + malloc_mutex_lock(&arenas_lock); + if (aidx < narenas_auto) { + if (arenas[aidx] != NULL) { + malloc_mutex_lock(&arenas[aidx]->lock); + mi.hblkhd = arenas[aidx]->stats.mapped; + mi.ordblks = arenas[aidx]->stats.allocated_large; + mi.uordblks = arenas[aidx]->stats.allocated_huge; + malloc_mutex_unlock(&arenas[aidx]->lock); + + for (unsigned j = 0; j < NBINS; j++) { + arena_bin_t* bin = &arenas[aidx]->bins[j]; + + malloc_mutex_lock(&bin->lock); + mi.fsmblks += bin->stats.allocated; + malloc_mutex_unlock(&bin->lock); + } + } + } + malloc_mutex_unlock(&arenas_lock); + return mi; +} + +struct mallinfo __mallinfo_bin_info(size_t aidx, size_t bidx) { + struct mallinfo mi; + memset(&mi, 0, sizeof(mi)); + + malloc_mutex_lock(&arenas_lock); + if (aidx < narenas_auto && bidx < NBINS) { + if (arenas[aidx] != NULL) { + arena_bin_t* bin = &arenas[aidx]->bins[bidx]; + + malloc_mutex_lock(&bin->lock); + mi.ordblks = bin->stats.allocated; + mi.uordblks = bin->stats.nmalloc; + mi.fordblks = bin->stats.ndalloc; + malloc_mutex_unlock(&bin->lock); + } + } + malloc_mutex_unlock(&arenas_lock); + return mi; +} |