in reply to Detecting memory leaks.

Wx::Font->new($gl_cfg->{client_point_size}, wxMODERN, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD, 0, $gl_cfg->{client_font})

620 bytes doesn't seem like a lot for a new font.

Is it really necessary to create a new font each time? Couldn't you create the font once and reference it when you need it?

Ditto other things.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^2: Detecting memory leaks.
by Steve_BZ (Chaplain) on May 04, 2015 at 14:57 UTC

    Hi BrowserUK,

    Thanks for that. A sensible suggestion. I just did that and made a global replace. I also moved the Wx::Font line before the rest of the code, like this:

    my $loc_font_wx=Wx::Font->new($gl_cfg->{client_point_size}, wxMODE +RN, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD, 0, $gl_cfg->{client_font}) +; $mu->record('after i_Booking set focus'); # 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($loc_fon +t_wx); $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($l +oc_font_wx);

    The output is unchanged:

    0 773984 ( 0) 193264 ( 0) 43436 ( 0) 8 ( +0) 368884 ( 0) after i_Booking set focus 0 773984 ( 0) 193264 ( 0) 43436 ( 0) 8 ( +0) 368884 ( 0) before i_Booking i_staticText 1 0 773984 ( 0) 193264 ( 0) 43436 ( 0) 8 ( +0) 368884 ( 0) after i_Booking i_staticText 1 0 774604 ( 620) 193264 ( 0) 43436 ( 0) 8 ( +0) 368884 ( 0) before i_Booking Ctl_Booking_Referring_Doctor_Ref +_4_Lbl

    But even so, the variable should be destroyed when it moves out of scope and it is not, so I suspect some sort of circular reference. I just can't see it.

    Steve.

      But even so, the variable should be destroyed when it moves out of scope and it is not, so I suspect some sort of circular reference. I just can't see it.

      If $booking_dlg->{booking_main} contains a reference to $booking_dlg? Then this is a circular reference:

      $booking_dlg->{Ctl_Booking_Referring_Doctor_Txt} = i_staticText->new($ +booking_dlg->{booking_main}

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

        Oh, for a minute I got my hopes up!

        I did:

        $mu->record('at i_Booking exit'); $mu->dump(); print "Find cycle >>>>>>>>"; find_cycle($booking_dlg); print "<<<<<<<<<< Find cycle"; return $booking_dlg;

        And the

        find_cycle($booking_dlg);

        Did nothing.

        Oh Well.

        Regards

        Steve.