Index: vm/gc_gen/src/common/gc_platform.h =================================================================== --- vm/gc_gen/src/common/gc_platform.h (revision 592488) +++ vm/gc_gen/src/common/gc_platform.h (working copy) @@ -187,7 +187,8 @@ if(result == 0) result = TRUE; else result = FALSE; #endif /* ifdef _WINDOWS_ else */ - +//assert that memory was released + assert(result); return result; } Index: vm/gc_gen/src/common/gc_common.h =================================================================== --- vm/gc_gen/src/common/gc_common.h (revision 592488) +++ vm/gc_gen/src/common/gc_common.h (working copy) @@ -402,6 +402,8 @@ struct Collection_Scheduler; typedef struct GC{ +//allocation heap base + void* alloc_heap_start; void* heap_start; void* heap_end; POINTER_SIZE_INT reserved_heap_size; Index: vm/gc_gen/src/gen/gen.h =================================================================== --- vm/gc_gen/src/gen/gen.h (revision 592488) +++ vm/gc_gen/src/gen/gen.h (working copy) @@ -57,6 +57,8 @@ typedef struct GC_Gen { /* <-- First couple of fields overloaded as GC */ + // allocation heap base + void* alloc_heap_start; void* heap_start; void* heap_end; POINTER_SIZE_INT reserved_heap_size; Index: vm/gc_gen/src/gen/gen.cpp =================================================================== --- vm/gc_gen/src/gen/gen.cpp (revision 592488) +++ vm/gc_gen/src/gen/gen.cpp (working copy) @@ -123,6 +123,8 @@ void *reserved_base; void *reserved_end; void *nos_base; + // allocation base + void* alloc_reserved_base; #ifdef STATIC_NOS_MAPPING @@ -140,14 +142,17 @@ void *los_mos_base = (void*)((POINTER_SIZE_INT)nos_base - los_mos_reserve_size); assert(!((POINTER_SIZE_INT)los_mos_base % SPACE_ALLOC_UNIT)); - reserved_base = vm_reserve_mem(los_mos_base, los_mos_reserve_size); - while( !reserved_base || reserved_base >= nos_base){ + + alloc_reserved_base = vm_reserve_mem(los_mos_base, los_mos_reserve_size); + + while( !alloc_reserved_base || alloc_reserved_base >= nos_base){ los_mos_base = (void*)((POINTER_SIZE_INT)los_mos_base - SPACE_ALLOC_UNIT); if(los_mos_base < RESERVE_BOTTOM){ DIE2("gc.base","Static NOS mapping: Can't reserve memory at address"<heap_start = reserved_base; gc_gen->heap_end = reserved_end; + //set the allocation heap base + gc_gen->alloc_heap_start = alloc_reserved_base; #ifdef STATIC_NOS_MAPPING gc_gen->reserved_heap_size = los_mos_reserve_size + nos_reserve_size; #else @@ -245,24 +257,32 @@ void gc_gen_destruct(GC_Gen *gc_gen) { TRACE2("gc.process", "GC: GC_Gen heap destruct ......"); - + + POINTER_SIZE_INT unmap_size; Space *nos = gc_gen->nos; gc_nos_destruct(gc_gen); - vm_unmap_mem(nos->heap_start, space_committed_size(nos)); + //cannot unmap partially + //vm_unmap_mem(nos->heap_start, space_committed_size(nos)); + unmap_size = space_committed_size(nos); gc_gen->nos = NULL; Space *mos = gc_gen->mos; gc_mos_destruct(gc_gen); - vm_unmap_mem(mos->heap_start, space_committed_size(mos)); + //cannot unmap partially + //vm_unmap_mem(mos->heap_start, space_committed_size(mos)); + unmap_size = unmap_size + space_committed_size(mos); gc_gen->mos = NULL; if(MAJOR_ALGO != MAJOR_MARK_SWEEP){ Space *los = gc_gen->los; gc_los_destruct(gc_gen); - vm_unmap_mem(los->heap_start, space_committed_size(los)); + //cannot unmap partially + // vm_unmap_mem(los->heap_start, space_committed_size(los)); + unmap_size = unmap_size + space_committed_size(los); gc_gen->los = NULL; } - + //unmap whole heap + vm_unmap_mem(gc_gen->alloc_heap_start, unmap_size); #ifdef GC_GEN_STATS gc_gen_stats_destruct(gc_gen); #endif