本文整理汇总了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);
}
示例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();
}
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例6: destroy
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void destroy() {
GridUnsafe.freeMemory(ptr);
}
示例7: stop
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void stop() throws IgniteException {
GridUnsafe.freeMemory(trackingArrPtr);
}
示例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);
}
}
示例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);
}
示例10: release
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* Release memory.
*
* @param ptr Pointer.
*/
protected void release(long ptr) {
GridUnsafe.freeMemory(ptr);
}