-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to manage memory when interacting with AssemblyScript? #245
Comments
Another approach is to use AssemblyScript's exported memory alloc/free and call them in native functions. I'd like to know which one can be the best practise. |
hey @xujuntwt95329 Have you been able to use as-wasi ? I ran into this issue jedisct1/as-wasi#32 Woud really appreciate some help. 🙏 |
Could you please provide some test cases ? For example your test code, your environment string. I've tried the example code from import { Console, Environ } from "../node_modules/as-wasi/assembly";
let env = new Environ();
let home = env.get("HOME")!;
Console.log(home); iwasm --env="HOME=test" as-wasi.wasm and I got this in my console test Seems it works well |
you are right! it seems to work. must have been an error on my part. Thanks a lot! |
…nal/feature Merge internal/feature into dev/simd
I'm trying to write wasm applications by AssemblyScript with native function calls.
Since AssemblyScript builds with a runtime, it handles memory and lifetime.
Then is it safe to use
wasm_runtime_module_malloc
in native functions, while allocating objects in AssemblyScript with its__alloc
api.For example, a native function called
getValue
to get value of a string key from hashmap.The function declaration can be defined as below.
For the first declartion, it may fail when length is not enough.
But for the second declaration, the code use
wasm_runtime_module_malloc
to dynamic allocate memory forvalue
based on its size.Is it safe to use? Is the allocator aware of memory usage in AssemblyScript runtime?
If not, what's the best practise for memory management between wamr and wasm?
The text was updated successfully, but these errors were encountered: