43
44 // Make sure all targets are reachable and available for GC in scalable manner.
45 // This exposes the potential GC problem in Cleaner lists.
46 ArrayList<Target> targets;
47
48 @Setup
49 public void setup() {
50 targets = new ArrayList<>();
51 for (int c = 0; c < count; c++) {
52 targets.add(new Target());
53 }
54 }
55
56 @Benchmark
57 public void test() {
58 System.gc();
59 }
60
61 static class Target {
62 private static final Cleaner CLEANER = Cleaner.create();
63 public Target() {
64 CLEANER.register(this, () -> {});
65 }
66 }
67
68 }
|
43
44 // Make sure all targets are reachable and available for GC in scalable manner.
45 // This exposes the potential GC problem in Cleaner lists.
46 ArrayList<Target> targets;
47
48 @Setup
49 public void setup() {
50 targets = new ArrayList<>();
51 for (int c = 0; c < count; c++) {
52 targets.add(new Target());
53 }
54 }
55
56 @Benchmark
57 public void test() {
58 System.gc();
59 }
60
61 static class Target {
62 private static final Cleaner CLEANER = Cleaner.create();
63 @SuppressWarnings("initialization")
64 public Target() {
65 CLEANER.register(this, () -> {});
66 }
67 }
68
69 }
|