GNOME Bugzilla – Bug 774414
Thread leak
Last modified: 2016-11-21 15:11:32 UTC
See https://bugzilla.redhat.com/show_bug.cgi?id=1337007#c30 for detailed explanation: sebastien.nobert@guavus.com 2016-11-11 17:13:00 EST There is a process-lifetime memory leak cause by the launch of new thread to gather net stat and io stat. The thread are joined only when the application is closed. Thread should probalby be created detached. Here is some output from #valgrind --tool=massif --depth=50 --pages-as-heap=yes gnome-boxes ... -------------------------------------------------------------------------------- n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) -------------------------------------------------------------------------------- 49 27,131,871,418 52,192,754,560 52,192,754,560 0 0 100.00% (52,192,754,560B) (page allocation syscalls) mmap/mremap/brk, --alloc-fns, etc. ->98.57% (51,448,250,368B) 0xA46B419: mmap (mmap.c:34) | ->96.43% (50,331,045,888B) 0xA15A0A6: pthread_create@@GLIBC_2.2.5 (allocatestack.c:504) | | ->96.43% (50,331,045,888B) 0x9B677EE: g_system_thread_new (gthread-posix.c:1169) | | ->96.43% (50,331,045,888B) 0x9B49FFD: g_thread_new_internal (gthread.c:870) | | ->96.30% (50,263,904,256B) 0x9B4A0B6: g_thread_new (gthread.c:823) | | | ->96.27% (50,247,118,848B) 0x1C6973: boxes_async_launcher_launch_co (async-launcher.vala:24) | | | | ->48.13% (25,119,363,072B) 0x161009: boxes_libvirt_machine_update_net_stat_co (libvirt-machine.c:2661) | | | | | ->48.13% (25,119,363,072B) 0x162BAA: boxes_libvirt_machine_update_stats_co (libvirt-machine.c:2894) | | | | | ->48.13% (25,119,363,072B) 0x9577B65: g_simple_async_result_complete (gsimpleasyncresult.c:801) | | | | | ->48.13% (25,119,363,072B) 0x162220: boxes_libvirt_machine_update_io_stat_co (libvirt-machine.c:2472) | | | | | ->48.13% (25,119,363,072B) 0x9577B65: g_simple_async_result_complete (gsimpleasyncresult.c:801) | | | | | ->48.13% (25,119,363,072B) 0x1C6896: boxes_async_launcher_launch_co (async-launcher.vala:21) | | | | | ->48.13% (25,119,363,072B) 0x9B236B8: g_main_context_dispatch (gmain.c:3154) | | | | | ->48.13% (25,119,363,072B) 0x9B23A6E: g_main_context_iterate.isra.29 (gmain.c:3840) | | | | | ->48.13% (25,119,363,072B) 0x9B23B1A: g_main_context_iteration (gmain.c:3901) | | | | | ->48.13% (25,119,363,072B) 0x95AF48B: g_application_run (gapplication.c:2381) | | | | | ->48.13% (25,119,363,072B) 0x177297: _vala_main (main.c:551) | | | | | ->48.13% (25,119,363,072B) 0xA38E72F: (below main) (libc-start.c:289) | | | | | | | | | ->48.11% (25,110,970,368B) 0x1626E5: boxes_libvirt_machine_update_io_stat_co (libvirt-machine.c:2389) | | | | | ->48.11% (25,110,970,368B) 0x162E63: boxes_libvirt_machine_update_stats_co (libvirt-machine.c:2887) | | | | | ->48.11% (25,110,970,368B) 0x95891F1: g_task_return_now (gtask.c:1107) | | | | | ->48.11% (25,110,970,368B) 0x9589227: complete_in_idle_cb (gtask.c:1121) | | | | | ->48.11% (25,110,970,368B) 0x9B236B8: g_main_context_dispatch (gmain.c:3154) | | | | | ->48.11% (25,110,970,368B) 0x9B23A6E: g_main_context_iterate.isra.29 (gmain.c:3840) | | | | | ->48.11% (25,110,970,368B) 0x9B23B1A: g_main_context_iteration (gmain.c:3901) | | | | | ->48.11% (25,110,970,368B) 0x95AF48B: g_application_run (gapplication.c:2381) | | | | | ->48.11% (25,110,970,368B) 0x177297: _vala_main (main.c:551) | | | | | ->48.11% (25,110,970,368B) 0xA38E72F: (below main) (libc-start.c:289) | | | | | | | | | ->00.03% (16,785,408B) in 1+ places, all below ms_print's threshold (01.00%) | | | | | | | ->00.03% (16,785,408B) in 1+ places, all below ms_print's threshold (01.00%) | | | | | ->00.13% (67,141,632B) in 1+ places, all below ms_print's threshold (01.00%) | |
Created attachment 339927 [details] [review] Tentative Fix This patch fix the issue for me. I'm not a Gnome dev but looking at the doc I saw a GThreadPool would probably be more appropriate.
(In reply to Sebastien Nobert from comment #1) > Created attachment 339927 [details] [review] [review] > Tentative Fix > > This patch fix the issue for me. I'm not a Gnome dev but looking at the doc > I saw a GThreadPool would probably be more appropriate. I think ThreadPool is for running the same task/function with different data. That's not the case here.
Review of attachment 339927 [details] [review]: Thanks. I've merged this and created a commit for you but please in future either use git-format-patch or git-bz to create/upload patches. Also please do read through this & try to follow it: https://wiki.gnome.org/Git/CommitMessages