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
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
ConstructorsConstructorDescriptionDefaults 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
Methods inherited from class de.redsix.pdfcompare.AbstractCompareResultWithSwap
addPage, finalize, hasImages, writeTo, writeToMethods 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, setEnvironmentMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.redsix.pdfcompare.ResultCollector
done
-
Constructor Details
-
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 Details
-
needToSwap
protected boolean needToSwap()- Specified by:
needToSwapin classAbstractCompareResultWithSwap
-
afterSwap
protected void afterSwap()- Overrides:
afterSwapin classAbstractCompareResultWithSwap
-