Mercurial > hg > truffle
comparison src/share/vm/memory/allocation.inline.hpp @ 9073:83f27710f5f7
7197666: java -d64 -version core dumps in a box with lots of memory
Summary: Allow task queues to be mmapped instead of malloced on Solaris
Reviewed-by: coleenp, jmasa, johnc, tschatzl
author | brutisso |
---|---|
date | Mon, 08 Apr 2013 07:49:28 +0200 |
parents | 63e54c37ac64 |
children | 6f817ce50129 |
comparison
equal
deleted
inserted
replaced
9072:8617e38bb4cb | 9073:83f27710f5f7 |
---|---|
106 | 106 |
107 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){ | 107 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){ |
108 FreeHeap(p, F); | 108 FreeHeap(p, F); |
109 } | 109 } |
110 | 110 |
111 template <class E, MEMFLAGS F> | |
112 E* ArrayAllocator<E, F>::allocate(size_t length) { | |
113 assert(_addr == NULL, "Already in use"); | |
114 | |
115 _size = sizeof(E) * length; | |
116 _use_malloc = _size < ArrayAllocatorMallocLimit; | |
117 | |
118 if (_use_malloc) { | |
119 _addr = AllocateHeap(_size, F); | |
120 if (_addr == NULL && _size >= (size_t)os::vm_allocation_granularity()) { | |
121 // malloc failed let's try with mmap instead | |
122 _use_malloc = false; | |
123 } else { | |
124 return (E*)_addr; | |
125 } | |
126 } | |
127 | |
128 int alignment = os::vm_allocation_granularity(); | |
129 _size = align_size_up(_size, alignment); | |
130 | |
131 _addr = os::reserve_memory(_size, NULL, alignment); | |
132 if (_addr == NULL) { | |
133 vm_exit_out_of_memory(_size, "Allocator (reserve)"); | |
134 } | |
135 | |
136 bool success = os::commit_memory(_addr, _size, false /* executable */); | |
137 if (!success) { | |
138 vm_exit_out_of_memory(_size, "Allocator (commit)"); | |
139 } | |
140 | |
141 return (E*)_addr; | |
142 } | |
143 | |
144 template<class E, MEMFLAGS F> | |
145 void ArrayAllocator<E, F>::free() { | |
146 if (_addr != NULL) { | |
147 if (_use_malloc) { | |
148 FreeHeap(_addr, F); | |
149 } else { | |
150 os::release_memory(_addr, _size); | |
151 } | |
152 _addr = NULL; | |
153 } | |
154 } | |
111 | 155 |
112 #endif // SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP | 156 #endif // SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP |