Skip to content

Instantly share code, notes, and snippets.

@mmgaggle

mmgaggle/output Secret

Created January 20, 2016 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmgaggle/a5818d4e8528d3681534 to your computer and use it in GitHub Desktop.
Save mmgaggle/a5818d4e8528d3681534 to your computer and use it in GitHub Desktop.
Tcmalloc Testing
kyle@synapse ~/src/malloc_test $ > ./runtime_malloc
Tcmalloc default thread cache size:33554432
Tcmalloc runtime thread cache size:134217728
#include <iostream>
#include <cstdlib>
#ifdef HAVE_GPERFTOOLS_HEAP_PROFILER_H
#include <gperftools/heap-profiler.h>
#else
#include <google/heap-profiler.h>
#endif
#ifdef HAVE_GPERFTOOLS_MALLOC_EXTENSION_H
#include <gperftools/malloc_extension.h>
#else
#include <google/malloc_extension.h>
#endif
using namespace std;
int main ()
{
size_t tc_cache_sz;
tc_cache_sz = 0;
MallocExtension::instance()->
GetNumericProperty("tcmalloc.max_total_thread_cache_bytes",
&tc_cache_sz);
cout << "Tcmalloc default thread cache size:" << tc_cache_sz << endl;
tc_cache_sz = 134217728;
MallocExtension::instance()->
SetNumericProperty("tcmalloc.max_total_thread_cache_bytes",
tc_cache_sz);
MallocExtension::instance()->
GetNumericProperty("tcmalloc.max_total_thread_cache_bytes",
&tc_cache_sz);
cout << "Tcmalloc runtime thread cache size:" << tc_cache_sz << endl;
}
/* EOF */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment