annotate src/share/vm/memory/allocation.inline.hpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents 833b0f92429a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
8675
63e54c37ac64 8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents: 6872
diff changeset
28 #include "runtime/atomic.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/os.hpp"
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
30 #include "services/memTracker.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Explicit C-heap memory management
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 void trace_heap_malloc(size_t size, const char* name, void *p);
a61af66fc99e Initial load
duke
parents:
diff changeset
35 void trace_heap_free(void *p);
a61af66fc99e Initial load
duke
parents:
diff changeset
36
2255
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
37 #ifndef PRODUCT
2250
f7de3327c683 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 1972
diff changeset
38 // Increments unsigned long value for statistics (not atomic on MP).
f7de3327c683 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 1972
diff changeset
39 inline void inc_stat_counter(volatile julong* dest, julong add_value) {
2255
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
40 #if defined(SPARC) || defined(X86)
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
41 // Sparc and X86 have atomic jlong (8 bytes) instructions
2250
f7de3327c683 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 1972
diff changeset
42 julong value = Atomic::load((volatile jlong*)dest);
f7de3327c683 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 1972
diff changeset
43 value += add_value;
f7de3327c683 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 1972
diff changeset
44 Atomic::store((jlong)value, (volatile jlong*)dest);
2255
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
45 #else
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
46 // possible word-tearing during load/store
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
47 *dest += add_value;
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
48 #endif
2250
f7de3327c683 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 1972
diff changeset
49 }
2255
bf29934d2f4f 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 2250
diff changeset
50 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // allocate using malloc; will fail if no memory available
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
53 inline char* AllocateHeap(size_t size, MEMFLAGS flags,
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
54 const NativeCallStack& stack,
6872
7b5885dadbdc 8000617: It should be possible to allocate memory without the VM dying.
nloodin
parents: 6842
diff changeset
55 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
56 char* p = (char*) os::malloc(size, flags, stack);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #ifdef ASSERT
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
58 if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 #endif
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
60 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
61 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
62 }
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
63 return p;
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
64 }
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
65 inline char* AllocateHeap(size_t size, MEMFLAGS flags,
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
66 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
67 return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
68 }
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
69
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
70 inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag,
6872
7b5885dadbdc 8000617: It should be possible to allocate memory without the VM dying.
nloodin
parents: 6842
diff changeset
71 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
72 char* p = (char*) os::realloc(old, size, flag, CURRENT_PC);
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
73 #ifdef ASSERT
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
74 if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
75 #endif
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
76 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
77 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
78 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return p;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
82 inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (PrintMallocFree) trace_heap_free(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 #endif
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
86 os::free(p, memflags);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
88
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
89
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
90 template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
91 const NativeCallStack& stack) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
92 void* p = (void*)AllocateHeap(size, F, stack);
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
93 #ifdef ASSERT
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
94 if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
95 #endif
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
96 return p;
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
97 }
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
98
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
99 template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
100 return CHeapObj<F>::operator new(size, CALLER_PC);
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
101 }
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
102
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
103 template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
104 const std::nothrow_t& nothrow_constant, const NativeCallStack& stack) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
105 void* p = (void*)AllocateHeap(size, F, stack,
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
106 AllocFailStrategy::RETURN_NULL);
10135
5a9fa2ba85f0 8012907: anti-delta fix for 8010992
dcubed
parents: 10130
diff changeset
107 #ifdef ASSERT
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
108 if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
109 #endif
10135
5a9fa2ba85f0 8012907: anti-delta fix for 8010992
dcubed
parents: 10130
diff changeset
110 return p;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
111 }
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
112
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
113 template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
114 const std::nothrow_t& nothrow_constant) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
115 return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
116 }
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
117
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
118 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
119 const NativeCallStack& stack) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
120 return CHeapObj<F>::operator new(size, stack);
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
121 }
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
122
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
123 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size)
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
124 throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
125 return CHeapObj<F>::operator new(size, CALLER_PC);
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
126 }
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
127
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
128 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
20360
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
129 const std::nothrow_t& nothrow_constant, const NativeCallStack& stack) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
130 return CHeapObj<F>::operator new(size, nothrow_constant, stack);
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
131 }
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
132
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
133 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
134 const std::nothrow_t& nothrow_constant) throw() {
833b0f92429a 8046598: Scalable Native memory tracking development
zgu
parents: 12146
diff changeset
135 return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
136 }
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
137
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
138 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
139 FreeHeap(p, F);
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
140 }
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
141
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
142 template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10221
diff changeset
143 FreeHeap(p, F);
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
144 }
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
145
9073
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
146 template <class E, MEMFLAGS F>
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
147 E* ArrayAllocator<E, F>::allocate(size_t length) {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
148 assert(_addr == NULL, "Already in use");
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
149
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
150 _size = sizeof(E) * length;
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
151 _use_malloc = _size < ArrayAllocatorMallocLimit;
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
152
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
153 if (_use_malloc) {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
154 _addr = AllocateHeap(_size, F);
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
155 if (_addr == NULL && _size >= (size_t)os::vm_allocation_granularity()) {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
156 // malloc failed let's try with mmap instead
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
157 _use_malloc = false;
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
158 } else {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
159 return (E*)_addr;
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
160 }
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
161 }
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
162
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
163 int alignment = os::vm_allocation_granularity();
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
164 _size = align_size_up(_size, alignment);
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
165
10221
c18152e0554e 8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents: 10161
diff changeset
166 _addr = os::reserve_memory(_size, NULL, alignment, F);
9073
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
167 if (_addr == NULL) {
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 10135
diff changeset
168 vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (reserve)");
9073
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
169 }
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
170
10969
a837fa3d3f86 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 10271
diff changeset
171 os::commit_memory_or_exit(_addr, _size, !ExecMem, "Allocator (commit)");
9073
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
172
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
173 return (E*)_addr;
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
174 }
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
175
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
176 template<class E, MEMFLAGS F>
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
177 void ArrayAllocator<E, F>::free() {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
178 if (_addr != NULL) {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
179 if (_use_malloc) {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
180 FreeHeap(_addr, F);
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
181 } else {
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
182 os::release_memory(_addr, _size);
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
183 }
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
184 _addr = NULL;
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
185 }
83f27710f5f7 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 8675
diff changeset
186 }
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2255
diff changeset
187
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
188 #endif // SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP