-
Notifications
You must be signed in to change notification settings - Fork 189
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
Can't add weak ref feature? #64
Comments
That wouldn't cover weak references, just finalization. In order to correctly implement weak references in go-lua, the Lua GC (or some variation of it) would have to be implemented. Right now, go-lua relies on the Go GC, which does not support weak references, to manage memory. Going back to finalizers, they're something that could be supported if the GC were implemented (via a metatable with a |
Please forgive me my poor English! ` type WeakRef struct { func NewWeakRef(v interface{}) WeakRef { func (w WeakRef) Get() (v interface{}) { convert Go pointer to uintptr which not prevent Go object from being collected by GC. Here runtime.SetFinalizer I think only provide a chance to notify us "oh, it has been collected". |
I heard that can use runtime.SetFinalizer function implement WEAK REF feature.
The text was updated successfully, but these errors were encountered: