1.1 --- a/src/share/vm/memory/allocation.cpp Thu Oct 18 13:09:47 2012 -0400 1.2 +++ b/src/share/vm/memory/allocation.cpp Fri Oct 19 21:40:07 2012 -0400 1.3 @@ -433,19 +433,18 @@ 1.4 NOT_PRODUCT(Atomic::inc(&_instance_count);) 1.5 } 1.6 1.7 -Arena::Arena(Arena *a) : _chunk(a->_chunk), _hwm(a->_hwm), _max(a->_max), _first(a->_first) { 1.8 - set_size_in_bytes(a->size_in_bytes()); 1.9 - NOT_PRODUCT(Atomic::inc(&_instance_count);) 1.10 -} 1.11 - 1.12 - 1.13 Arena *Arena::move_contents(Arena *copy) { 1.14 copy->destruct_contents(); 1.15 copy->_chunk = _chunk; 1.16 copy->_hwm = _hwm; 1.17 copy->_max = _max; 1.18 copy->_first = _first; 1.19 - copy->set_size_in_bytes(size_in_bytes()); 1.20 + 1.21 + // workaround rare racing condition, which could double count 1.22 + // the arena size by native memory tracking 1.23 + size_t size = size_in_bytes(); 1.24 + set_size_in_bytes(0); 1.25 + copy->set_size_in_bytes(size); 1.26 // Destroy original arena 1.27 reset(); 1.28 return copy; // Return Arena with contents 1.29 @@ -497,6 +496,9 @@ 1.30 char* end = _first->next() ? _first->top() : _hwm; 1.31 free_malloced_objects(_first, _first->bottom(), end, _hwm); 1.32 } 1.33 + // reset size before chop to avoid a rare racing condition 1.34 + // that can have total arena memory exceed total chunk memory 1.35 + set_size_in_bytes(0); 1.36 _first->chop(); 1.37 reset(); 1.38 }