# HG changeset patch # User Merten Sach # Date 1310409354 -7200 # Node ID a214c84dff4e609af1128c32f04f59fae61875e0 # Parent 2bdcba4acca081263fe503ebb407b56174d73094 malloc_touch diff -r 2bdcba4acca0 -r a214c84dff4e vmalloc.c --- a/vmalloc.c Mon Jul 11 20:29:26 2011 +0200 +++ b/vmalloc.c Mon Jul 11 20:35:54 2011 +0200 @@ -451,13 +451,13 @@ firstChunk = malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); if( firstChunk == NULL ) {printf("malloc error\n"); exit(1);} - //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; - //} + 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; + } freeListHead->prevChunkInFreeList = NULL; //Use this addr to free the heap when cleanup