Skip to content

Commit

Permalink
Enable advance leak detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
szetszwo committed Sep 29, 2024
1 parent 9159532 commit 0f4b61e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,19 @@ synchronized void assertNoLeaks() {
}

int n = 0;
for(LeakTracker tracker : set) {
for (LeakTracker tracker : set) {
if (tracker.reportLeak() != null) {
n++;
}
}
final int leaks = n;
Preconditions.assertTrue(n == 0, () -> "#leaks = " + leaks + ", set.size = " + set.size());
assertNoLeaks(n);
}

synchronized void assertNoLeaks(int leaks) {
Preconditions.assertTrue(leaks == 0, () -> {
final int size = set.size();
return "#leaks = " + leaks + (leaks == size? "==" : "!=") + " set.size = " + size;
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MiniRaftClusterWithGrpc newCluster(String[] ids, String[] listenerIds, Ra
};

static {
ReferenceCountedObject.enableLeakDetection();
ReferenceCountedObject.enableLeakDetection(true);
}

public interface FactoryGet extends Factory.Get<MiniRaftClusterWithGrpc> {
Expand Down

0 comments on commit 0f4b61e

Please sign in to comment.