-
-
Notifications
You must be signed in to change notification settings - Fork 670
Is there any way to get the callback of the AssemblyScipt object being destructor? #2048
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
Comments
As mentioned by #383 |
There is a rough mechanism in place that is meant as the internal stepping stone to eventually implement assemblyscript/tests/compiler/rt/finalize.ts Lines 1 to 13 in 454529d
|
I found a problem, the ptr changes every time after resize how to solve this problem? |
From the mention of "resize" I assume that these are the backing buffers of the respective arrays. When resized, a new backing buffer is allocated and the old one is left for the GC. The array object itself remains if it is still referenced, it's just the buffers. |
After memory.grow, I can find the object through changetype in the __finalize function, and then call the object's destructor function
In this way, I find that sometimes an exception is thrown |
Not every import { OBJECT, TOTAL_OVERHEAD } from "rt/common";
@global function __finalize(ptr: usize): void {
var obj = changetype<OBJECT>(ptr - TOTAL_OVERHEAD)
if (obj.rtId == idof<Object>()) {
...
}
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions! |
My requirement is this, AssemblyScirpt compiled by Wasm will bridge to the new C++ objects, so I need to notify C++ to release the objects created by C++ when the AssemblyScirpt object is released.
The text was updated successfully, but these errors were encountered: