1.1 --- a/src/share/vm/memory/cardTableModRefBS.cpp Thu Apr 18 14:03:37 2013 -0400 1.2 +++ b/src/share/vm/memory/cardTableModRefBS.cpp Fri Apr 19 11:08:52 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2000, 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 @@ -78,17 +78,13 @@ 1.11 1.12 assert(card_size <= 512, "card_size must be less than 512"); // why? 1.13 1.14 - _covered = new MemRegion[max_covered_regions]; 1.15 - _committed = new MemRegion[max_covered_regions]; 1.16 - if (_covered == NULL || _committed == NULL) 1.17 + NEW_C_HEAP_OBJECT_ARRAY(_covered, MemRegion, max_covered_regions, mtGC, 0, AllocFailStrategy::RETURN_NULL); 1.18 + NEW_C_HEAP_OBJECT_ARRAY(_committed, MemRegion, max_covered_regions, mtGC, 0, AllocFailStrategy::RETURN_NULL); 1.19 + if (_covered == NULL || _committed == NULL) { 1.20 vm_exit_during_initialization("couldn't alloc card table covered region set."); 1.21 - int i; 1.22 - for (i = 0; i < max_covered_regions; i++) { 1.23 - _covered[i].set_word_size(0); 1.24 - _committed[i].set_word_size(0); 1.25 } 1.26 + 1.27 _cur_covered_regions = 0; 1.28 - 1.29 const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 : 1.30 MAX2(_page_size, (size_t) os::vm_allocation_granularity()); 1.31 ReservedSpace heap_rs(_byte_map_size, rs_align, false); 1.32 @@ -134,7 +130,7 @@ 1.33 || _lowest_non_clean_base_chunk_index == NULL 1.34 || _last_LNC_resizing_collection == NULL) 1.35 vm_exit_during_initialization("couldn't allocate an LNC array."); 1.36 - for (i = 0; i < max_covered_regions; i++) { 1.37 + for (int i = 0; i < max_covered_regions; i++) { 1.38 _lowest_non_clean[i] = NULL; 1.39 _lowest_non_clean_chunk_size[i] = 0; 1.40 _last_LNC_resizing_collection[i] = -1; 1.41 @@ -153,6 +149,33 @@ 1.42 } 1.43 } 1.44 1.45 +CardTableModRefBS::~CardTableModRefBS() { 1.46 + if (_covered) { 1.47 + FREE_C_HEAP_OBJECT_ARRAY(MemRegion, _covered, _max_covered_regions, mtGC); 1.48 + _covered = NULL; 1.49 + } 1.50 + if (_committed) { 1.51 + FREE_C_HEAP_OBJECT_ARRAY(MemRegion, _committed, _max_covered_regions, mtGC); 1.52 + _committed = NULL; 1.53 + } 1.54 + if (_lowest_non_clean) { 1.55 + FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean, mtGC); 1.56 + _lowest_non_clean = NULL; 1.57 + } 1.58 + if (_lowest_non_clean_chunk_size) { 1.59 + FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size, mtGC); 1.60 + _lowest_non_clean_chunk_size = NULL; 1.61 + } 1.62 + if (_lowest_non_clean_base_chunk_index) { 1.63 + FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index, mtGC); 1.64 + _lowest_non_clean_base_chunk_index = NULL; 1.65 + } 1.66 + if (_last_LNC_resizing_collection) { 1.67 + FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection, mtGC); 1.68 + _last_LNC_resizing_collection = NULL; 1.69 + } 1.70 +} 1.71 + 1.72 int CardTableModRefBS::find_covering_region_by_base(HeapWord* base) { 1.73 int i; 1.74 for (i = 0; i < _cur_covered_regions; i++) {