本文整理汇总了Java中com.sun.jna.Native.free方法的典型用法代码示例。如果您正苦于以下问题:Java Native.free方法的具体用法?Java Native.free怎么用?Java Native.free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.Native
的用法示例。
在下文中一共展示了Native.free方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: free
import com.sun.jna.Native; //导入方法依赖的package包/类
public static void free(long peer)
{
long sizeInBytes = memTracker.get(peer);
long totalSizeInBytes = ALLOCATED_SIZE.addAndGet(-1 * sizeInBytes);
if (totalSizeInBytes < 0) {
ALLOCATED_SIZE.set(0);
totalSizeInBytes = 0;
}
LOGGER.info("Freeing off-heap memory block of " + (sizeInBytes/1048576) +
"Mb and total allocated off-heap memory size is " + (totalSizeInBytes/1048576) + "Mb");
Native.free(peer);
memTracker.remove(peer);
}
示例2: validate
import com.sun.jna.Native; //导入方法依赖的package包/类
/**
* Validates if the expression instance is valid
* @return ValidationResult object
*/
public ValidationResult validate() {
PointerByReference info = new PointerByReference();
PointerByReference error = new PointerByReference();
int hsResult = HyperscanLibrary.INSTANCE.hs_expression_info(this.expression, Util.bitEnumSetToInt(this.flags), info, error);
String errorMessage = "";
boolean isValid = true;
if(hsResult != 0) {
isValid = false;
CompileErrorStruct errorStruct = new CompileErrorStruct(error.getValue());
errorMessage = errorStruct.message;
errorStruct.setAutoRead(false);
HyperscanLibrary.INSTANCE.hs_free_compile_error(errorStruct);
}
else {
Native.free(Pointer.nativeValue(info.getValue()));
}
return new ValidationResult(errorMessage, isValid);
}
示例3: 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);
}
示例4: 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);
}
示例5: free
import com.sun.jna.Native; //导入方法依赖的package包/类
public static void free(long addr) {
Native.free(addr);
}
示例6: 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);
}