src/share/vm/memory/allocation.cpp

changeset 2557
f7de3327c683
parent 2357
79d8657be916
child 2589
4a9604cd7c5f
     1.1 --- a/src/share/vm/memory/allocation.cpp	Mon Feb 07 10:25:39 2011 -0800
     1.2 +++ b/src/share/vm/memory/allocation.cpp	Mon Feb 07 10:34:39 2011 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -157,7 +157,7 @@
    1.11  
    1.12  void trace_heap_malloc(size_t size, const char* name, void* p) {
    1.13    // A lock is not needed here - tty uses a lock internally
    1.14 -  tty->print_cr("Heap malloc " INTPTR_FORMAT " %7d %s", p, size, name == NULL ? "" : name);
    1.15 +  tty->print_cr("Heap malloc " INTPTR_FORMAT " " SIZE_FORMAT " %s", p, size, name == NULL ? "" : name);
    1.16  }
    1.17  
    1.18  
    1.19 @@ -573,22 +573,27 @@
    1.20    st->print("AllocatedObj(" INTPTR_FORMAT ")", this);
    1.21  }
    1.22  
    1.23 -size_t Arena::_bytes_allocated = 0;
    1.24 +julong Arena::_bytes_allocated = 0;
    1.25 +
    1.26 +void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); }
    1.27  
    1.28  AllocStats::AllocStats() {
    1.29 -  start_mallocs = os::num_mallocs;
    1.30 -  start_frees = os::num_frees;
    1.31 +  start_mallocs      = os::num_mallocs;
    1.32 +  start_frees        = os::num_frees;
    1.33    start_malloc_bytes = os::alloc_bytes;
    1.34 -  start_res_bytes = Arena::_bytes_allocated;
    1.35 +  start_mfree_bytes  = os::free_bytes;
    1.36 +  start_res_bytes    = Arena::_bytes_allocated;
    1.37  }
    1.38  
    1.39 -int     AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
    1.40 -size_t  AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
    1.41 -size_t  AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
    1.42 -int     AllocStats::num_frees() { return os::num_frees - start_frees; }
    1.43 +julong  AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
    1.44 +julong  AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
    1.45 +julong  AllocStats::num_frees()   { return os::num_frees - start_frees; }
    1.46 +julong  AllocStats::free_bytes()  { return os::free_bytes - start_mfree_bytes; }
    1.47 +julong  AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
    1.48  void    AllocStats::print() {
    1.49 -  tty->print("%d mallocs (%ldK), %d frees, %ldK resrc",
    1.50 -             num_mallocs(), alloc_bytes()/K, num_frees(), resource_bytes()/K);
    1.51 +  tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), "
    1.52 +                UINT64_FORMAT" frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc",
    1.53 +                num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M);
    1.54  }
    1.55  
    1.56  

mercurial