1.1 --- a/src/share/vm/services/memSnapshot.cpp Fri May 03 15:51:16 2013 -0700 1.2 +++ b/src/share/vm/services/memSnapshot.cpp Mon May 06 11:15:13 2013 -0400 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -262,13 +262,28 @@ 1.11 assert(cur->is_reserved_region() && cur->contains_region(rec), 1.12 "Sanity check"); 1.13 if (rec->is_same_region(cur)) { 1.14 - // release whole reserved region 1.15 + 1.16 + // In snapshot, the virtual memory records are sorted in following orders: 1.17 + // 1. virtual memory's base address 1.18 + // 2. virtual memory reservation record, followed by commit records within this reservation. 1.19 + // The commit records are also in base address order. 1.20 + // When a reserved region is released, we want to remove the reservation record and all 1.21 + // commit records following it. 1.22 #ifdef ASSERT 1.23 - VMMemRegion* next_region = (VMMemRegion*)peek_next(); 1.24 - // should not have any committed memory in this reserved region 1.25 - assert(next_region == NULL || !next_region->is_committed_region(), "Sanity check"); 1.26 + address low_addr = cur->addr(); 1.27 + address high_addr = low_addr + cur->size(); 1.28 #endif 1.29 + // remove virtual memory reservation record 1.30 remove(); 1.31 + // remove committed regions within above reservation 1.32 + VMMemRegion* next_region = (VMMemRegion*)current(); 1.33 + while (next_region != NULL && next_region->is_committed_region()) { 1.34 + assert(next_region->addr() >= low_addr && 1.35 + next_region->addr() + next_region->size() <= high_addr, 1.36 + "Range check"); 1.37 + remove(); 1.38 + next_region = (VMMemRegion*)current(); 1.39 + } 1.40 } else if (rec->addr() == cur->addr() || 1.41 rec->addr() + rec->size() == cur->addr() + cur->size()) { 1.42 // released region is at either end of this region