Make test_threads more generic

This commit is contained in:
rustyx 2016-02-27 18:29:31 +01:00 committed by Jason Evans
parent e025c5158b
commit e270a8f936

View File

@ -10,23 +10,12 @@
#include <vector>
#include <stdio.h>
#include <jemalloc/jemalloc.h>
#include <windows.h>
using std::vector;
using std::thread;
using std::uniform_int_distribution;
using std::minstd_rand;
#if NDEBUG && JEMALLOC_ISSUE_318_WORKAROUND
extern "C" JEMALLOC_EXPORT void _malloc_thread_cleanup(void);
static thread_local struct JeMallocThreadHelper {
~JeMallocThreadHelper() {
_malloc_thread_cleanup();
}
} tls_jemallocThreadHelper;
#endif
int test_threads()
{
je_malloc_conf = "narenas:3";
@ -91,7 +80,7 @@ int test_threads()
size_t allocated2;
je_mallctl("stats.active", &allocated2, &sz1, NULL, 0);
size_t leaked = allocated2 - allocated1;
printf("\nDone. Leaked: %Id bytes\n", leaked);
printf("\nDone. Leaked: %zd bytes\n", leaked);
bool failed = leaked > 65536; // in case C++ runtime allocated something (e.g. iostream locale or facet)
printf("\nTest %s!\n", (failed ? "FAILED" : "successful"));
printf("\nPress Enter to continue...\n");