Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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;
- size_t env_cache_sz;
- char *env_cache_sz_str;
- int st;
- env_cache_sz_str = getenv("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES");
- if (env_cache_sz_str) {
- env_cache_sz = strtoul(env_cache_sz_str, NULL, 0);
- if (env_cache_sz == 33554432) {
- cout << "TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES Value same as default:"
- " 33554432 export a different value for test" << endl;
- exit(EXIT_FAILURE);
- }
- tc_cache_sz = 0;
- MallocExtension::instance()->
- GetNumericProperty("tcmalloc.max_total_thread_cache_bytes",
- &tc_cache_sz);
- if (tc_cache_sz == env_cache_sz) {
- cout << "Tcmalloc OK! Internal and Env cache size are same:" <<
- tc_cache_sz << endl;
- st = EXIT_SUCCESS;
- } else {
- cout << "Tcmalloc BUG! TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES: "
- << env_cache_sz << " Internal Size: " << tc_cache_sz
- << " different" << endl;
- st = EXIT_FAILURE;
- }
- } else {
- cout << "TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES Env Not Set" << endl;
- st = EXIT_FAILURE;
- }
- exit(st);
- }
- /* EOF */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement