diff 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
line wrap: on
line diff
--- a/src/share/vm/memory/allocation.hpp	Tue Jun 18 12:31:07 2013 -0700
+++ b/src/share/vm/memory/allocation.hpp	Tue Jun 18 22:45:32 2013 +0200
@@ -713,13 +713,21 @@
 // is set so that we always use malloc except for Solaris where we set the
 // limit to get mapped memory.
 template <class E, MEMFLAGS F>
-class ArrayAllocator : StackObj {
+class ArrayAllocator VALUE_OBJ_CLASS_SPEC {
   char* _addr;
   bool _use_malloc;
   size_t _size;
+  bool _free_in_destructor;
  public:
-  ArrayAllocator() : _addr(NULL), _use_malloc(false), _size(0) { }
-  ~ArrayAllocator() { free(); }
+  ArrayAllocator(bool free_in_destructor = true) :
+    _addr(NULL), _use_malloc(false), _size(0), _free_in_destructor(free_in_destructor) { }
+
+  ~ArrayAllocator() {
+    if (_free_in_destructor) {
+      free();
+    }
+  }
+
   E* allocate(size_t length);
   void free();
 };