@yuuang/ffi-rs-darwin-x64
Advanced tools
Comparing version 1.0.77 to 1.0.78
{ | ||
"name": "@yuuang/ffi-rs-darwin-x64", | ||
"version": "1.0.77", | ||
"version": "1.0.78", | ||
"os": [ | ||
@@ -5,0 +5,0 @@ "darwin" |
@@ -19,3 +19,3 @@ # ffi-rs | ||
## features | ||
## Features | ||
@@ -51,3 +51,3 @@ - High performance ✨ | ||
## changelog | ||
## Changelog | ||
@@ -715,2 +715,25 @@ See [CHANGELOG.md](./CHANGELOG.md) | ||
## Memory Management | ||
It's important to free the memory allocations during a single ffi call prevent memory leak. | ||
What kinds of data memory are allocated in this? | ||
- call parameters in Rust environment which are allocated in the heap like `String` | ||
- return value which in C environment which are allocated in the heap like `char*` | ||
At default, `ffi-rs` will free all of memory both call parameters and return value(except functionConstructor). | ||
In some cases, the called c function also free memory has been allocated after ffi-call will cause repeated release error. | ||
For avoid this error, there are two ways to prevent `ffi-rs` free memory automatically | ||
- set `freeResultMemory: false` when call `load` method | ||
If you set freeResultMemory to false, `ffi-rs` will not release the return result memory which was allocated in c environment | ||
- Use `DataType.External` as paramsType or retType | ||
If developers use `DataType.External` as paramsType or retType, please use `freePointer` to release the memory of pointer when this memory is no longer in use. ref [test.ts](./test.ts#170) | ||
## runInNewThread | ||
@@ -717,0 +740,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
655890
757