mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-07 03:48:42 +03:00
always use MI_HUGE_BLOCK_SIZE for pages in huge segments
This commit is contained in:
parent
4c6814bc68
commit
09f171b4f5
7 changed files with 72 additions and 25 deletions
|
@ -19,13 +19,15 @@ static void negative_stat(void);
|
|||
static void alloc_huge(void);
|
||||
static void test_heap_walk(void);
|
||||
static void test_remap(bool start_remappable);
|
||||
static void test_remap2(void);
|
||||
|
||||
int main() {
|
||||
mi_version();
|
||||
mi_stats_reset();
|
||||
|
||||
test_remap(true);
|
||||
|
||||
test_remap2();
|
||||
//test_remap(true);
|
||||
|
||||
// detect double frees and heap corruption
|
||||
// double_free1();
|
||||
// double_free2();
|
||||
|
@ -219,6 +221,14 @@ static void test_heap_walk(void) {
|
|||
mi_heap_visit_blocks(heap, true, &test_visit, NULL);
|
||||
}
|
||||
|
||||
static void test_remap2(void) {
|
||||
int* p = (int*)mi_malloc(356);
|
||||
p = (int*)mi_realloc(p, 583);
|
||||
memset(p, '\0', 580);
|
||||
p = (int*)mi_realloc(p, 1500705);
|
||||
p = (int*)mi_realloc(p, 3000711);
|
||||
mi_free(p);
|
||||
}
|
||||
|
||||
static void test_remap(bool start_remappable) {
|
||||
const size_t iterN = 100;
|
||||
|
|
|
@ -27,6 +27,7 @@ we therefore test the API over various inputs. Please add more tests :-)
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <vector>
|
||||
|
@ -59,6 +60,7 @@ bool mem_is_zero(uint8_t* p, size_t size) {
|
|||
// ---------------------------------------------------------------------------
|
||||
int main(void) {
|
||||
mi_option_disable(mi_option_verbose);
|
||||
mi_option_set(mi_option_remap_threshold, 100 /* in kib */);
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Malloc
|
||||
|
@ -284,6 +286,15 @@ int main(void) {
|
|||
mi_free(p);
|
||||
};
|
||||
|
||||
CHECK_BODY("reallo-huge") { // By Jason Gibson
|
||||
int* p = (int*)mi_malloc(356);
|
||||
p = (int*)mi_realloc(p, 583);
|
||||
memset(p, '\0', 580);
|
||||
p = (int*)mi_realloc(p, 1500705);
|
||||
p = (int*)mi_realloc(p, 3000711);
|
||||
mi_free(p);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Heaps
|
||||
// ---------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue