< prev index next >

src/hotspot/share/services/mallocTracker.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 #include "precompiled.hpp"
  25 
  26 #include "runtime/atomic.hpp"
  27 #include "services/mallocSiteTable.hpp"
  28 #include "services/mallocTracker.hpp"
  29 #include "services/mallocTracker.inline.hpp"
  30 #include "services/memTracker.hpp"
  31 
  32 size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)];
  33 
  34 // Total malloc'd memory amount
  35 size_t MallocMemorySnapshot::total() const {
  36   size_t amount = 0;
  37   for (int index = 0; index < mt_number_of_types; index ++) {
  38     amount += _malloc[index].malloc_size();
  39   }
  40   amount += _tracking_header.size() + total_arena();
  41   return amount;
  42 }
  43 
  44 // Total malloc'd memory used by arenas
  45 size_t MallocMemorySnapshot::total_arena() const {
  46   size_t amount = 0;


 136   //                      16 bytes alignment for 64-bit systems.
 137   assert(((size_t)memblock & (sizeof(size_t) * 2 - 1)) == 0, "Alignment check");
 138 
 139 #ifdef ASSERT
 140   if (level > NMT_minimal) {
 141     // Read back
 142     assert(get_size(memblock) == size,   "Wrong size");
 143     assert(get_flags(memblock) == flags, "Wrong flags");
 144   }
 145 #endif
 146 
 147   return memblock;
 148 }
 149 
 150 void* MallocTracker::record_free(void* memblock) {
 151   assert(MemTracker::tracking_level() != NMT_off && memblock != NULL, "precondition");
 152   MallocHeader* header = malloc_header(memblock);
 153   header->release();
 154   return (void*)header;
 155 }
 156 
 157 


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 #include "precompiled.hpp"
  25 

  26 #include "services/mallocSiteTable.hpp"
  27 #include "services/mallocTracker.hpp"
  28 #include "services/mallocTracker.inline.hpp"
  29 #include "services/memTracker.hpp"
  30 
  31 size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)];
  32 
  33 // Total malloc'd memory amount
  34 size_t MallocMemorySnapshot::total() const {
  35   size_t amount = 0;
  36   for (int index = 0; index < mt_number_of_types; index ++) {
  37     amount += _malloc[index].malloc_size();
  38   }
  39   amount += _tracking_header.size() + total_arena();
  40   return amount;
  41 }
  42 
  43 // Total malloc'd memory used by arenas
  44 size_t MallocMemorySnapshot::total_arena() const {
  45   size_t amount = 0;


 135   //                      16 bytes alignment for 64-bit systems.
 136   assert(((size_t)memblock & (sizeof(size_t) * 2 - 1)) == 0, "Alignment check");
 137 
 138 #ifdef ASSERT
 139   if (level > NMT_minimal) {
 140     // Read back
 141     assert(get_size(memblock) == size,   "Wrong size");
 142     assert(get_flags(memblock) == flags, "Wrong flags");
 143   }
 144 #endif
 145 
 146   return memblock;
 147 }
 148 
 149 void* MallocTracker::record_free(void* memblock) {
 150   assert(MemTracker::tracking_level() != NMT_off && memblock != NULL, "precondition");
 151   MallocHeader* header = malloc_header(memblock);
 152   header->release();
 153   return (void*)header;
 154 }


< prev index next >