Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have a fairly mature but functionally independent, piece of code that precedes a call to a video player in wxPerl.
When this code is not called the video (gstreamer) never crashes. When the code is called the video crashes occasionally, maybe 10% of the time.
This issue is of fairly long standing, but because it is sporadic, no-one is quite sure when it started.
While watching this happen in a performance monitor, I noticed that the memory utilisation was not stable and that it gradually increased over time. I tried tracking this through Valgrind and Valgrind showed some kilobytes of memory leaks, but didn't specify when they occurred (ie in real time). Just at the end in the leak summary.
I have been using Memory::Usage as shown in http://perlmaven.com/eliminate-circular-reference-memory-leak-using-weaken to try to find trhe leak, but without much success. Every time I think I have found it, I modify the code only to find the Memory 'diff' move down the script.
Here is a sample of the output:
time vsz ( diff) rss ( diff) shared ( diff) code ( diff) + data ( diff) 0 774028 ( 774028) 193524 ( 193524) 43648 ( 43648) 8 ( + 8) 368928 ( 368928) before i_Booking->new 0 774028 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) after i_Booking tbl_patient_exam 0 774028 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) before i_Booking SetScreenHeader 0 774028 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) after i_Booking SetScreenHeader 0 774028 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) after i_Booking set focus 0 774028 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) before i_Booking i_staticText 1 0 774028 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) after i_Booking i_staticText 1 0 774648 ( 620) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) before i_Booking Ctl_Booking_Referring_Doctor_Ref +_4_Lbl 0 774648 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) before i_Booking i_staticText 2 0 774648 ( 0) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) after i_Booking i_staticText 2 0 774648 ( 0) 193800 ( 276) 43924 ( 276) 8 ( +0) 368928 ( 0) before i_Booking health plan providor 0 774648 ( 0) 193800 ( 0) 43924 ( 0) 8 ( +0) 368928 ( 0) at i_Booking mid point 0 774648 ( 0) 193804 ( 4) 43924 ( 0) 8 ( +0) 368928 ( 0) at i_Booking DatePickerCtrl 0 774780 ( 132) 193932 ( 128) 43924 ( 0) 8 ( +0) 369060 ( 132) at i_Booking Examining Doctor Search 0 774912 ( 132) 194172 ( 240) 43924 ( 0) 8 ( +0) 369192 ( 132) at i_Booking Patient details 0 774912 ( 0) 194172 ( 0) 43924 ( 0) 8 ( +0) 369192 ( 0) before i_Booking $loc_window_layout->SetFooter 0 774912 ( 0) 194172 ( 0) 43924 ( 0) 8 ( +0) 369192 ( 0) after i_Booking $loc_window_layout->SetFooter 0 774912 ( 0) 194172 ( 0) 43924 ( 0) 8 ( +0) 369192 ( 0) at i_Booking exit
I am suspicious of a number of pieces of code, but like bubbles in the wall-paper the bubble just moves when I press it. For instance in the above output, we see :
The total code between this line and the previous output is shown here, together with the surrounding lines:0 774648 ( 620) 193524 ( 0) 43648 ( 0) 8 ( +0) 368928 ( 0) before i_Booking Ctl_Booking_Referring_Doctor_Ref
# Referring Dr details from Dr file $booking_dlg->{Ctl_Booking_Referring_Doctor_Lbl} = Wx::StaticText- +>new($booking_dlg->{booking_main}, wxID_ANY, __t('Referring Doctor'), + wxDefaultPosition, wxDefaultSize, ); $mu->record('before i_Booking i_staticText 1'); $booking_dlg->{Ctl_Booking_Referring_Doctor_Txt} = i_staticText->n +ew($booking_dlg->{booking_main}, wxID_ANY, "", wxDefaultPosition, wxD +efaultSize, ); $mu->record('after i_Booking i_staticText 1'); $booking_dlg->{Ctl_Booking_Referring_Doctor_Txt}->SetFont(Wx::Font +->new($gl_cfg->{client_point_size}, wxMODERN, wxFONTSTYLE_ITALIC, wxF +ONTWEIGHT_BOLD, 0, $gl_cfg->{client_font})); $mu->record('before i_Booking Ctl_Booking_Referring_Doctor_Ref_4_L +bl'); $booking_dlg->{Ctl_Booking_Referring_Doctor_Ref_4_Lbl} = Wx::Stati +cText->new($booking_dlg->{booking_main}, wxID_ANY, __t("Ref 4"), wxDe +faultPosition, wxDefaultSize, ); $mu->record('before i_Booking i_staticText 2'); $booking_dlg->{Ctl_Booking_Referring_Doctor_Ref_4_Txt} = i_staticT +ext->new($booking_dlg->{booking_main}, wxID_ANY, "", wxDefaultPositio +n, __xy_size(100), ); $mu->record('after i_Booking i_staticText 2'); $booking_dlg->{Ctl_Booking_Referring_Doctor_Ref_4_Txt}->SetFont(Wx +::Font->new($gl_cfg->{client_point_size}, wxMODERN, wxFONTSTYLE_ITALI +C, wxFONTWEIGHT_BOLD, 0, $gl_cfg->{client_font}));
But really the code here looks quite innocent.
Any ideas would be welcome.
Regards
Steve.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detecting memory leaks.
by BrowserUk (Patriarch) on May 04, 2015 at 14:44 UTC | |
by Steve_BZ (Chaplain) on May 04, 2015 at 14:57 UTC | |
by BrowserUk (Patriarch) on May 04, 2015 at 16:04 UTC | |
by Steve_BZ (Chaplain) on May 04, 2015 at 16:53 UTC | |
by Anonymous Monk on May 05, 2015 at 00:05 UTC | |
| |
|
Re: Detecting memory leaks.
by RichardK (Parson) on May 04, 2015 at 15:53 UTC | |
by Steve_BZ (Chaplain) on May 04, 2015 at 16:37 UTC | |
|
Re: Detecting memory leaks.
by Anonymous Monk on May 04, 2015 at 17:49 UTC | |
by Steve_BZ (Chaplain) on May 04, 2015 at 18:28 UTC |