Memory leak after rendering images on html


#1

Hello community, I have an app on top on Electron: Gala and everything was ok but when the user started to scroll I’m loading more and more images, and I started to notice on every new page that I load more images, electron memory grow up like crazy. I tried to remove the image object if it’s not visible but that didn’t help at all.

Somebody know a way to force to clean/clear the memory?

Thanks!
Gonzalo


#2

Because Electron uses chromium/chrome for rendering you have a Memory Leak in Chrome, not in Electron.

But you can solve that :wink:

JavaScript has a automatic “Garbage Collection”. It cleans the memory on its own, if it can.
For this have to unlink you Images/Objects… from anywhere. DOM, EventListeners! & vars.
Then chrome will delete it from the memory for you.

You should google for “javascript garbage collection” “javascript memory leak” and "chrome devtools memory leak"
The chrome devtools you have available in Electron are very helpfull to find the leak.

hope that helps