Package de.redsix.pdfcompare
Class CompareResultWithMemoryOverflow
- java.lang.Object
-
- de.redsix.pdfcompare.CompareResultImpl
-
- de.redsix.pdfcompare.AbstractCompareResultWithSwap
-
- de.redsix.pdfcompare.CompareResultWithMemoryOverflow
-
- All Implemented Interfaces:
CompareResult,ResultCollector
public class CompareResultWithMemoryOverflow extends AbstractCompareResultWithSwap
This CompareResult monitors the memory the JVM consumes through Runtime.totalMemory() - Runtime.freeMemory() when a new page is added. When the consumed memory crosses a threshold, images are swapped to disk and removed from memory. The threshold defaults to 70% of Runtime.maxMemory() but at least 200MB, which worked for me. After swapping, a System.gc() is triggered.
-
-
Field Summary
-
Fields inherited from class de.redsix.pdfcompare.CompareResultImpl
diffImages, environment, hasDifferenceInExclusion, isEqual
-
-
Constructor Summary
Constructors Constructor Description CompareResultWithMemoryOverflow()Defaults to 70% of the available maxMemory reported by the JVM.CompareResultWithMemoryOverflow(long approximateMaxMemoryUsageInMegaBytes)Stores images to disk, when the used memory is higher than the given theshold in megabytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterSwap()protected booleanneedToSwap()-
Methods inherited from class de.redsix.pdfcompare.AbstractCompareResultWithSwap
addPage, finalize, hasImages, writeTo, writeTo
-
Methods inherited from class de.redsix.pdfcompare.CompareResultImpl
actualOnly, addImagesToDocument, addImagesToDocument, addPageToDocument, expectedOnly, getDifferences, getDifferencesJson, getNumberOfPages, getPageDiffsInPercent, getPagesWithDifferences, hasDifferenceInExclusion, hasOnlyActual, hasOnlyExpected, hasOnlyOneDoc, isEqual, isNotEqual, keepImages, noPagesFound, setEnvironment
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.redsix.pdfcompare.ResultCollector
done
-
-
-
-
Constructor Detail
-
CompareResultWithMemoryOverflow
public CompareResultWithMemoryOverflow()
Defaults to 70% of the available maxMemory reported by the JVM.
-
CompareResultWithMemoryOverflow
public CompareResultWithMemoryOverflow(long approximateMaxMemoryUsageInMegaBytes)
Stores images to disk, when the used memory is higher than the given theshold in megabytes.- Parameters:
approximateMaxMemoryUsageInMegaBytes- the maximum memory to use in megabytes
-
-
Method Detail
-
needToSwap
protected boolean needToSwap()
- Specified by:
needToSwapin classAbstractCompareResultWithSwap
-
afterSwap
protected void afterSwap()
- Overrides:
afterSwapin classAbstractCompareResultWithSwap
-
-