@@ -36,12 +36,12 @@ public MeterThread(LongConsumer callback, int intervalMs) {
36
36
}
37
37
38
38
// Basically, we have two ways of measuring the allocation rate.
39
- // First relies on checking heap usage between two points of time and
40
- // substracting . This is accurate, but works only if the GC didn't trigger
41
- // in the meantime.
42
- // Second works by taking allocation stats by each alive thread. This is
43
- // more reliable, but potentially less accurate (because threads can go
44
- // away, and we lose their allocation stats).
39
+ // The first relies on checking heap usage between two points in time and
40
+ // subtracting . This is accurate but works only if the GC didn't trigger in
41
+ // the meantime.
42
+ // The second works by taking allocation stats by each alive thread. This is
43
+ // more reliable but potentially less accurate (because threads can go away,
44
+ // and we lose their allocation stats).
45
45
// The idea is to use the first approach if GC didn't happen, and the second
46
46
// one if it did.
47
47
@@ -109,8 +109,9 @@ private BigInteger allocatedByAllThreads() {
109
109
long [] ids = threadBean .getAllThreadIds ();
110
110
long [] allocatedBytes = threadBean .getThreadAllocatedBytes (ids );
111
111
BigInteger result = BigInteger .ZERO ;
112
- // This is not correct because we will lose allocation data from threads
113
- // that died. Oh well.
112
+ // This is approach is not entirely correct because doesn't see the
113
+ // allocation data from threads that died since the last iteration. Oh
114
+ // well, doing best effort.
114
115
for (long abytes : allocatedBytes )
115
116
result = result .add (BigInteger .valueOf (abytes ));
116
117
return result ;
0 commit comments