src/share/vm/memory/allocation.hpp

changeset 4901
83f27710f5f7
parent 4512
4102b59539ce
child 4942
f36e073d56a4
child 4962
6f817ce50129
child 5241
f75faf51e8c4
     1.1 --- a/src/share/vm/memory/allocation.hpp	Mon Feb 11 10:31:56 2013 -0800
     1.2 +++ b/src/share/vm/memory/allocation.hpp	Mon Apr 08 07:49:28 2013 +0200
     1.3 @@ -611,4 +611,23 @@
     1.4    void check()    PRODUCT_RETURN;
     1.5  };
     1.6  
     1.7 +// Helper class to allocate arrays that may become large.
     1.8 +// Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
     1.9 +// and uses mapped memory for larger allocations.
    1.10 +// Most OS mallocs do something similar but Solaris malloc does not revert
    1.11 +// to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
    1.12 +// is set so that we always use malloc except for Solaris where we set the
    1.13 +// limit to get mapped memory.
    1.14 +template <class E, MEMFLAGS F>
    1.15 +class ArrayAllocator : StackObj {
    1.16 +  char* _addr;
    1.17 +  bool _use_malloc;
    1.18 +  size_t _size;
    1.19 + public:
    1.20 +  ArrayAllocator() : _addr(NULL), _use_malloc(false), _size(0) { }
    1.21 +  ~ArrayAllocator() { free(); }
    1.22 +  E* allocate(size_t length);
    1.23 +  void free();
    1.24 +};
    1.25 +
    1.26  #endif // SHARE_VM_MEMORY_ALLOCATION_HPP

mercurial