mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 07:29:30 +03:00
add test for issue #944
This commit is contained in:
parent
638ea539de
commit
50d3525a8c
1 changed files with 31 additions and 1 deletions
|
@ -37,6 +37,7 @@ static void tsan_numa_test(); // issue #414
|
|||
static void strdup_test(); // issue #445
|
||||
static void heap_thread_free_huge();
|
||||
static void test_std_string(); // issue #697
|
||||
static void test_thread_local(); // issue #944
|
||||
|
||||
static void test_stl_allocators();
|
||||
|
||||
|
@ -44,7 +45,8 @@ static void test_stl_allocators();
|
|||
int main() {
|
||||
// mi_stats_reset(); // ignore earlier allocations
|
||||
|
||||
test_std_string();
|
||||
//test_std_string();
|
||||
test_thread_local();
|
||||
// heap_thread_free_huge();
|
||||
/*
|
||||
heap_thread_free_large();
|
||||
|
@ -312,3 +314,31 @@ static void tsan_numa_test() {
|
|||
dummy_worker();
|
||||
t1.join();
|
||||
}
|
||||
|
||||
|
||||
class MTest
|
||||
{
|
||||
char *data;
|
||||
public:
|
||||
MTest() { data = (char*)malloc(1024); }
|
||||
~MTest() { free(data); };
|
||||
};
|
||||
|
||||
thread_local MTest tlVariable;
|
||||
|
||||
void threadFun( int i )
|
||||
{
|
||||
printf( "Thread %d\n", i );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds(100) );
|
||||
}
|
||||
|
||||
void test_thread_local()
|
||||
{
|
||||
for( int i=1; i < 100; ++i )
|
||||
{
|
||||
std::thread t( threadFun, i );
|
||||
t.join();
|
||||
mi_stats_print(NULL);
|
||||
}
|
||||
return;
|
||||
}
|
Loading…
Add table
Reference in a new issue