Print this page
rev 4524 : 8012086: The object count event should only send events for instances occupying more than 0.5% of the heap
Reviewed-by: brutisso, jwilhelm

Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/memory/heapInspection.hpp
          +++ new/src/share/vm/memory/heapInspection.hpp
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20   20   * or visit www.oracle.com if you need additional information or have any
  21   21   * questions.
  22   22   *
  23   23   */
  24   24  
  25   25  #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP
  26   26  #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP
  27   27  
  28   28  #include "memory/allocation.inline.hpp"
       29 +#include "memory/klassInfoClosure.hpp"
  29   30  #include "oops/oop.inline.hpp"
  30   31  
  31   32  
  32   33  // HeapInspection
  33   34  
  34   35  // KlassInfoTable is a bucket hash table that
  35   36  // maps klassOops to extra information:
  36   37  //    instance count and instance word size.
  37   38  //
  38   39  // A KlassInfoBucket is the head of a link list
↓ open down ↓ 18 lines elided ↑ open up ↑
  57   58    bool is_equal(klassOop k)  { return k == _klass; }
  58   59    klassOop klass()           { return _klass; }
  59   60    long count()               { return _instance_count; }
  60   61    void set_count(long ct)    { _instance_count = ct; }
  61   62    size_t words()             { return _instance_words; }
  62   63    void set_words(size_t wds) { _instance_words = wds; }
  63   64    int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
  64   65    void print_on(outputStream* st) const;
  65   66  };
  66   67  
  67      -class KlassInfoClosure: public StackObj {
  68      - public:
  69      -  // Called for each KlassInfoEntry.
  70      -  virtual void do_cinfo(KlassInfoEntry* cie) = 0;
  71      -};
  72      -
  73   68  class KlassInfoBucket: public CHeapObj<mtInternal> {
  74   69   private:
  75   70    KlassInfoEntry* _list;
  76   71    KlassInfoEntry* list()           { return _list; }
  77   72    void set_list(KlassInfoEntry* l) { _list = l; }
  78   73   public:
  79   74    KlassInfoEntry* lookup(const klassOop k);
  80   75    void initialize() { _list = NULL; }
  81   76    void empty();
  82   77    void iterate(KlassInfoClosure* cic);
  83   78  };
  84   79  
  85   80  class KlassInfoTable: public StackObj {
  86   81   private:
  87   82    int _size;
  88   83    static const int _num_buckets = 20011;
       84 +  size_t _size_of_instances_in_words;
  89   85  
  90   86    // An aligned reference address (typically the least
  91   87    // address in the perm gen) used for hashing klass
  92   88    // objects.
  93   89    HeapWord* _ref;
  94   90  
  95   91    KlassInfoBucket* _buckets;
  96   92    uint hash(klassOop p);
  97   93    KlassInfoEntry* lookup(const klassOop k);
  98   94  
  99   95   public:
 100   96    KlassInfoTable(HeapWord* ref);
 101   97    ~KlassInfoTable();
 102   98    bool record_instance(const oop obj);
 103   99    void iterate(KlassInfoClosure* cic);
 104  100    bool allocation_failed() { return _buckets == NULL; }
      101 +  size_t size_of_instances_in_words() const;
 105  102  };
 106  103  
 107  104  class KlassInfoHisto : public StackObj {
 108  105   private:
 109  106    GrowableArray<KlassInfoEntry*>* _elements;
 110  107    GrowableArray<KlassInfoEntry*>* elements() const { return _elements; }
 111  108    const char* _title;
 112  109    const char* title() const { return _title; }
 113  110    static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2);
 114  111    void print_elements(outputStream* st) const;
↓ open down ↓ 3 lines elided ↑ open up ↑
 118  115    ~KlassInfoHisto();
 119  116    void add(KlassInfoEntry* cie);
 120  117    void print_on(outputStream* st) const;
 121  118    void sort();
 122  119  };
 123  120  
 124  121  
 125  122  class HeapInspection : public AllStatic {
 126  123   public:
 127  124    static void heap_inspection(outputStream* st, bool need_prologue);
 128      -  static size_t instance_inspection(KlassInfoTable* cit,
 129      -                                    KlassInfoClosure* cl,
 130      -                                    bool need_prologue,
 131      -                                    BoolObjectClosure* filter = NULL);
      125 +  static size_t populate_table(KlassInfoTable* cit,
      126 +                               bool need_prologue,
      127 +                               BoolObjectClosure* filter = NULL);
 132  128    static HeapWord* start_of_perm_gen();
 133  129    static void find_instances_at_safepoint(klassOop k, GrowableArray<oop>* result);
 134  130   private:
 135  131    static bool is_shared_heap();
 136  132    static void prologue();
 137  133    static void epilogue();
 138  134  };
 139  135  
 140  136  #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX