I could not find any memory leak with Perl 5.10.0 x86_64-linux-thread-multi on SLES11 SP1
with a script that tries to post data.
sub post {
$SIG{'TERM'} = \&termination_flag;
my $ua = LWP::UserAgent->new;
$ua->timeout( $configuration->{'timeout'} );
while ($run) {
my %post;
{
syslog LOG_DEBUG, "Locking to check for new location GeoJSON data";
lock %location;
until ( %location or not $run ) {
syslog LOG_DEBUG, "Waiting for location GeoJSON data";
cond_wait %location;
}
%post = %location;
}
if (%post) {
my %feature;
while ( my ( $id, $feature ) = each %post ) {
$feature{$id} = encode_json $feature;
}
my $content = '{"type":"FeatureCollection","features":['
. join( ',', values %feature ) . ']}';
syslog LOG_INFO, "Posting location data $content";
my $response = $ua->post(
$configuration->{'url'},
'Content-Type' => 'application/json',
'Content' => $content
);
if ( $response->is_success ) {
syslog LOG_INFO, $response->as_string;
syslog LOG_DEBUG, "Locking to delete the posted location data";
lock %location;
while ( my ( $id, $feature ) = each %location ) {
my $feature_json = $feature{$id};
if ( defined $feature_json
and $feature_json eq encode_json $feature )
{
delete $location{$id};
}
}
}
else {
syslog LOG_CRIT, $response->as_string;
sleep $run * $configuration->{'retry'};
}
}
}
if (%location) {
syslog LOG_ERR, "Unposted location data: %s", encode_json \%location;
}
syslog LOG_INFO, "The post subroutine terminating";
}
==12274== Memcheck, a memory error detector
==12274== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==12274== Using Valgrind-3.8.0 and LibVEX; rerun with -h for copyright info
==12274== Command: /opt/avl/current/sbin/aplicom.pl
==12274==
aplicom[12274]: Started the program with configuration
{"url":"
http://localhost:9210/external","port":60000}
aplicom[12274]: Locking to check for new location GeoJSON data
aplicom[12274]: Receiving a message on the socket
aplicom[12274]: Waiting for location GeoJSON data
aplicom[12274]: 127.0.0.1:39397:
44c200000000000001004000ffff6d0180501914a25017d0e20395d491017bac6305000088
8000000000000000002ece0000000004e7000004e70000000000000000000300120000000
000000000
aplicom[12274]: Data validity 128 at position 16
aplicom[12274]: Digital input status at position 37
aplicom[12274]: Voltage of analog inputs at position 38
aplicom[12274]: Voltage of main power in millivolts. 16bit unsigned integer at position 46
aplicom[12274]: Distance travelled 1 in meters since trip meter was reset. 32bit unsigned
integer.
aplicom[12274]: Distance travelled 2 in meters since trip meter was reset. 32bit unsigned
integer.
aplicom[12274]: Status of outputs at position 58
aplicom[12274]: iButton key ID at position 59
aplicom[12274]: Driver Log Keypad button at position 65
aplicom[12274]: Altitude at position 66: 0003
aplicom[12274]: {"geometry":{"coordinates":
[24.882275,60.150929,3],"type":"Point"},"type":"Feature","id":1,"properties":
{"maximum_velocity":0,"event_information":1,"iButton":"000000000000","travelled2":1255,"nu
mber_of_satellites":5,"net_time":"20120813111619","time":1343820962,"analog_input_4":0,"f
lag":"0000000000000000","snapshot_counter":18,"analog_input_3":0,"velocity":0,"direction":2
72,"external_battery":0,"maximum_velocity_error":0,"analog_input_1":0,"main_power":11982,"
additional_data":129,"locationgw":"aplicom","output":"Output 1 is off. Output 2 is
off","travelled1":1255,"event":"ALARM_ACTIVE","lip_result_code":201,"reason_code":129,"posit
ion_error":-1,"velocity_error":0,"gps_time":1343738082,"analog_input_2":0,"keypad":0,"digital
_input":"IGN on. DIN1 off. DIN2 off. DIN3 off. DIN4 off. DIN5 off. DIN6 off."}}
aplicom[12274]: Locking to signal new location data
aplicom[12274]: Signaling new location data
aplicom[12274]: Receiving a message on the socket
aplicom[12274]: Posting location data {"type":"FeatureCollection","features":[{"geometry":
{"coordinates":[24.882275,60.150929,3],"type":"Point"},"type":"Feature","id":1,"properties":
{"maximum_velocity":0,"event_information":1,"iButton":"000000000000","travelled2":1255,"nu
mber_of_satellites":5,"net_time":"20120813111619","time":1343820962,"analog_input_4":0,"f
lag":"0000000000000000","snapshot_counter":18,"analog_input_3":0,"velocity":0,"direction":2
72,"external_battery":0,"maximum_velocity_error":0,"analog_input_1":0,"main_power":11982,"
additional_data":129,"locationgw":"aplicom","output":"Output 1 is off. Output 2 is
off","travelled1":1255,"event":"ALARM_ACTIVE","lip_result_code":201,"reason_code":129,"posit
ion_error":-1,"velocity_error":0,"gps_time":1343738082,"analog_input_2":0,"keypad":0,"digital
_input":"IGN on. DIN1 off. DIN2 off. DIN3 off. DIN4 off. DIN5 off. DIN6 off."}}]}
aplicom[12274]: 500 Can't connect to localhost:9210 (connect: Connection refused)
Content-Type: text/plain
Client-Date: Mon, 13 Aug 2012 08:16:20 GMT
Client-Warning: Internal response
...
aplicom[12274]: HTTP/1.1 200 HTTPResponse
Connection: close
Content-Length: 4
Content-Type: text/plain; charset=iso-8859-1
Client-Date: Mon, 13 Aug 2012 08:16:32 GMT
Client-Peer: 127.0.0.1:9210
Client-Response-Num: 1
OK
aplicom[12274]: Locking to delete the posted location data
aplicom[12274]: Locking to check for new location GeoJSON data
aplicom[12274]: Waiting for location GeoJSON data
aplicom[12274]: Setting termination flag
aplicom[12274]: Set termination flag
aplicom[12274]: Termination signal caught
aplicom[12274]: Failed to receive data from the socket: Interrupted system call
aplicom[12274]: Closing the socket
aplicom[12274]: Killing the post thread
aplicom[12274]: Locking to signal termination
aplicom[12274]: Signaling the post thread to terminate
aplicom[12274]: Setting termination flag
aplicom[12274]: Set termination flag
aplicom[12274]: The post subroutine terminating
aplicom[12274]: Joining the post thread
aplicom[12274]: Program terminating
==12274==
==12274== HEAP SUMMARY:
==12274== in use at exit: 118,290 bytes in 104 blocks
==12274== total heap usage: 334,932 allocs, 334,828 frees, 38,350,543 bytes allocated
==12274==
==12274== LEAK SUMMARY:
==12274== definitely lost: 0 bytes in 0 blocks
==12274== indirectly lost: 0 bytes in 0 blocks
==12274== possibly lost: 0 bytes in 0 blocks
==12274== still reachable: 118,290 bytes in 104 blocks
==12274== suppressed: 0 bytes in 0 blocks
==12274== Reachable blocks (those to which a pointer was found) are not shown.
==12274== To see them, rerun with: --leak-check=full --show-reachable=yes
==12274==
==12274== For counts of detected and suppressed errors, rerun with: -v
==12274== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)