Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak #661

Open
netikras opened this issue Mar 20, 2024 · 34 comments
Open

Possible memory leak #661

netikras opened this issue Mar 20, 2024 · 34 comments
Labels
bug Something isn't working

Comments

@netikras
Copy link

Brief summary of issue

Over time Shutter memory usage grows inadequately high

Steps to reproduce the issue

  1. Open shutter in tray mode
  2. use Shutter occasionally
  3. check memory usage after 3-4 weeks

It's not the first time I see Shutter among the top RAM consumers. Restarting it drops memory usage significantly. E.g. just now I was struggling with free memory and I found that Shutter was using ~2.6GB of RAM. After restarting it - it indexed the same the same 207 screenshots I have (70MB) and now the process only weights 169.348M. Over time I expect this number to slowly creep into gigs.

I wish I could provide anything more useful, anything to work with, but I don't know what info you may need nor how to capture it. The RAM leak will become apparent over time, so if I had instructions - perhaps I could capture some diag info for you.

Extra information, such as Shutter version, display server in use (Xorg or Wayland), operating system and ideas for how to solve:

0.99.2 Rev.1593

@netikras netikras added the bug Something isn't working label Mar 20, 2024
@Photon89
Copy link
Member

Thanks for your bug report! I will try to catch the leak(s) with Devel::Leak::Object, let's see, how this works out! You could also join the testing, if you have the resources. You'd need to install Devel::Leak::Object to do so though. Then just add

use Devel::Leak::Object qw{ GLOBAL_bless };

in the modules section (around line numbers 30-40 in /usr/bin/shutter). Then, when you launch Shutter from CLI and after a few weeks exit it, there will be output about leaks at the end of the output. After a very short run I got

Tracked objects by class:
	Class::Struct::Tie_ISA                   1
	Encode::utf8                             3
	Errno                                    1
	Gtk3::ImageView::Tool::Dragger           4
	Locale::gettext                          1
	Method::Generate::Accessor               3
	Method::Generate::Constructor            3
	Moo::HandleMoose::AuthorityHack          1
	Moo::HandleMoose::_TypeMap               1
	Net::DBus::Annotation                    4
	Number::Bytes::Human                     1
	POSIX::SigRt                             1
	Readonly::Scalar                         5
	Shutter::App::Autostart                  1
	Shutter::App::Common                     1
	Shutter::App::HelperFunctions            3
	Shutter::App::Menu                       1
	Shutter::App::ShutterNotification        1
	Shutter::App::SimpleDialogs              5
	Shutter::App::Toolbar                    1
	Shutter::Pixbuf::Load                    3
	Shutter::Pixbuf::Save                    1

But I assume that after a few weeks there will be entries with a high number of objects, so we can find the leak(s).

@netikras
Copy link
Author

netikras commented Apr 2, 2024

Alright, I'm joining the witch hunt!

$ ps aux | grep -E "^USER|shutter"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user1    38088  0.0  0.0      0     0 ?        Z     2022  72:49 [shutter] <defunct>
user1   550290  0.0  0.0      0     0 ?        Z     2023  42:11 [shutter] <defunct>
user1  1326863  0.0  0.0      0     0 ?        Z     2022  82:33 [shutter] <defunct>
user1  3015878  0.0  0.0      0     0 ?        Z     2023  46:06 [shutter] <defunct>
user1  3108262 54.9  0.3 2094728 237520 pts/10 Sl+  08:26   1:16 /usr/bin/perl /usr/bin/shutter
user1  3108263  0.0  0.0  10684   580 pts/10   S+   08:26   0:00 tee /tmp/shutter.log
user1 3109610  0.0  0.0  11580  2696 pts/34   S+   08:29   0:00 grep --color=auto -E ^USER|shutter
user1  3590463  0.0  0.0      0     0 ?        Z     2023  75:24 [shutter] <defunct>

(I wonder why so many zombies... Prolly unrelated to the memleak anyways :) )

Current RSS usage -- ~227M with 673 screenshots loaded

@Photon89
Copy link
Member

Photon89 commented Apr 2, 2024

I'm also surprised by the 54.5% CPU usage... Is it just a short peak, or is the CPU usage high for longer periods of time?

@netikras
Copy link
Author

netikras commented Apr 2, 2024

@Photon89 ps was captured moments after starting up the shutter. With this debug module enabled it took quite a while to start up. That's the reason behind the high CPU% in ps's output (and we know that ps is cumulative, so it's quite inert)

@netikras
Copy link
Author

netikras commented Jun 7, 2024

Finally...

Process RSS was 1GB

Tracked objects by class:
        Class::Struct::Tie_ISA                   1
        Encode::Internal                         1
        Encode::utf8                             3
        Errno                                    1
        Gtk3::ImageView::Tool::Dragger           794
        Gtk3::ImageView::Tool::Selector          62
        Locale::gettext                          1
        Net::DBus::Annotation                    4
        Number::Bytes::Human                     1
        POSIX::SigRt                             1
        Readonly::Scalar                         5
        Shutter::App::Autostart                  1
        Shutter::App::Common                     1
        Shutter::App::Directories                1
        Shutter::App::HelperFunctions            3
        Shutter::App::Menu                       1
        Shutter::App::ShutterNotification        1
        Shutter::App::SimpleDialogs              5
        Shutter::App::Toolbar                    1
        Shutter::Draw::DrawingTool               1
        Shutter::Pixbuf::Load                    3
        Shutter::Pixbuf::Save                    1
        Shutter::Screenshot::History             52
        Shutter::Screenshot::SelectorAdvanced    51
        Shutter::Screenshot::Workspace           1

@Photon89
Copy link
Member

Photon89 commented Jun 8, 2024

@DarthGandalf Looks like Gtk3::ImageView::Tool::Dragger is only used inside the editor (DrawingTool.pm). There is a DESTROY sub but it is commented out and not used. Maybe it should be restored and used on closing the editor?

@DarthGandalf
Copy link
Member

I don't understand why Dragger is created there at all, it doesn't seem to be used

@Photon89
Copy link
Member

Photon89 commented Jun 9, 2024

@netikras I have created a branch where the problematic object isn't being initialized: https://github.com/shutter-project/shutter/tree/debug-661 Could you test it and see if it fixes the issue for you? Just check out the branch or download it as an archive, then run bin/shutter. Thanks!

edit: You might need to install this new dependency if you have used v0.99.2 so far: https://metacpan.org/pod/Moo

@netikras
Copy link
Author

netikras commented Jun 14, 2024

Starting testing.

$ ps aux | head -1; ps aux | egrep '[.]/shutter'
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user1    1532888  1.0  0.5 1788660 375296 pts/152 Sl+ 08:43   1:19 /usr/bin/perl ./shutter

@Photon89
Copy link
Member

Are there any news on the memory consumption of the experimental branch?

@netikras
Copy link
Author

@Photon89 Hi!

I started it in a separate terminal and left it running. Only now, when you pinged me, I went to check and found that it was no longer running. Exit code is 0, but I can't recall any reason I would manually exit the app.
Shutter is currently running, but from $PATH rather than git dir, so I must've restarted it unconsciously.

In the terminal console I see lots of records at the end of execution (see below), IDK if they suggest an abrupt termination due to an error or whether they are normal

should I restart testing?

<...>
(shutter:1532888): Gtk-CRITICAL **: 17:18:55.305: gtk_drag_source_set_icon_pixbuf: assertion 'site != NULL' failed
GLib-GObject-WARNING **: value "0.000391" of type 'gfloat' is invalid or out of range for property 'zoom' of type 'gfloat' at /usr/share/perl5/Gtk3/ImageView.pm line 410.
	Gtk3::ImageView::_set_zoom(Gtk3::ImageView=HASH(0x5595fae5d338), 0.000391389432485323) called at /usr/share/perl5/Gtk3/ImageView.pm line 459
	Gtk3::ImageView::_set_zoom_with_center(Gtk3::ImageView=HASH(0x5595fae5d338), 0.000391389432485323, 1277.5, 269) called at /usr/share/perl5/Gtk3/ImageView.pm line 504
	Gtk3::ImageView::zoom_to_box(Gtk3::ImageView=HASH(0x5595fae5d338), HASH(0x5595fae5dd10)) called at /usr/share/perl5/Gtk3/ImageView.pm line 482
	Gtk3::ImageView::set_zoom_to_fit(Gtk3::ImageView=HASH(0x5595fae5d338), 1, 1) called at /usr/share/perl5/Gtk3/ImageView.pm line 542
	Gtk3::ImageView::set_fitting(Gtk3::ImageView=HASH(0x5595fae5d338), 1) called at ./shutter line 6573
	Shutter::App::fct_take_screenshot(Gtk3::ToolButton=HASH(0x5595efc0d208), "select", undef, undef) called at ./shutter line 3080
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
screenshot successfully saved to /home/user1/Paveikslai/Selection_024.png!
GLib-CRITICAL **: Source ID 329494 was not found when attempting to remove it at ./shutter line 7032.
 at ./shutter line 7030.
	Shutter::App::fct_show_status_message(1, "Selection_024.png saved") called at ./shutter line 6609
	Shutter::App::fct_take_screenshot(Gtk3::ToolButton=HASH(0x5595efc0d208), "select", undef, undef) called at ./shutter line 3080
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)
<...>
fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)
GLib-CRITICAL **: Source ID 331120 was not found when attempting to remove it at ./shutter line 7032.
 at ./shutter line 7030.
	Shutter::App::fct_show_status_message(1, "Selected images copied to clipboard") called at ./shutter line 5645
	Shutter::App::fct_clipboard(Gtk3::ImageMenuItem=HASH(0x5595ef6e9458), "image") called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

Gtk3::Gdk::Event=SCALAR(0x5595fae5fd88) was emitted by widget Gtk3::ApplicationWindow=HASH(0x5595ef4dccd0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)
<...>
Gtk3::StatusIcon=HASH(0x5595eab66da8) was emitted by widget Gtk3::StatusIcon=HASH(0x5595eab66da8)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

Gtk3::StatusIcon=HASH(0x5595fadad1a0) was emitted by widget Gtk3::StatusIcon=HASH(0x5595fadad1a0)

fct_update_tray_menu was called by Wnck::Screen=HASH(0x5595ef5351f0)

quit was emitted by widget Gtk3::ImageMenuItem=HASH(0x5595ef654a28)
GLib-CRITICAL **: Source ID 332183 was not found when attempting to remove it at ./shutter line 7032.
 at ./shutter line 7030.
	Shutter::App::fct_show_status_message(1, "Settings saved successfully!") called at ./shutter line 4686
	Shutter::App::fct_save_settings(undef) called at ./shutter line 3199
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595f98c8be8), "Dropbox", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/9ef6A6eBT_") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings(undef) called at ./shutter line 3199
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595f98c8be8), "Dropbox", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/9ef6A6eBT_") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings(undef) called at ./shutter line 3199
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
<...>
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595fae3f1d0), "ToileLibre", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/9ef6A6eBT_") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings(undef) called at ./shutter line 3199
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595fae3f1d0), "ToileLibre", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/9ef6A6eBT_") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings(undef) called at ./shutter line 3199
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595fae3f1d0), "ToileLibre", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadbcc60), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/9ef6A6eBT_") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings(undef) called at ./shutter line 3199
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
<...>
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595fae4fa70), "vgyme", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/oS025ODdTW") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings("*") called at ./shutter line 3200
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595fae4fa70), "vgyme", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/oS025ODdTW") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings("*") called at ./shutter line 3200
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595fae4fa70), "vgyme", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/oS025ODdTW") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings("*") called at ./shutter line 3200
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595fae4fa70), "vgyme", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/oS025ODdTW") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings("*") called at ./shutter line 3200
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Use of uninitialized value at /usr/share/perl5/XML/Simple.pm line 1571.
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595fae4fa70), "vgyme", "  ") called at /usr/share/perl5/XML/Simple.pm line 1594
	XML::Simple::value_to_xml(XML::Simple=HASH(0x5595fadd7960), HASH(0x5595ed48e7d8), "opt", "") called at /usr/share/perl5/XML/Simple.pm line 662
	XML::Simple::XMLout(HASH(0x5595ed48e7d8), "OutputFile", "/tmp/oS025ODdTW") called at ./shutter line 4735
	eval {...} called at ./shutter line 4733
	Shutter::App::fct_save_settings("*") called at ./shutter line 3200
	Shutter::App::__ANON__() called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	eval {...} called at /usr/lib/x86_64-linux-gnu/perl5/5.30/Glib/Object/Introspection.pm line 67
	Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x5595ef4cb1f8)) called at ./shutter line 11033
Tracked objects by class:
	Class::Struct::Tie_ISA                   1
	Config                                   1
	Encode::Internal                         1
	Encode::utf8                             3
	Errno                                    1
	Gtk3::ImageView::Tool::Dragger           839
	Gtk3::ImageView::Tool::Selector          35
	Locale::gettext                          1
	Method::Generate::Accessor               3
	Method::Generate::Constructor            3
	Moo::HandleMoose::AuthorityHack          1
	Moo::HandleMoose::_TypeMap               1
	Net::DBus::Annotation                    4
	Number::Bytes::Human                     1
	POSIX::SigRt                             1
	Readonly::Scalar                         5
	Shutter::App::Autostart                  1
	Shutter::App::Common                     1
	Shutter::App::HelperFunctions            3
	Shutter::App::Menu                       1
	Shutter::App::ShutterNotification        1
	Shutter::App::SimpleDialogs              5
	Shutter::App::Toolbar                    1
	Shutter::Draw::DrawingTool               1
	Shutter::Pixbuf::Load                    3
	Shutter::Pixbuf::Save                    1
	Shutter::Screenshot::History             23
	Shutter::Screenshot::SelectorAdvanced    23
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
GLib-GObject-CRITICAL **: g_boxed_free: assertion 'boxed != NULL' failed during global destruction.
 at ./shutter line 0.
	eval {...} called at ./shutter line 0
~/workspace/shutter/bin$ echo $?
0
~/workspace/shutter/bin$ 

(in the output mind the line numbers: 3200 and 3199)

@netikras
Copy link
Author

I may have been running it off master... 😅

Restarting off the new branch now

@Photon89
Copy link
Member

Damn, yeah, looks like master... Sorry for your time spent for nothing!

@netikras
Copy link
Author

netikras commented Aug 5, 2024

Still monitoring. Current RSS size: ~700M

$ ps aux | grep [.]/shutter                                                                                                                                                                                                                                                         
user1  1655916  0.0  1.0 2642392 715344 pts/152 Sl+ liep.23   9:02 /usr/bin/perl ./shutter

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

I think, that's enough, could you please post another leak output?

@netikras
Copy link
Author

netikras commented Aug 5, 2024

Sure!

Tracked objects by class:
	Class::Struct::Tie_ISA                   1
	Encode::Internal                         1
	Encode::utf8                             3
	Errno                                    1
	Gtk3::ImageView::Tool::Dragger           883
	Gtk3::ImageView::Tool::Selector          27
	Locale::gettext                          1
	Method::Generate::Accessor               3
	Method::Generate::Constructor            3
	Moo::HandleMoose::AuthorityHack          1
	Moo::HandleMoose::_TypeMap               1
	Net::DBus::Annotation                    4
	Number::Bytes::Human                     1
	POSIX::SigRt                             1
	Readonly::Scalar                         5
	Shutter::App::Autostart                  1
	Shutter::App::Common                     1
	Shutter::App::HelperFunctions            3
	Shutter::App::Menu                       1
	Shutter::App::ShutterNotification        1
	Shutter::App::SimpleDialogs              5
	Shutter::App::Toolbar                    1
	Shutter::Draw::DrawingTool               1
	Shutter::Pixbuf::Load                    3
	Shutter::Pixbuf::Save                    1
	Shutter::Screenshot::History             22
	Shutter::Screenshot::SelectorAdvanced    22

And this time I think I was on the correct branch :)

~/workspace/shutter/bin$ git status
On branch debug-661
Your branch is up to date with 'origin/debug-661'.

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

I have no explanation for this, there are only two occasions where Gtk3::ImageView::Tool::Dragger has been initialized, one of them is already commented out in master, the other one is additionally commented out in the debug branch...

You can check it yourself with grep -R "Dragger" ~/workspace/shutter

There should be two hits, both commented out:

/usr/share/shutter/resources/modules/Shutter/Screenshot/SelectorAdvanced.pm:	#$self->{_dragger}  = Gtk3::ImageView::Tool::Dragger->new($self->{_view});
/usr/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm:	#$self->{_dragger}  = Gtk3::ImageView::Tool::Dragger->new($self->{_view});

@netikras
Copy link
Author

netikras commented Aug 5, 2024

IDK what to say either :) Could it be second-line dependencies?

Full disclosure. I'm launching shutter from your binary. However, I'm working with 18 active workspaces, and lugging the shutter window across them is a tedious chore. Clicking on the shutter icon in a status bar is an options, but that's also not too convenient. Instead, I do [winlogo]→"shutt"→[enter] (as if I'm launching shutter anew) and the shutter window pops up.
I checked with ps, the shutter window that pops up belongs to the same ./shutter process launched from your git branch. Could it be that 'shutter' launched from the system installation overwrites smth in the 'shutter' process launched from binary in your branch? IDK how you've implemented the singleton process mechanism: whether it just checks for a pid (and if found - signals it to pop-up), or spawns another process that for some reason connects to the running one (via some IPC channel) and potentially exchanges code/plugins/libs/...

If there's no woodoo magic going on and your dependencies don't depend on Dragger themselves, I can't explain why there's Dragger in the report either.

@netikras
Copy link
Author

netikras commented Aug 5, 2024

RSS seems to be growing when I'm editing the screenshot. Could it be related? Does Dragger come from the editing feature?

RSS doesn't seem to go down after I close the editor

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

Well, initially the object has been initialized in DrawingTool.pm that is responsible for the editor. But I commented it out and don't understand why it is still there...

@netikras
Copy link
Author

netikras commented Aug 5, 2024

Gtk3::ImageView::Tool::Dragger 883

I see this even if I start your executable, wait for it to load all the screenshots and close it off. No win_logo, no editing, no clicking anywhere on the shutter window.

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

To exclude the possibility of mixing several Shutter versions, I propose to edit the installed files directly and then run Shutter from /usr/bin.

Here are the necessary changes: master...debug-661

  1. Add the line use Devel::Leak::Object qw{ GLOBAL_bless }; in /usr/bin/shutter (for example after line 37)
  2. Comment out line 82 in /usr/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm where the Dragger object is initialized.

@netikras
Copy link
Author

netikras commented Aug 5, 2024

# find /usr/share/shutter/resources/ -name DrawingTool.pm 
# ls -l /usr/share/shutter/resources/
viso 28
drwxr-xr-x 2 root root 4096 kov.   24  2022 conf
drwxr-xr-x 2 root root 4096 kov.   24  2022 credits
drwxr-xr-x 2 root root 4096 kov.   24  2022 gui
drwxr-xr-x 3 root root 4096 kov.   24  2022 icons
drwxr-xr-x 2 root root 4096 kov.   24  2022 license
drwxr-xr-x 5 root root 4096 kov.   24  2022 po
drwxr-xr-x 4 root root 4096 kov.   24  2022 system

There is no DrawingTool.pm in my installation?

There is one under

/usr/share/perl5/Shutter/Draw/DrawingTool.pm

Is this the one?

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

I guess so, looks like the packager for your distro decided to put all perl modules into /usr/share/perl5.

@netikras
Copy link
Author

netikras commented Aug 5, 2024

nope, still the same.

Well OK, almost the same :D For some reason it now loads only ~half of the screenshots I have in my library. The number of Dragger instances' corresponds to the number of loaded screenshots.

	Gtk3::ImageView::Tool::Dragger           492

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

But the RSS usage at start is still low, even though there are several hundred instances of Dragger?

Possibly we should concentrate on the other objects which have far less instances but might accumulate over time and consume more and more RSS. For example, there are 22 instances of Shutter::Screenshot::SelectorAdvanced which means, SelectorAdvanced isn't unloaded after being used.

Still, it's an interesting question, how Dragger gets into play. Probably somewhere in the definition of fct_create_tab in the main Shutter file:

sub fct_create_tab {

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

I pushed a commit which might reduce the memory leak, could you please test?

3d338c7

@netikras
Copy link
Author

netikras commented Aug 5, 2024

now it won't start

Variable "%session_screens" will not stay shared at ./shutter line 10913.
Variable "$window" will not stay shared at ./shutter line 10921.
Variable "$nav_toolbar" will not stay shared at ./shutter line 10931.
Global symbol "$drawing_tool" requires explicit package name (did you forget to declare "my $drawing_tool"?) at ./shutter line 5948.
Execution of ./shutter aborted due to compilation errors.
 at ./shutter line 11037.
Tracked objects by class:
	Class::Struct::Tie_ISA                   1
	Encode::Internal                         1
	Encode::utf8                             2
	Errno                                    1
	Net::DBus::Annotation                    4
	POSIX::SigRt                             1
	Readonly::Scalar                         5

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

Sorry, I copy&pasted a line one line off... Could you test again? Sorry!

@netikras
Copy link
Author

netikras commented Aug 5, 2024

it's all fine, after all, you're doing it for me (us) :)))

After initial startup this is the summary

Tracked objects by class:
	Class::Struct::Tie_ISA                   1
	Encode::Internal                         1
	Encode::utf8                             3
	Errno                                    1
	Gtk3::ImageView::Tool::Dragger           492
	Locale::gettext                          1
	Method::Generate::Accessor               3
	Method::Generate::Constructor            3
	Moo::HandleMoose::AuthorityHack          1
	Moo::HandleMoose::_TypeMap               1
	Net::DBus::Annotation                    4
	Number::Bytes::Human                     1
	POSIX::SigRt                             1
	Readonly::Scalar                         5
	Shutter::App::Autostart                  1
	Shutter::App::Common                     1
	Shutter::App::HelperFunctions            3
	Shutter::App::Menu                       1
	Shutter::App::ShutterNotification        1
	Shutter::App::SimpleDialogs              5
	Shutter::App::Toolbar                    1
	Shutter::Pixbuf::Load                    3
	Shutter::Pixbuf::Save                    1

And this is the ps aux (~218M RSS)

~/workspace/shutter/bin$ ps aux | head -1 ; ps aux | grep [.]/shutter
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user1   223242 34.1  0.3 2146828 223892 pts/152 Sl  17:15   0:21 /usr/bin/perl ./shutter

Should I have it running for a few days now, or is there any other testing method you'd recommend?

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

If you could observe an increase in RSS by using the editor, maybe you could test whether this is still the case. It should free the memory after closing the editor now. Also, after taking a screenshot, such that Shutter::Screenshot::SelectorAdvanced won't accumulate.

@Photon89
Copy link
Member

Photon89 commented Aug 5, 2024

Okay, so i dived into this issue a little bit deeper. Unfortunately, I have never dealt with memory management before, so I am kind of groping in the dark here.

I am now able to watch the memory consumption at any line of code using Memory::Usage and I see that undefining variables has no effect on it for some reason. Probably because the variables are just pointers to other ones, and these other ones are still around somewhere. But I didn't manage to track it down so far.

Regarding the many Gtk3::ImageView::Tool::Dragger instances, they are being spawned from inside /usr/share/perl5/vendor_perl/Gtk3/ImageView/Tool.pm. Looks like they are necessary for displaying the screenshot preview in the various tabs. The problematic part is that the number of instances doesn't decrease when tabs are being closed.

@netikras
Copy link
Author

netikras commented Aug 6, 2024

IDK, I don't normally close tabs in shutter. However, after a week's of use RSS grows substantially, and after shutter restart RSS drops significantly.

Unless... when editing a screenshot, a new version of the screenshot means closing the original tab and opening a new (redacted screenshot) tab? That would explain the connection between RSS rise and you looking into the tabs-closing-memory-unreleased issue.

@Photon89
Copy link
Member

Photon89 commented Aug 6, 2024

No, sorry for the confusion. Closing tabs was just an example. Another example is taking screenshots. The editor, however seems to be fine to me, at least in the debug branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants