TagStudioDev / TagStudio

A User-Focused Photo & File Management System
https://docs.tagstud.io/
GNU General Public License v3.0
5.2k stars 372 forks source link

Memory leak on macOS #208

Open benorei opened 5 months ago

benorei commented 5 months ago

I installed tag studio on my laptop, played around for a bit, then I closed my laptop and when I came back a few hours later, my computer had run out of memory because tag studio was trying to use 114 GB of memory.

Screenshot 2024-05-23 at 1 43 50 AM
CyanVoxel commented 5 months ago

Well this doesn't look very good... Could I get some more build/system information from you?

xarvex commented 4 months ago

Hi @benorei, can we get the information asked about so we can explore what's going on? As well, is this something you've encountered again at any point?

benorei commented 4 months ago

Yes, sorry. I don't know what version - I have since uninstalled. It was the latest version at whatever day I made the post. I downloaded it from Github, and it would be macos_aarch64. macOS Version - Sonoma 14.5 CPU model - Apple M2 Pro RAM amount - 32 GB Last thing I did in the program - Load a large amount of images into the viewer

yedpodtrzitko commented 3 months ago

While working on the sql backend, I most likely stumbled upon where the memleak is happening. QtDriver.frame_dict is accumulating data with each library search and never clearing them.

this can be reproduced by printing memory usage of the object here:

https://github.com/TagStudioDev/TagStudio/blob/ce87b11fbd642e688f0856e055fb77257eff15c1/tagstudio/src/qt/ts_qt.py#L1375

install memory analyzer

$ pip install pympler

add into the code:

from pympler import asizeof
print(asizeof.asizeof(self.frame_dict))

now with each new search you will see that the memory size of frame_dict is increasing