pop-os / cosmic-files

COSMIC file manager
GNU General Public License v3.0
113 stars 84 forks source link

[BUG?]: High memory consumption - spawn too many system threads for image/thumbnail decoding & leaking? #641

Open l-const opened 1 week ago

l-const commented 1 week ago

Cosmic-files version:

20f9292

Issue/Bug description:

Steps to reproduce:

Expected behavior:

Other notes:

using heaptrack: https://github.com/KDE/heaptrack

installed with :

dnf install heaptrack

executed:

heaptrack --pid ${pid of cosmic-files}

with initial on startup memory consumption of 48MB as seen from this:

screenshot-2024-11-04-21-17-30

reaching up to and excedding 300MB:

screenshot-2024-11-04-21-56-39

heaptrack overview:

screenshot-2024-11-04-21-29-27

screenshot-2024-11-04-21-44-31

it seems that no memory leak is happening but for the thumnail generation we create through tokio too manu system threads by calling the clone3 system call

screenshot-2024-11-04-22-02-32

Here is the zipped .zst file that i exported:

heaptrack.cosmic-files.31272.zip

l-const commented 1 week ago

Used top to find the number of threads from the process, there is a variable size of threads , starting with 31 and managed to get up to 43 but then again did go down to 31 again after inactivity, the worrying part is that i managed to reach 1.0 GB memory consumption:

executed:

top -H -p 6880

screenshot-2024-11-05-10-54-24 screenshot-2024-11-05-10-56-54

l-const commented 1 week ago

Update: 1) reached 1.2 GB 2) huge allocation fromcosmic_text::shape_fallback andshapeline::layout_to_buffer 3) actual leak in image::dynimage::DynamicImage::thumbnail::thumbnail_exact of 8.5 MB

screenshot-2024-11-05-12-28-47 screenshot-2024-11-05-12-35-53

heaptrack.cosmic-files.28551.zip

actually, cosmic_text seems to be leaking, reported 300MB :

screenshot-2024-11-05-12-53-25

heaptrack.cosmic-files.40307.zip

heaptrack stats:
    allocations:            9778375
    leaked allocations:     144634
    temporary allocations:  2224622
Heaptrack finished! Now run the following to investigate the data:

  heaptrack --analyze "/home/kostas/heaptrack.cosmic-files.40307.zst"
l-const commented 1 week ago

screenshot-2024-11-06-22-50-52

screenshot-2024-11-06-23-05-21

l-const commented 1 week ago

I recorded a small video going from 50MB to 350MB:

memory-leak-cosmic-files.webm