Darshan Hiranandani : Feature Request for Go Plugin Memory Management – Clearing Unused Memory?

Hi everyone,

I’m Darshan Hiranandani, working with Go plugins and need to load and unload them frequently. However, I’ve noticed that the memory used by the unloaded plugins isn’t being cleared, which can lead to memory issues over time.

Is there a way to manually clear the memory of old plugins after they’ve been unloaded? Or perhaps is this something that could be implemented as a feature within the Go plugin system?

Has anyone faced similar issues or found workarounds for efficient memory management when loading/unloading plugins in Go? Any tips or best practices for handling this?

Looking forward to hearing your thoughts and suggestions!

Thanks!
Regards
Darshan Hiranandani

It sounds like your plugin is not handling memory release inside. You should actively release the memory used inside the plugin.
If you can’t modify the plugin, you can try to start the plugin as a subprocess. When the subprocess ends, the corresponding memory will also be released.