Mercurial > hg > truffle
diff src/share/vm/memory/allocation.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 | 4102b59539ce |
children | 89e4d67fdd2a f36e073d56a4 6f817ce50129 f75faf51e8c4 |
line wrap: on
line diff
--- a/src/share/vm/memory/allocation.hpp Mon Feb 11 10:31:56 2013 -0800 +++ b/src/share/vm/memory/allocation.hpp Mon Apr 08 07:49:28 2013 +0200 @@ -611,4 +611,23 @@ void check() PRODUCT_RETURN; }; +// Helper class to allocate arrays that may become large. +// Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit +// and uses mapped memory for larger allocations. +// Most OS mallocs do something similar but Solaris malloc does not revert +// to mapped memory for large allocations. By default ArrayAllocatorMallocLimit +// is set so that we always use malloc except for Solaris where we set the +// limit to get mapped memory. +template <class E, MEMFLAGS F> +class ArrayAllocator : StackObj { + char* _addr; + bool _use_malloc; + size_t _size; + public: + ArrayAllocator() : _addr(NULL), _use_malloc(false), _size(0) { } + ~ArrayAllocator() { free(); } + E* allocate(size_t length); + void free(); +}; + #endif // SHARE_VM_MEMORY_ALLOCATION_HPP