本文整理汇总了Java中com.sun.jna.Native.malloc方法的典型用法代码示例。如果您正苦于以下问题:Java Native.malloc方法的具体用法?Java Native.malloc怎么用?Java Native.malloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.Native
的用法示例。
在下文中一共展示了Native.malloc方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allocate
import com.sun.jna.Native; //导入方法依赖的package包/类
public static long allocate(long size)
{
long sizeInMb = size/1048576;
long totalSizeInMb = ALLOCATED_SIZE.addAndGet(size)/1048576;
LOGGER.info("Allocating off-heap memory block of " + sizeInMb +
"Mb and total allocated off-heap memory size is " + totalSizeInMb + "Mb");
long retAddr = Native.malloc(size);
memTracker.put(retAddr, size);
return retAddr;
}
示例2: memory_malloc_jna
import com.sun.jna.Native; //导入方法依赖的package包/类
@Benchmark
public void memory_malloc_jna() {
long native_p = Native.malloc(100);
ByteSlice buffer = ByteSlice.wrap(MemoryUtil.getByteBuffer(native_p, 100, true));
for (int i = 0; i < 100; i++) {
buffer.put(i, (byte) i);
}
//Native.free(native_p);
}
示例3: memory_malloc_jna2
import com.sun.jna.Native; //导入方法依赖的package包/类
@Benchmark
public void memory_malloc_jna2() {
long native_p = Native.malloc(100);
ByteSlice buffer = ByteSlice.wrap(MemoryUtil.getByteBuffer(native_p, 100, true));
for (int i = 0; i < 100; i++) {
buffer.put(i, (byte) i);
}
Pointer.createConstant(native_p);
//Native.free(native_p);
}
示例4: memory_malloc_jna3
import com.sun.jna.Native; //导入方法依赖的package包/类
@Benchmark
public void memory_malloc_jna3() {
long native_p = Native.malloc(100);
ByteSlice buffer = ByteSlice.wrap(MemoryUtil.getByteBuffer(native_p, 100, true));
for (int i = 0; i < 100; i++) {
buffer.put(i, (byte) i);
}
buffer.asPointer();
//Native.free(native_p);
}
示例5: memory_get_set_pointer
import com.sun.jna.Native; //导入方法依赖的package包/类
@Benchmark
public void memory_get_set_pointer() {
long p = Native.malloc(1000);
Pointer pointer = new Pointer(p);
pointer.setByte(10, (byte) 10);
byte b = pointer.getByte(10);
Native.free(p);
}
示例6: memory_get_set_directbytebuffer
import com.sun.jna.Native; //导入方法依赖的package包/类
@Benchmark
public void memory_get_set_directbytebuffer() {
long p = Native.malloc(1000);
ByteSlice slice = ByteSlice.fromAddress(p, 1000, false);
slice.put(10, (byte) 10);
byte b = slice.get(10);
Native.free(p);
}
示例7: MemoryBuffer
import com.sun.jna.Native; //导入方法依赖的package包/类
public MemoryBuffer(int size) {
super(Native.malloc(size));
this.size = size;
}
示例8: allocate
import com.sun.jna.Native; //导入方法依赖的package包/类
public static long allocate(long size) {
return Native.malloc(size);
}
示例9: memory_malloc_free_jna
import com.sun.jna.Native; //导入方法依赖的package包/类
@Benchmark
public void memory_malloc_free_jna() {
long p = Native.malloc(1000);
Native.free(p);
}