本文整理匯總了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);
}