/** * Create a new ByteBuffer of the specified size. * * @param size * required number of ints to store. * @return the new IntBuffer */ public static ByteBuffer createByteBuffer(int size) { ByteBuffer buf = allocator.allocate(size).order(ByteOrder.nativeOrder()); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Direct buffers are garbage collected by using a phantom reference and a * reference queue. Every once a while, the JVM checks the reference queue * and cleans the direct buffers. However, as this doesn't happen * immediately after discarding all references to a direct buffer, it's easy * to OutOfMemoryError yourself using direct buffers. **/ public static void destroyDirectBuffer(Buffer toBeDestroyed) { if (!isDirect(toBeDestroyed)) { return; } allocator.destroyDirectBuffer(toBeDestroyed); }
/** * Create a new FloatBuffer of the specified size. * * @param size * required number of floats to store. * @return the new FloatBuffer */ public static FloatBuffer createFloatBuffer(int size) { FloatBuffer buf = allocator.allocate(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Direct buffers are garbage collected by using a phantom reference and a * reference queue. Every once a while, the JVM checks the reference queue * and cleans the direct buffers. However, as this doesn't happen * immediately after discarding all references to a direct buffer, it's easy * to OutOfMemoryError yourself using direct buffers. **/ public static void destroyDirectBuffer(Buffer toBeDestroyed) { if (!isDirect(toBeDestroyed)) { return; } allocator.destroyDirectBuffer(toBeDestroyed); }
/** * Create a new IntBuffer of the specified size. * * @param size * required number of ints to store. * @return the new IntBuffer */ public static IntBuffer createIntBuffer(int size) { IntBuffer buf = allocator.allocate(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new ShortBuffer of the specified size. * * @param size * required number of shorts to store. * @return the new ShortBuffer */ public static ShortBuffer createShortBuffer(int size) { ShortBuffer buf = allocator.allocate(2 * size).order(ByteOrder.nativeOrder()).asShortBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new DoubleBuffer of the specified size. * * @param size * required number of double to store. * @return the new DoubleBuffer */ public static DoubleBuffer createDoubleBuffer(int size) { DoubleBuffer buf = allocator.allocate(8 * size).order(ByteOrder.nativeOrder()).asDoubleBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new ByteBuffer of the specified size. * * @param size * required number of ints to store. * @return the new IntBuffer */ public static ByteBuffer createByteBuffer(int size) { ByteBuffer buf = allocator.allocate(size).order(ByteOrder.nativeOrder()); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new DoubleBuffer of the specified size. * * @param size * required number of double to store. * @return the new DoubleBuffer */ public static DoubleBuffer createDoubleBuffer(int size) { DoubleBuffer buf = allocator.allocate(8 * size).order(ByteOrder.nativeOrder()).asDoubleBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new IntBuffer of the specified size. * * @param size * required number of ints to store. * @return the new IntBuffer */ public static IntBuffer createIntBuffer(int size) { IntBuffer buf = allocator.allocate(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new ShortBuffer of the specified size. * * @param size * required number of shorts to store. * @return the new ShortBuffer */ public static ShortBuffer createShortBuffer(int size) { ShortBuffer buf = allocator.allocate(2 * size).order(ByteOrder.nativeOrder()).asShortBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }
/** * Create a new FloatBuffer of the specified size. * * @param size * required number of floats to store. * @return the new FloatBuffer */ public static FloatBuffer createFloatBuffer(int size) { FloatBuffer buf = allocator.allocate(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer(); buf.clear(); onBufferAllocated(buf); return buf; }