Package io.scanbot.sdk.image
Class ImageRefProfiler
- java.lang.Object
-
- io.scanbot.sdk.image.ImageRefProfiler
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class ImageRefProfiler extends java.lang.Object implements java.lang.AutoCloseableImageRef memory profiler. ImageRefs are reference-counted. If references aren't correctly released for whatever reason, the image memory will leak. Leaking memory over time may cause out-of-memory crashes and must be avoided. The profiler can return basic and detailed information about all currently alive ImageRefs, that can be useful to track leaking ImageRefs or to confirm that there are no leaks.
-
-
Constructor Summary
Constructors Constructor Description ImageRefProfiler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes native resources held by the object.static ImageRefPoolSnapshotsDiffdiff(ImageRefPoolSnapshot firstSnapshot, ImageRefPoolSnapshot secondSnapshot)Computes difference between two snapshots.static voidenableDetailedProfiling()After the function is called, ImageRefs will store additional information, such as source from which they were created.protected voidfinalize()static ImageRefPoolSnapshotmakeSnapshot()Returns a snapshot of all alive ImageRefs.
-
-
-
Method Detail
-
makeSnapshot
public static ImageRefPoolSnapshot makeSnapshot()
Returns a snapshot of all alive ImageRefs. The snapshot contains a list of ImageRefs with information such as in-memory size. If detailed profiling is enabled (by calling enableDetailedProfiling beforehand), the profile will contain additional information such as the source from which each ImageRef has been created.- Returns:
- The snapshot of all alive ImageRefs.
-
enableDetailedProfiling
public static void enableDetailedProfiling()
After the function is called, ImageRefs will store additional information, such as source from which they were created. This information may be important when trying to understand a profile. This function must be called BEFORE the first ImageRef is created, otherwise details may be lost.
-
diff
public static ImageRefPoolSnapshotsDiff diff(ImageRefPoolSnapshot firstSnapshot, ImageRefPoolSnapshot secondSnapshot)
Computes difference between two snapshots. To confirm that a particular operation doesn't leak, take a snapshot before and after the operation, and check that the diff doesn't contain any unexpected new ImageRefs.- Parameters:
firstSnapshot- Snapshot that was taken earliersecondSnapshot- Snapshot that was taken later- Returns:
- Difference between two snapshots
-
close
public void close()
Closes native resources held by the object.- Specified by:
closein interfacejava.lang.AutoCloseable
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-