AutomaticComponentToolkit
AutomaticComponentToolkit copied to clipboard
[cgo] unloadLibrary is never called
We would need to call unload library with the wrapper destructor, but I am a bit helpless how this works. @qmuntal: Is there a chance you can take a look at this?
I don´t think it make sense to add the auto-release capability to the wrapper. It clearly a resource loaded by the user, therefore it should be unloaded by the user, same as when opening/closing files or http requests.
I would just add a Unload
method to the Wrapper
struct that performs the unloading.
I see, thank you for the feedback! But does that mean the unload will leak memory if the wrapper goes out of scope?
But does that mean the unload will leak memory if the wrapper goes out of scope?
Yes, unless the user calls unload
before the wrapper goes out of scope. defer
is very helpful in this scenarios:
lib := act.LoadLibrary("C:/foo.dll")
defer lib.Unload() // lib will be automatically released when going out of scope