32
32
import java .nio .ByteOrder ;
33
33
import java .util .Iterator ;
34
34
import java .util .concurrent .atomic .AtomicInteger ;
35
+ import java .util .concurrent .atomic .AtomicLong ;
35
36
import org .bytedeco .javacpp .annotation .Name ;
36
37
import org .bytedeco .javacpp .annotation .Platform ;
37
38
import org .bytedeco .javacpp .tools .Generator ;
@@ -285,6 +286,7 @@ static class DeallocatorReference extends PhantomReference<Pointer> implements D
285
286
Deallocator deallocator ;
286
287
287
288
static volatile long totalBytes = 0 ;
289
+ static AtomicLong totalCount = new AtomicLong ();
288
290
long bytes ;
289
291
290
292
AtomicInteger count ;
@@ -298,6 +300,7 @@ final void add() {
298
300
next .prev = head = this ;
299
301
}
300
302
totalBytes += bytes ;
303
+ totalCount .incrementAndGet ();
301
304
}
302
305
}
303
306
@@ -316,6 +319,7 @@ final void remove() {
316
319
}
317
320
prev = next = this ;
318
321
totalBytes -= bytes ;
322
+ totalCount .decrementAndGet ();
319
323
}
320
324
}
321
325
@@ -527,6 +531,11 @@ public static long totalBytes() {
527
531
return DeallocatorReference .totalBytes ;
528
532
}
529
533
534
+ /** Returns {@link DeallocatorReference#totalCount}, current number of pointers tracked by deallocators. */
535
+ public static long totalCount () {
536
+ return DeallocatorReference .totalCount .get ();
537
+ }
538
+
530
539
/** Returns {@link #maxPhysicalBytes}, the maximum amount of physical memory that should be used. */
531
540
public static long maxPhysicalBytes () {
532
541
return maxPhysicalBytes ;
0 commit comments