src/share/vm/memory/allocation.hpp

changeset 5280
9f9c0a163cc5
parent 5269
abbd5c660b48
parent 5278
b9d151496930
child 5295
9f3e3245b50f
child 5307
e0c9a1d29eb4
equal deleted inserted replaced
5275:726d2d4913fc 5280:9f9c0a163cc5
730 // Most OS mallocs do something similar but Solaris malloc does not revert 730 // Most OS mallocs do something similar but Solaris malloc does not revert
731 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit 731 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
732 // is set so that we always use malloc except for Solaris where we set the 732 // is set so that we always use malloc except for Solaris where we set the
733 // limit to get mapped memory. 733 // limit to get mapped memory.
734 template <class E, MEMFLAGS F> 734 template <class E, MEMFLAGS F>
735 class ArrayAllocator : StackObj { 735 class ArrayAllocator VALUE_OBJ_CLASS_SPEC {
736 char* _addr; 736 char* _addr;
737 bool _use_malloc; 737 bool _use_malloc;
738 size_t _size; 738 size_t _size;
739 public: 739 bool _free_in_destructor;
740 ArrayAllocator() : _addr(NULL), _use_malloc(false), _size(0) { } 740 public:
741 ~ArrayAllocator() { free(); } 741 ArrayAllocator(bool free_in_destructor = true) :
742 _addr(NULL), _use_malloc(false), _size(0), _free_in_destructor(free_in_destructor) { }
743
744 ~ArrayAllocator() {
745 if (_free_in_destructor) {
746 free();
747 }
748 }
749
742 E* allocate(size_t length); 750 E* allocate(size_t length);
743 void free(); 751 void free();
744 }; 752 };
745 753
746 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP 754 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP

mercurial