< prev index next >

src/hotspot/share/services/mallocTracker.hpp

Print this page
rev 47399 : [mq]: add_ptr


  51     DEBUG_ONLY(_peak_count = 0;)
  52     DEBUG_ONLY(_peak_size  = 0;)
  53   }
  54 
  55   inline void allocate(size_t sz) {
  56     Atomic::inc(&_count);
  57     if (sz > 0) {
  58       Atomic::add(sz, &_size);
  59       DEBUG_ONLY(_peak_size = MAX2(_peak_size, _size));
  60     }
  61     DEBUG_ONLY(_peak_count = MAX2(_peak_count, _count);)
  62   }
  63 
  64   inline void deallocate(size_t sz) {
  65     assert(_count > 0, "Nothing allocated yet");
  66     assert(_size >= sz, "deallocation > allocated");
  67     Atomic::dec(&_count);
  68     if (sz > 0) {
  69       // unary minus operator applied to unsigned type, result still unsigned
  70       #pragma warning(suppress: 4146)
  71       Atomic::add(-sz, &_size);
  72     }
  73   }
  74 
  75   inline void resize(long sz) {
  76     if (sz != 0) {
  77       Atomic::add(size_t(sz), &_size);
  78       DEBUG_ONLY(_peak_size = MAX2(_size, _peak_size);)
  79     }
  80   }
  81 
  82   inline size_t count() const { return _count; }
  83   inline size_t size()  const { return _size;  }
  84   DEBUG_ONLY(inline size_t peak_count() const { return _peak_count; })
  85   DEBUG_ONLY(inline size_t peak_size()  const { return _peak_size; })
  86 
  87 };
  88 
  89 /*
  90  * Malloc memory used by a particular subsystem.
  91  * It includes the memory acquired through os::malloc()




  51     DEBUG_ONLY(_peak_count = 0;)
  52     DEBUG_ONLY(_peak_size  = 0;)
  53   }
  54 
  55   inline void allocate(size_t sz) {
  56     Atomic::inc(&_count);
  57     if (sz > 0) {
  58       Atomic::add(sz, &_size);
  59       DEBUG_ONLY(_peak_size = MAX2(_peak_size, _size));
  60     }
  61     DEBUG_ONLY(_peak_count = MAX2(_peak_count, _count);)
  62   }
  63 
  64   inline void deallocate(size_t sz) {
  65     assert(_count > 0, "Nothing allocated yet");
  66     assert(_size >= sz, "deallocation > allocated");
  67     Atomic::dec(&_count);
  68     if (sz > 0) {
  69       // unary minus operator applied to unsigned type, result still unsigned
  70       #pragma warning(suppress: 4146)
  71       Atomic::sub(sz, &_size);
  72     }
  73   }
  74 
  75   inline void resize(long sz) {
  76     if (sz != 0) {
  77       Atomic::add(size_t(sz), &_size);
  78       DEBUG_ONLY(_peak_size = MAX2(_size, _peak_size);)
  79     }
  80   }
  81 
  82   inline size_t count() const { return _count; }
  83   inline size_t size()  const { return _size;  }
  84   DEBUG_ONLY(inline size_t peak_count() const { return _peak_count; })
  85   DEBUG_ONLY(inline size_t peak_size()  const { return _peak_size; })
  86 
  87 };
  88 
  89 /*
  90  * Malloc memory used by a particular subsystem.
  91  * It includes the memory acquired through os::malloc()


< prev index next >