mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
merge from dev
This commit is contained in:
commit
7e96634da4
6 changed files with 81 additions and 38 deletions
|
@ -182,11 +182,12 @@ static void invalid_free();
|
|||
static void test_aslr(void);
|
||||
static void test_process_info(void);
|
||||
static void test_reserved(void);
|
||||
static void negative_stat(void);
|
||||
|
||||
|
||||
int main() {
|
||||
mi_version();
|
||||
|
||||
mi_stats_reset();
|
||||
// detect double frees and heap corruption
|
||||
// double_free1();
|
||||
// double_free2();
|
||||
|
@ -195,28 +196,29 @@ int main() {
|
|||
// test_aslr();
|
||||
// invalid_free();
|
||||
// test_reserved();
|
||||
|
||||
// negative_stat();
|
||||
|
||||
void* p1 = malloc(78);
|
||||
void* p2 = malloc(24);
|
||||
free(p1);
|
||||
p1 = mi_malloc(8);
|
||||
//char* s = strdup("hello\n");
|
||||
char* s = strdup("hello\n");
|
||||
free(p2);
|
||||
|
||||
p2 = malloc(16);
|
||||
p1 = realloc(p1, 32);
|
||||
free(p1);
|
||||
free(p2);
|
||||
//free(s);
|
||||
//mi_collect(true);
|
||||
|
||||
free(s);
|
||||
|
||||
/* now test if override worked by allocating/freeing across the api's*/
|
||||
//p1 = mi_malloc(32);
|
||||
//free(p1);
|
||||
//p2 = malloc(32);
|
||||
//mi_free(p2);
|
||||
//mi_free(p2);
|
||||
mi_collect(true);
|
||||
mi_stats_print(NULL);
|
||||
test_process_info();
|
||||
// test_process_info();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -336,3 +338,13 @@ static void test_reserved(void) {
|
|||
p3 = malloc(1*GiB);
|
||||
free(p4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void negative_stat(void) {
|
||||
int* p = mi_malloc(60000);
|
||||
mi_stats_print_out(NULL, NULL);
|
||||
*p = 100;
|
||||
mi_free(p);
|
||||
mi_stats_print_out(NULL, NULL);
|
||||
}
|
|
@ -123,7 +123,7 @@ static void free_items(void* p) {
|
|||
|
||||
static void stress(intptr_t tid) {
|
||||
//bench_start_thread();
|
||||
uintptr_t r = (tid * 43); // rand();
|
||||
uintptr_t r = ((tid + 1) * 43); // rand();
|
||||
const size_t max_item_shift = 5; // 128
|
||||
const size_t max_item_retained_shift = max_item_shift + 2;
|
||||
size_t allocs = 100 * ((size_t)SCALE) * (tid % 8 + 1); // some threads do more
|
||||
|
@ -243,14 +243,18 @@ int main(int argc, char** argv) {
|
|||
|
||||
// Run ITER full iterations where half the objects in the transfer buffer survive to the next round.
|
||||
srand(0x7feb352d);
|
||||
// mi_stats_reset();
|
||||
#ifndef NDEBUG
|
||||
mi_stats_reset();
|
||||
#endif
|
||||
#ifdef STRESS
|
||||
test_stress();
|
||||
#else
|
||||
test_leak();
|
||||
#endif
|
||||
|
||||
// mi_collect(true);
|
||||
#ifndef NDEBUG
|
||||
mi_collect(true);
|
||||
#endif
|
||||
mi_stats_print(NULL);
|
||||
//bench_end_program();
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue