Search in sources :

Example 1 with UnsafeChunk

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;
}
Also used : UnsafeChunk(org.apache.ignite.internal.mem.UnsafeChunk) IgniteException(org.apache.ignite.IgniteException) DirectMemoryRegion(org.apache.ignite.internal.mem.DirectMemoryRegion)

Aggregations

IgniteException (org.apache.ignite.IgniteException)1 DirectMemoryRegion (org.apache.ignite.internal.mem.DirectMemoryRegion)1 UnsafeChunk (org.apache.ignite.internal.mem.UnsafeChunk)1