public class MemoryUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
MemoryUtil.Callback<T>
Callback throwing IOException and returning some (image) object
for
tryUntilEnoughMemory(com.day.cq.dam.api.Asset, int, com.day.cq.dam.commons.util.MemoryUtil.Callback) |
Modifier and Type | Field and Description |
---|---|
static long |
MIN_CQ_MEMORY_REQUIREMENT
We assume about 100 megs as minimal cq requirement...
|
Constructor and Description |
---|
MemoryUtil() |
Modifier and Type | Method and Description |
---|---|
static long |
getExpectedImageMemory(Asset asset)
Calculates the expected image memory consumption.
|
static boolean |
hasEnoughMemory(Asset asset)
Checks if enough memory is available for the asset/image processing
Note: it works for images only!
|
static boolean |
hasEnoughSystemMemory(Asset asset)
Checks if the available max.
|
static long |
suggestMaxHeapSize(Asset asset)
Suggests the minimal max.
|
static <T> T |
tryUntilEnoughMemory(Asset asset,
int maxTrials,
MemoryUtil.Callback<T> callback)
Tries to execute the callback until no memory exception occurs anymore.
|
static <T> T |
tryUntilEnoughMemory(Asset asset,
MemoryUtil.Callback<T> callback)
Tries to execute the callback until no memory exception occurs anymore.
|
public static long MIN_CQ_MEMORY_REQUIREMENT
public static <T> T tryUntilEnoughMemory(Asset asset, MemoryUtil.Callback<T> callback)
null
will be returned.T
- return type (image object etc.)asset
- asset to load Java 2D image fromcallback
- method that actually loads an image involving Java 2D memory,
return value will be passed through and returned by this methodnull
if memory limits prevented loading within a certain number of trialspublic static <T> T tryUntilEnoughMemory(Asset asset, int maxTrials, MemoryUtil.Callback<T> callback)
null
will be returned.T
- return type (image object etc.)asset
- asset to load Java 2D image frommaxTrials
- maximum number of trials, must be > 0callback
- method that actually loads an image involving Java 2D memory,
return value will be passed through and returned by this methodnull
if memory limits prevented loading within a certain number of trialspublic static boolean hasEnoughSystemMemory(Asset asset)
asset
- asset to checktrue
either if the check succeeds or the check cannot
be performed (no image data available e.g. the asset is not an image)
otherwise false
public static long getExpectedImageMemory(Asset asset)
photoshop:ColorMode
or tiff:SamplesPerPixel
.
If this information can be derived from metadata then it is defaulted to 4.asset
- asset to check-1
in case the expected
memory cannot be calculatedpublic static boolean hasEnoughMemory(Asset asset)
asset
- asset to checktrue
either if the check succeeds or the check cannot
be performed (no image data available e.g. the asset is not an image)
otherwise false
public static long suggestMaxHeapSize(Asset asset)
asset
- asset to checkCopyright © 2010 - 2020 Adobe. All Rights Reserved