Package edu.wpi.grip.core
Class Cleaner
- java.lang.Object
-
- edu.wpi.grip.core.Cleaner
-
public class Cleaner extends java.lang.Object
Cleans up unused objects by periodically callingSystem.gc()
to nudge the garbage collector to clean up dead native (JavaCV) objects. This is required because JavaCV objects only free their native memory when they're garbage collected, so if they accumulate in the heap, the app will use about 40x the memory as used heap (i.e. 230MB of used heap results in about 9.8GB of used memory for the process). This is becauseMats
and anything else extendingPointer
use native memory that greatly exceeds the Java objects size on the heap.JavaCV has a system property
org.bytedeco.javacpp.maxphysicalbytes
that it uses to determine when to start deallocating native memory. However, this only results in calls toSystem.gc()
and imposes a hard upper limit on native memory use, limiting large images or long pipelines. It's also not very portable: running from source needs it to be passed as a JVM argument with gradle, and it can't be adjusted based on the amount of memory on the system it's installed on. For us, manually running System.gc() periodically is a better solution.
-
-
Constructor Summary
Constructors Constructor Description Cleaner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onRunFinished(RunStoppedEvent e)
-
-
-
Method Detail
-
onRunFinished
public void onRunFinished(@Nullable RunStoppedEvent e)
-
-