55 }
56 }
57
58 // Method below is called by VM and VM expect certain
59 // entry class layout.
60
61 static Entry[] getFinalizerHistogram() {
62 Map<String, Entry> countMap = new HashMap<>();
63 ReferenceQueue<Object> queue = Finalizer.getQueue();
64 queue.forEach(r -> {
65 Object referent = r.get();
66 if (referent != null) {
67 countMap.computeIfAbsent(
68 referent.getClass().getName(), Entry::new).increment();
69 /* Clear stack slot containing this variable, to decrease
70 the chances of false retention with a conservative GC */
71 referent = null;
72 }
73 });
74
75 Entry fhe[] = countMap.values().toArray(new Entry[countMap.size()]);
76 Arrays.sort(fhe,
77 Comparator.comparingInt(Entry::getInstanceCount).reversed());
78 return fhe;
79 }
80 }
|
55 }
56 }
57
58 // Method below is called by VM and VM expect certain
59 // entry class layout.
60
61 static Entry[] getFinalizerHistogram() {
62 Map<String, Entry> countMap = new HashMap<>();
63 ReferenceQueue<Object> queue = Finalizer.getQueue();
64 queue.forEach(r -> {
65 Object referent = r.get();
66 if (referent != null) {
67 countMap.computeIfAbsent(
68 referent.getClass().getName(), Entry::new).increment();
69 /* Clear stack slot containing this variable, to decrease
70 the chances of false retention with a conservative GC */
71 referent = null;
72 }
73 });
74
75 Entry[] fhe = countMap.values().toArray(new Entry[countMap.size()]);
76 Arrays.sort(fhe,
77 Comparator.comparingInt(Entry::getInstanceCount).reversed());
78 return fhe;
79 }
80 }
|