comparison src/share/vm/memory/allocation.hpp @ 10992:b9d151496930

8016556: G1: Use ArrayAllocator for BitMaps Reviewed-by: tschatzl, dholmes, coleenp, johnc
author brutisso
date Tue, 18 Jun 2013 22:45:32 +0200
parents f2110083203d
children 9f9c0a163cc5
comparison
equal deleted inserted replaced
10991:01522ca68fc7 10992:b9d151496930
711 // Most OS mallocs do something similar but Solaris malloc does not revert 711 // Most OS mallocs do something similar but Solaris malloc does not revert
712 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit 712 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
713 // is set so that we always use malloc except for Solaris where we set the 713 // is set so that we always use malloc except for Solaris where we set the
714 // limit to get mapped memory. 714 // limit to get mapped memory.
715 template <class E, MEMFLAGS F> 715 template <class E, MEMFLAGS F>
716 class ArrayAllocator : StackObj { 716 class ArrayAllocator VALUE_OBJ_CLASS_SPEC {
717 char* _addr; 717 char* _addr;
718 bool _use_malloc; 718 bool _use_malloc;
719 size_t _size; 719 size_t _size;
720 public: 720 bool _free_in_destructor;
721 ArrayAllocator() : _addr(NULL), _use_malloc(false), _size(0) { } 721 public:
722 ~ArrayAllocator() { free(); } 722 ArrayAllocator(bool free_in_destructor = true) :
723 _addr(NULL), _use_malloc(false), _size(0), _free_in_destructor(free_in_destructor) { }
724
725 ~ArrayAllocator() {
726 if (_free_in_destructor) {
727 free();
728 }
729 }
730
723 E* allocate(size_t length); 731 E* allocate(size_t length);
724 void free(); 732 void free();
725 }; 733 };
726 734
727 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP 735 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP