# HG changeset patch # User Merten Sach # Date 1315398802 -7200 # Node ID d0aa5a796fc515422832122d3f172b8648a0f332 # Parent 9b2b9bc2c362bf0019f3ba6a4842b6f38505e7cf touch memory at start of algorithm to make it comparable diff -r 9b2b9bc2c362 -r d0aa5a796fc5 vmalloc.c --- a/vmalloc.c Wed Sep 07 14:28:20 2011 +0200 +++ b/vmalloc.c Wed Sep 07 14:33:22 2011 +0200 @@ -342,6 +342,14 @@ if( firstChunk == NULL ) {printf("Can't allocate initial memory\n"); exit(1);} freeLists->memSpace = firstChunk; + //Touch memory to avoid page faults + void *ptr,*endPtr; + endPtr = (void*)firstChunk+MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE; + for(ptr = firstChunk; ptr < endPtr; ptr+=PAGE_SIZE) + { + *(char*)ptr = 0; + } + firstChunk->nextLowerInMem = NULL; firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk + MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog*));