< prev index next >

src/share/vm/memory/allocation.hpp

Print this page
rev 10388 : imported patch fixAA


 709 // should check the ReallocMark.
 710 class ReallocMark: public StackObj {
 711 protected:
 712   NOT_PRODUCT(int _nesting;)
 713 
 714 public:
 715   ReallocMark()   PRODUCT_RETURN;
 716   void check()    PRODUCT_RETURN;
 717 };
 718 
 719 // Helper class to allocate arrays that may become large.
 720 // Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
 721 // and uses mapped memory for larger allocations.
 722 // Most OS mallocs do something similar but Solaris malloc does not revert
 723 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
 724 // is set so that we always use malloc except for Solaris where we set the
 725 // limit to get mapped memory.
 726 template <class E, MEMFLAGS F>
 727 class ArrayAllocator : public AllStatic {
 728  private:
 729   static bool should_use_malloc(size_t length) {
 730     return length * sizeof(E) < ArrayAllocatorMallocLimit;
 731   }
 732 
 733   static size_t size_for_malloc(size_t length);
 734   static size_t size_for_mmap(size_t length);
 735 
 736   static E* allocate_malloc(size_t length);
 737   static E* allocate_mmap(size_t length);
 738 
 739   static void free_malloc(E* addr, size_t length);
 740   static void free_mmap(E* addr, size_t length);
 741 
 742  public:
 743   static E* allocate(size_t length);
 744   static E* reallocate(E* old_addr, size_t old_length, size_t new_length);
 745   static void free(E* addr, size_t length);
 746 };
 747 
 748 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP


 709 // should check the ReallocMark.
 710 class ReallocMark: public StackObj {
 711 protected:
 712   NOT_PRODUCT(int _nesting;)
 713 
 714 public:
 715   ReallocMark()   PRODUCT_RETURN;
 716   void check()    PRODUCT_RETURN;
 717 };
 718 
 719 // Helper class to allocate arrays that may become large.
 720 // Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
 721 // and uses mapped memory for larger allocations.
 722 // Most OS mallocs do something similar but Solaris malloc does not revert
 723 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
 724 // is set so that we always use malloc except for Solaris where we set the
 725 // limit to get mapped memory.
 726 template <class E, MEMFLAGS F>
 727 class ArrayAllocator : public AllStatic {
 728  private:
 729   static bool should_use_malloc(size_t length);


 730 
 731   static size_t size_for_malloc(size_t length);
 732   static size_t size_for_mmap(size_t length);
 733 
 734   static E* allocate_malloc(size_t length);
 735   static E* allocate_mmap(size_t length);
 736 
 737   static void free_malloc(E* addr, size_t length);
 738   static void free_mmap(E* addr, size_t length);
 739 
 740  public:
 741   static E* allocate(size_t length);
 742   static E* reallocate(E* old_addr, size_t old_length, size_t new_length);
 743   static void free(E* addr, size_t length);
 744 };
 745 
 746 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP
< prev index next >