equal
deleted
inserted
replaced
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 |