use of org.apache.ignite.internal.mem.UnsafeChunk in project ignite by apache.
the class UnsafeMemoryProvider method nextRegion.
/**
* {@inheritDoc}
*/
@Override
public DirectMemoryRegion nextRegion() {
if (regions.size() == sizes.length)
return null;
long chunkSize = sizes[regions.size()];
long ptr;
try {
ptr = GridUnsafe.allocateMemory(chunkSize);
} catch (IllegalArgumentException e) {
String msg = "Failed to allocate next memory chunk: " + U.readableSize(chunkSize, true) + ". Check if chunkSize is too large and 32-bit JVM is used.";
if (regions.size() == 0)
throw new IgniteException(msg, e);
U.error(log, msg);
return null;
}
if (ptr <= 0) {
U.error(log, "Failed to allocate next memory chunk: " + U.readableSize(chunkSize, true));
return null;
}
DirectMemoryRegion region = new UnsafeChunk(ptr, chunkSize);
regions.add(region);
return region;
}
Aggregations