void replace_jemalloc_stats(jemalloc_stats_t* aStats) { AutoLock lock(sLock); sFuncs->jemalloc_stats(aStats); FdPrintf(sFd, "%zu %zu jemalloc_stats()\n", GetPid(), GetTid()); }
void replace_free(void* aPtr) { AutoLock lock(sLock); if (aPtr) { FdPrintf(sFd, "%zu %zu free(%p)\n", GetPid(), GetTid(), aPtr); } sFuncs->free(aPtr); }
void* replace_valloc(size_t aSize) { AutoLock lock(sLock); void* ptr = sFuncs->valloc(aSize); if (ptr) { FdPrintf(sFd, "%zu %zu valloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr); } return ptr; }
void* replace_memalign(size_t aAlignment, size_t aSize) { AutoLock lock(sLock); void* ptr = sFuncs->memalign(aAlignment, aSize); if (ptr) { FdPrintf(sFd, "%zu %zu memalign(%zu,%zu)=%p\n", GetPid(), GetTid(), aAlignment, aSize, ptr); } return ptr; }
void* replace_realloc(void* aPtr, size_t aSize) { AutoLock lock(sLock); void* new_ptr = sFuncs->realloc(aPtr, aSize); if (new_ptr || !aSize) { FdPrintf(sFd, "%zu %zu realloc(%p,%zu)=%p\n", GetPid(), GetTid(), aPtr, aSize, new_ptr); } return new_ptr; }
int replace_posix_memalign(void** aPtr, size_t aAlignment, size_t aSize) { AutoLock lock(sLock); int ret = sFuncs->posix_memalign(aPtr, aAlignment, aSize); if (ret == 0) { FdPrintf(sFd, "%zu %zu posix_memalign(%zu,%zu)=%p\n", GetPid(), GetTid(), aAlignment, aSize, *aPtr); } return ret; }
void jemalloc_stats(Buffer& aArgs) { if (aArgs) { die("Malformed input"); } jemalloc_stats_t stats; ::jemalloc_stats_impl(&stats); FdPrintf(2, "#%zu mapped: %zu; allocated: %zu; waste: %zu; dirty: %zu; " "bookkeep: %zu; binunused: %zu\n", mOps, stats.mapped, stats.allocated, stats.waste, stats.page_cache, stats.bookkeeping, stats.bin_unused); /* TODO: Add more data, like actual RSS as measured by OS, but compensated * for the replay internal data. */ }