mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
7197666: java -d64 -version core dumps in a box with lots of memory
Allow task queues to be mmapped instead of malloced on Solaris Reviewed-by: coleenp, jmasa, johnc, tschatzl
This commit is contained in:
parent
fabb8c6e25
commit
4a685f181b
4 changed files with 72 additions and 3 deletions
|
@ -108,5 +108,49 @@ template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){
|
|||
FreeHeap(p, F);
|
||||
}
|
||||
|
||||
template <class E, MEMFLAGS F>
|
||||
E* ArrayAllocator<E, F>::allocate(size_t length) {
|
||||
assert(_addr == NULL, "Already in use");
|
||||
|
||||
_size = sizeof(E) * length;
|
||||
_use_malloc = _size < ArrayAllocatorMallocLimit;
|
||||
|
||||
if (_use_malloc) {
|
||||
_addr = AllocateHeap(_size, F);
|
||||
if (_addr == NULL && _size >= (size_t)os::vm_allocation_granularity()) {
|
||||
// malloc failed let's try with mmap instead
|
||||
_use_malloc = false;
|
||||
} else {
|
||||
return (E*)_addr;
|
||||
}
|
||||
}
|
||||
|
||||
int alignment = os::vm_allocation_granularity();
|
||||
_size = align_size_up(_size, alignment);
|
||||
|
||||
_addr = os::reserve_memory(_size, NULL, alignment);
|
||||
if (_addr == NULL) {
|
||||
vm_exit_out_of_memory(_size, "Allocator (reserve)");
|
||||
}
|
||||
|
||||
bool success = os::commit_memory(_addr, _size, false /* executable */);
|
||||
if (!success) {
|
||||
vm_exit_out_of_memory(_size, "Allocator (commit)");
|
||||
}
|
||||
|
||||
return (E*)_addr;
|
||||
}
|
||||
|
||||
template<class E, MEMFLAGS F>
|
||||
void ArrayAllocator<E, F>::free() {
|
||||
if (_addr != NULL) {
|
||||
if (_use_malloc) {
|
||||
FreeHeap(_addr, F);
|
||||
} else {
|
||||
os::release_memory(_addr, _size);
|
||||
}
|
||||
_addr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue