< prev index next >

openjfx9/modules/javafx.graphics/src/main/java/com/sun/marlin/OffHeapArray.java

Print this page

        

*** 21,58 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package sun.java2d.marlin; ! import static sun.java2d.marlin.MarlinConst.LOG_UNSAFE_MALLOC; import jdk.internal.misc.Unsafe; - import jdk.internal.ref.CleanerFactory; /** * * @author bourgesl */ ! final class OffHeapArray { // unsafe reference ! static final Unsafe UNSAFE; // size of int / float static final int SIZE_INT; static { UNSAFE = Unsafe.getUnsafe(); SIZE_INT = Unsafe.ARRAY_INT_INDEX_SCALE; } /* members */ ! long address; long length; int used; ! OffHeapArray(final Object parent, final long len) { // note: may throw OOME: this.address = UNSAFE.allocateMemory(len); this.length = len; this.used = 0; if (LOG_UNSAFE_MALLOC) { --- 21,57 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.marlin; ! import static com.sun.marlin.MarlinConst.LOG_UNSAFE_MALLOC; import jdk.internal.misc.Unsafe; /** * * @author bourgesl */ ! public final class OffHeapArray { // unsafe reference ! public static final Unsafe UNSAFE; // size of int / float static final int SIZE_INT; static { UNSAFE = Unsafe.getUnsafe(); SIZE_INT = Unsafe.ARRAY_INT_INDEX_SCALE; } /* members */ ! public long address; long length; int used; ! public OffHeapArray(final Object parent, final long len) { // note: may throw OOME: this.address = UNSAFE.allocateMemory(len); this.length = len; this.used = 0; if (LOG_UNSAFE_MALLOC) {
*** 60,70 **** + ": OffHeapArray.allocateMemory = " + len + " to addr = " + this.address); } // Register a cleaning function to ensure freeing off-heap memory: ! CleanerFactory.cleaner().register(parent, () -> this.free()); } /* * As realloc may change the address, updating address is MANDATORY * @param len new array length --- 59,69 ---- + ": OffHeapArray.allocateMemory = " + len + " to addr = " + this.address); } // Register a cleaning function to ensure freeing off-heap memory: ! MarlinUtils.getCleaner().register(parent, () -> this.free()); } /* * As realloc may change the address, updating address is MANDATORY * @param len new array length
< prev index next >