Skip to content

Commit 9902ae6

Browse files
Fix comments
1 parent d0ea660 commit 9902ae6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/jvm_alloc_rate_meter/MeterThread.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ public MeterThread(LongConsumer callback, int intervalMs) {
3636
}
3737

3838
// 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).
4545
// The idea is to use the first approach if GC didn't happen, and the second
4646
// one if it did.
4747

@@ -109,8 +109,9 @@ private BigInteger allocatedByAllThreads() {
109109
long[] ids = threadBean.getAllThreadIds();
110110
long[] allocatedBytes = threadBean.getThreadAllocatedBytes(ids);
111111
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.
114115
for (long abytes : allocatedBytes)
115116
result = result.add(BigInteger.valueOf(abytes));
116117
return result;

0 commit comments

Comments
 (0)