Glib::Timeout causing memory leak
- From: Jamie Lahowetz <jlahowetz gmail com>
- To: "gtk-perl-list gnome org" <gtk-perl-list gnome org>
- Subject: Glib::Timeout causing memory leak
- Date: Thu, 9 Apr 2009 22:47:05 -0500
I have this fairly large program. Recently I have discovered a memory
leak occurring in two Glib::Timeouts and have not been able to
discover the cause. The firs widget is a red "off" that switches to a
green "on" when the use clicks the button. The second is similar and
also includes a black label that displays a GPS location. These
widgets are located in the same widget. When these time outs are
running and the widget that contains them is open, memory usage
increases and keeps going until windows crashes producing a blue
screen. Vise versa when they are commented out the leakage goes away.
Has anyone ever encountered this type of leak? Any ideas?
Below is the code for the two time outs:
#-------------------Telemetry State-------------------
sub tele_state {
#Tele client connected
if ($tele_start == 1 and $telemetry == 1) {
$tele_status->set_markup( '<span size="large"
foreground="green">Connected</span>');
if ($subflag >= 4) {
$tele_subscribe->set_markup( '<span size="small"
foreground="green">tele subscribe</span>');
}
if ($planflag >= 3) {
$fp_subscribe->set_markup( '<span size="small"
foreground="green">FP subscribe</span>');
}
}
#Tele Client not connected
elsif ($tele_start == 1 and $telemetry == 0) {
$tele_status->set_markup( '<span size="large"
foreground="yellow">No Server</span>');
}
#tele client off
else {
$tele_status->set_markup( '<span size="large"
foreground="red">OFF</span>');
$tele_subscribe->set_markup( '<span size="small"
foreground="red">tele Unsubscribe</span>');
$fp_subscribe->set_markup( '<span size="small"
foreground="red">FP Unsubscribe</span>');
}
#handle the button
if ($tele_start == 0 and $tele_state eq 'Tele Disconnect') {
$tele_button->set_label('Tele Connect');
$tele_state='Tele Connect';
}
#Subscribed to atmospheric data
if ($metflag == 3) {$met_subscribe->set_markup( '<span
size="large" foreground="green">Subscribe</span>')}
if ($metflag == 0) {$met_subscribe->set_markup( '<span
size="large" foreground="red">Unsubscribe</span>')}
return 1;
}
#-------------------GPS States-------------------
sub gps_state {
#GPS on and working
if ($gps_start == 1 and defined($ns && $lat && $ew && $lon &&
$utc) and $lat != 0) {
#display the current GPS position
$gps_current->set_label("$ns $lat, $ew $lon \n $utc");
$gps_status->set_markup( '<span size="xx-large"
foreground="green">ON</span>');
}
#GPS on but not working
elsif ($gps_start == 1) {
$gps_current->set_label("N/A");
$gps_status->set_markup( '<span size="xx-large"
foreground="yellow">NO DATA</span>');
}
elsif ($gps_current == 1) {}
#GPS off
else {
$gps_current->set_label("N/A");
$gps_status->set_markup( '<span size="xx-large"
foreground="red">OFF</span>');
}
return 1;
}
called by:
my $timer_tele = Glib::Timeout->add(1000, \&tele_state);
my $timer_gps = Glib::Timeout->add(1000, \&gps_state);
--
Jamie Ryan Lahowetz
University of Nebraska - Lincoln
Graduate Student - Geosciences
402.304.0766
jlahowetz gmail com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]