Memory leak

Issue #326 open
Olivier Croquette created an issue

I am experiencing memory leaks, just by cycling RAF files using F3 and F4, for instance:

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user       81445 12.1 41.5 45816200 13291456 ?   Sl   21:52  10:26 /tmp/tmp.FTni1LWrgh-ART/ART/ART.bin
user       81445 14.4 50.9 45414792 16303632 ?   Sl   21:52  12:33 /tmp/tmp.FTni1LWrgh-ART/ART/ART.bin
user       81445 18.5 53.9 45496712 17270972 ?   Sl   21:52  16:29 /tmp/tmp.FTni1LWrgh-ART/ART/ART.bin
user       81445 19.4 58.2 46602632 18660848 ?   Sl   21:52  17:22 /tmp/tmp.FTni1LWrgh-ART/ART/ART.bin

A few pictures rendered separate every line.

I use ART 1.21.3 from the download area.

Comments (11)

  1. Olivier Croquette reporter

    Is there a way to get more information about the memory usage, like the kind of data?

  2. agriggio repo owner

    Hi,

    you can try using mi-malloc env vars to get more info, though I don’t know how useful they could be.

    I guess your best bet would be to use a debug build and test with the google heap profiler or address sanitizer.

    P.S: I don’t know how the appimage was built or where it comes from btw

  3. Olivier Croquette reporter

    Thanks for the quick reply, I will try that.

    The version I use is the one from the download area, it is not an appimage, sorry. Here is the md5 of the main binary:

    86101c8fceecc7804f1af6020d9ceae6  ART.bin
    

  4. Olivier Croquette reporter

    MIMALLOC_VERBOSE does not display anything useful, but MIMALLOC_SHOW_STATS shows this:

    heap stats:    peak      total      freed    current       unit      count   
      reserved:   40.1 GiB   99.3 GiB   60.4 GiB   38.9 GiB                        not all freed!
     committed:   14.7 GiB   77.8 GiB   63.8 GiB   13.9 GiB                        not all freed!
         reset:      0          0          0          0                            ok
       touched:  299.7 MiB  419.5 MiB  105.7 GiB -105.3 GiB                        ok
      segments:    3.5 Ki     4.7 Ki     4.7 Ki       8                            not all freed!
    -abandoned:    796        1.5 Ki     1.4 Ki      62                            not all freed!
       -cached:      0          0          0          0                            ok
         pages:      0          0       58.7 Ki   -58.7 Ki                         ok
    -abandoned:    1.2 Ki     2.1 Ki     1.9 Ki     229                            not all freed!
     -extended:      0    
     -noretire:      0    
         mmaps:      0    
       commits:    2.9 Ki 
       threads:    329        3.0 Ki     5.2 Ki    -2.2 Ki                         ok
      searches:     0.0 avg
    numa nodes:       1
       elapsed:     151.429 s
       process: user: 552.556 s, system: 47.331 s, faults: 68, rss: 10.1 GiB, commit: 14.7 GiB
    

  5. agriggio repo owner

    Unfortunately, this doesn’t tell us much I’m afraid…

    FWIW, when I run with AddressSanitizer I see no obvious leak (only some global vars that are not deallocated, but nothing to be worried about).

    To be clear, I’m not saying that everything is fine, but that so far we don’t have enough info to pinpoint the possible issues…

    What modules are you using in your experiment? Can you share one of the sidecars?

  6. Olivier Croquette reporter

    I found a subset of 3 files that trigger a memory leak when cycling through them. I put them in the same shared folder as last time (gmail). Hopefully you can reproduce it on your side. The jumps in the memory consumption are not as big as I expected, so maybe there is more than one leak.

  7. agriggio repo owner

    I played a little bit with the files, but still don’t see anything major. FWIW here’s the output of AddressSanitizer:

    =================================================================
    ==841665==ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 15360 byte(s) in 24 object(s) allocated from:
        #0 0x7f813c70dc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
        #1 0x7f8138b6b3a0  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x213a0)
    
    Direct leak of 7168 byte(s) in 28 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f8138b6b2f4  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x212f4)
    
    Direct leak of 288 byte(s) in 9 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x7f8139f7aebc in LibRaw::open_buffer(void const*, unsigned long) (/opt/libraw/lib/libraw_r.so.24+0xc3ebc)
    
    Direct leak of 96 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x55e637631155 in MyExpander::init() ../../rtgui/guiutils.cc:543
        #2 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #3 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #4 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #5 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #6 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Direct leak of 96 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x55e637631026 in MyExpander::init() ../../rtgui/guiutils.cc:542
        #2 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #3 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #4 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #5 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #6 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Direct leak of 96 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x55e6376313b3 in MyExpander::init() ../../rtgui/guiutils.cc:545
        #2 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #3 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #4 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #5 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #6 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Direct leak of 96 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x55e637631284 in MyExpander::init() ../../rtgui/guiutils.cc:544
        #2 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #3 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #4 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #5 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #6 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Direct leak of 96 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x55e6376314d9 in MyExpander::init() ../../rtgui/guiutils.cc:546
        #2 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #3 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #4 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #5 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #6 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Direct leak of 48 byte(s) in 2 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f8138b55b79  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xbb79)
    
    Direct leak of 42 byte(s) in 2 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813b724e98 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57e98)
    
    Direct leak of 16 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813b724e98 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57e98)
        #2 0x11821da  (<unknown module>)
    
    Indirect leak of 47168 byte(s) in 1474 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f8138b5754f  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd54f)
    
    Indirect leak of 22633 byte(s) in 1744 object(s) allocated from:
        #0 0x7f813c6963ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
        #1 0x7f8138b6ab64 in FcValueSave (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20b64)
    
    Indirect leak of 15648 byte(s) in 489 object(s) allocated from:
        #0 0x7f813c70da06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
        #1 0x7f8138b6b93c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2193c)
    
    Indirect leak of 8512 byte(s) in 266 object(s) allocated from:
        #0 0x7f813c70da06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
        #1 0x7f8138b6ae0f  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20e0f)
    
    Indirect leak of 2304 byte(s) in 72 object(s) allocated from:
        #0 0x7f813c70da06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
        #1 0x7f8138b6acae  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20cae)
    
    Indirect leak of 1296 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813ba8f697  (/lib/x86_64-linux-gnu/libcairo.so.2+0xb6697)
    
    Indirect leak of 576 byte(s) in 12 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f8138b64e11 in FcLangSetCreate (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1ae11)
    
    Indirect leak of 557 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813ba1d0f4  (/lib/x86_64-linux-gnu/libcairo.so.2+0x440f4)
    
    Indirect leak of 392 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813ba13588  (/lib/x86_64-linux-gnu/libcairo.so.2+0x3a588)
    
    Indirect leak of 256 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813896791f  (/lib/x86_64-linux-gnu/libpixman-1.so.0+0x5191f)
    
    Indirect leak of 40 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813ba50bd9 in cairo_surface_set_mime_data (/lib/x86_64-linux-gnu/libcairo.so.2+0x77bd9)
    
    Indirect leak of 36 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
        #1 0x7f813b724e98 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57e98)
    
    Indirect leak of 24 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70dc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
        #1 0x7f813b9efc47  (/lib/x86_64-linux-gnu/libcairo.so.2+0x16c47)
    
    Indirect leak of 16 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x7f813b0f211c in Cairo::ImageSurface::create_from_png(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (/lib/x86_64-linux-gnu/libcairomm-1.0.so.1+0x1e11c)
        #2 0x55e637a35c7a in RTImage::createImgSurfFromFile(Glib::ustring const&) ../../rtgui/rtimage.cc:208
        #3 0x55e637a34be6 in RTImage::changeImage(Glib::ustring const&) ../../rtgui/rtimage.cc:135
        #4 0x55e637a34604 in RTImage::setImage(Glib::ustring const&, Glib::ustring const&) ../../rtgui/rtimage.cc:103
        #5 0x55e637a32be4 in RTImage::RTImage(Glib::ustring const&, Glib::ustring const&) ../../rtgui/rtimage.cc:55
        #6 0x55e6376314ee in MyExpander::init() ../../rtgui/guiutils.cc:546
        #7 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #8 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #9 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #10 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #11 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Indirect leak of 16 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x7f813b0f211c in Cairo::ImageSurface::create_from_png(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (/lib/x86_64-linux-gnu/libcairomm-1.0.so.1+0x1e11c)
        #2 0x55e637a35c7a in RTImage::createImgSurfFromFile(Glib::ustring const&) ../../rtgui/rtimage.cc:208
        #3 0x55e637a34be6 in RTImage::changeImage(Glib::ustring const&) ../../rtgui/rtimage.cc:135
        #4 0x55e637a34604 in RTImage::setImage(Glib::ustring const&, Glib::ustring const&) ../../rtgui/rtimage.cc:103
        #5 0x55e637a32be4 in RTImage::RTImage(Glib::ustring const&, Glib::ustring const&) ../../rtgui/rtimage.cc:55
        #6 0x55e63763116a in MyExpander::init() ../../rtgui/guiutils.cc:543
        #7 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #8 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #9 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #10 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #11 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Indirect leak of 16 byte(s) in 1 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x7f813b0f211c in Cairo::ImageSurface::create_from_png(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (/lib/x86_64-linux-gnu/libcairomm-1.0.so.1+0x1e11c)
        #2 0x55e637a35c7a in RTImage::createImgSurfFromFile(Glib::ustring const&) ../../rtgui/rtimage.cc:208
        #3 0x55e637a34be6 in RTImage::changeImage(Glib::ustring const&) ../../rtgui/rtimage.cc:135
        #4 0x55e637a34604 in RTImage::setImage(Glib::ustring const&, Glib::ustring const&) ../../rtgui/rtimage.cc:103
        #5 0x55e637a32be4 in RTImage::RTImage(Glib::ustring const&, Glib::ustring const&) ../../rtgui/rtimage.cc:55
        #6 0x55e63763103b in MyExpander::init() ../../rtgui/guiutils.cc:542
        #7 0x55e637a4eaf9 in RTWindow::RTWindow() ../../rtgui/rtwindow.cc:420
        #8 0x55e6377e0b80 in create_rt_window ../../rtgui/main.cc:274
        #9 0x55e6377e15f9 in create_window ../../rtgui/main.cc:312
        #10 0x55e6377e250a in on_command_line ../../rtgui/main.cc:372
        #11 0x7f813b308156 in Gio::Application_Class::command_line_callback(_GApplication*, _GApplicationCommandLine*) (/lib/x86_64-linux-gnu/libgiomm-2.4.so.1+0xeb156)
    
    Indirect leak of 12 byte(s) in 3 object(s) allocated from:
        #0 0x7f813c70f587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x7f813b0f2146 in Cairo::ImageSurface::create_from_png(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (/lib/x86_64-linux-gnu/libcairomm-1.0.so.1+0x1e146)
    
    SUMMARY: AddressSanitizer: 122904 byte(s) leaked in 4141 allocation(s).
    

  8. Olivier Croquette reporter

    OK thanks for trying!

    Did you test with the state of 1.21.3, or maybe a newer version where the leak does not occur?

    I can try to troubleshoot on my side, but then I will need a debug version I guess. Should I build it myself? Is there any documentation for that?

  9. agriggio repo owner

    I tested version 1.22, but there should be no difference with 1.21.3

    You set CMAKE_BUILD_TYPE=Debug in CMakeCache.txt for a debug build, and WITH_SAN=address if you want to enable address sanitizer

    HTH

  10. Log in to comment