TagStudio icon indicating copy to clipboard operation
TagStudio copied to clipboard

Memory leak on macOS

Open benorei opened this issue 1 year ago • 4 comments

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

benorei avatar May 23 '24 08:05 benorei

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

  • TagStudio Version + Build Type (Git, macos_x86_64, macos_aarch64)
  • macOS Version
  • CPU model
  • RAM amount
  • What was the last thing you did in the program?

CyanVoxel avatar May 23 '24 21:05 CyanVoxel

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?

xarvex avatar Jun 11 '24 18:06 xarvex

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

benorei avatar Jun 29 '24 21:06 benorei

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

yedpodtrzitko avatar Jul 23 '24 05:07 yedpodtrzitko