当前位置: 首页>>代码示例>>Java>>正文


Java GridUnsafe.freeMemory方法代码示例

本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.freeMemory方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.freeMemory方法的具体用法?Java GridUnsafe.freeMemory怎么用?Java GridUnsafe.freeMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.internal.util.GridUnsafe的用法示例。


在下文中一共展示了GridUnsafe.freeMemory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: releasePool

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * Release pool memory.
 *
 * @param poolPtr Pool pointer.
 */
public static void releasePool(long poolPtr) {
    // Clean predefined memory chunks.
    long mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_1);

    if (mem != 0)
        GridUnsafe.freeMemory(mem);

    mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_2);

    if (mem != 0)
        GridUnsafe.freeMemory(mem);

    mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_3);

    if (mem != 0)
        GridUnsafe.freeMemory(mem);

    // Clean pool chunk.
    GridUnsafe.freeMemory(poolPtr);
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:PlatformMemoryUtils.java

示例2: shutdown

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void shutdown() {
    if (regions != null) {
        for (Iterator<DirectMemoryRegion> it = regions.iterator(); it.hasNext(); ) {
            DirectMemoryRegion chunk = it.next();

            GridUnsafe.freeMemory(chunk.address());

            // Safety.
            it.remove();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:UnsafeMemoryProvider.java

示例3: release0

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * Internal release procedure. Decreases size of corresponding counter.
 *
 * @param ptr Address of memory block to deallocate.
 * @param size Size of allocated block.
 * @param cnt Counter to update.
 */
private void release0(long ptr, long size, AtomicLong cnt) {
    if (ptr != 0) {
        if (SAFE_RELEASE)
            fill(ptr, size, (byte)0xAB);

        GridUnsafe.freeMemory(ptr);

        cnt.addAndGet(-size);

        if (lsnr != null)
            lsnr.onEvent(RELEASE);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:GridUnsafeMemory.java

示例4: afterTest

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
    super.afterTest();

    // Cleanup allocated objects.
    for (Long ptr : ptrs)
        GridUnsafe.freeMemory(ptr);

    ptrs.clear();
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:BinaryFooterOffsetsOffheapSelfTest.java

示例5: afterTest

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
    for (Long ptr : ptrs)
        GridUnsafe.freeMemory(ptr);

    super.afterTest();
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:BinarySerialiedFieldComparatorSelfTest.java

示例6: destroy

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void destroy() {
    GridUnsafe.freeMemory(ptr);
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:5,代码来源:DenseOffHeapMatrixStorage.java

示例7: stop

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void stop() throws IgniteException {
    GridUnsafe.freeMemory(trackingArrPtr);
}
 
开发者ID:apache,项目名称:ignite,代码行数:5,代码来源:RandomLruPageEvictionTracker.java

示例8: testOffheapBinary

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testOffheapBinary() throws Exception {
    BinaryObjectBuilder builder = builder("Class");

    builder.setField("i", 111);
    builder.setField("f", 111.111f);
    builder.setField("iArr", new int[] {1, 2, 3});
    builder.setField("obj", new Key(1));
    builder.setField("col", Arrays.asList(new Value(1), new Value(2)), Collection.class);

    BinaryObject po = builder.build();

    byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);

    long ptr = GridUnsafe.allocateMemory(arr.length + 5);

    try {
        long ptr0 = ptr;

        GridUnsafe.putBoolean(null, ptr0++, false);

        int len = arr.length;

        if (BIG_ENDIAN)
            GridUnsafe.putIntLE(ptr0, len);
        else
            GridUnsafe.putInt(ptr0, len);

        GridUnsafe.copyHeapOffheap(arr, GridUnsafe.BYTE_ARR_OFF, ptr0 + 4, arr.length);

        BinaryObject offheapObj = (BinaryObject)
            ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);

        assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());

        assertEquals(expectedHashCode("Class"), offheapObj.type().typeId());
        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), offheapObj.hashCode());

        assertEquals(111, offheapObj.<Integer>field("i").intValue());
        assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
        assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
        assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);

        List<BinaryObject> list = offheapObj.field("col");

        assertEquals(2, list.size());

        assertEquals(1, list.get(0).<Value>deserialize().i);
        assertEquals(2, list.get(1).<Value>deserialize().i);

        assertEquals(po, offheapObj);
        assertEquals(offheapObj, po);
    }
    finally {
        GridUnsafe.freeMemory(ptr);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:60,代码来源:BinaryObjectBuilderDefaultMappersSelfTest.java

示例9: testUnsafe

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * Test unsafe vs. new.
 */
@SuppressWarnings("JavaDoc")
private static void testUnsafe() throws InterruptedException {
    X.println("Testing unsafe...");

    int MAX = 1000000;

    long[] addrs = new long[MAX];

    System.gc();

    GridTimer t = new GridTimer("unsafe");

    int mem = 1024;

    for (int i = 0; i < MAX; i++) {
        addrs[i] = GridUnsafe.allocateMemory(mem);

        GridUnsafe.putByte(addrs[i] + RAND.nextInt(mem), (byte)RAND.nextInt(mem));

        v = GridUnsafe.getByte(addrs[i] + RAND.nextInt(mem));
    }

    X.println("Unsafe [time=" + t.stop() + "ms, v=" + v + ']');

    Thread.sleep(5000L);

    for (long l : addrs)
        GridUnsafe.freeMemory(l);
}
 
开发者ID:apache,项目名称:ignite,代码行数:33,代码来源:GridBasicPerformanceTest.java

示例10: release

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * Release memory.
 *
 * @param ptr Pointer.
 */
protected void release(long ptr) {
    GridUnsafe.freeMemory(ptr);
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:BinaryOffheapOutputStream.java


注:本文中的org.apache.ignite.internal.util.GridUnsafe.freeMemory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。