Possible test case and info on CPAN RT 26185 Memory Leak POE::Component::Client::HTTP

Christian Brink <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
Here is a pared down working example of when I see the memory leak. If I 
comment out the  P::C::C::HTTP  create , I see no change in memory usage.

I have added my memory usage log.

If this works for everyone I'll post it to the RT ticket, otherwise I 
can happily take suggestions on what else I need to attach, to help 
track this down.

 

-- 
Christian Brink
Software Development Manager
R-Stream POS and Data Management
2220 34th St. South
St. Petersburg, FL 33711
727-209-0233 ext. 104
727-213-1969 fax
[email protected]
memusage.poe (text/plain, 2.4 KB)
PID   - EPOCH      
10749 - 1205934957	Size: 14913536	PCT: 1.00	diff: 0	        max: 14913536	min: 14913536	total diff: 0
10749 - 1205935161	Size: 15015936	PCT: 1.00	diff: 102400	max: 15015936	min: 14913536	total diff: 102400
10749 - 1205935593	Size: 15118336	PCT: 1.00	diff: 102400	max: 15118336	min: 14913536	total diff: 204800
10749 - 1205935644	Size: 15200256	PCT: 1.00	diff: 81920	max: 15200256	min: 14913536	total diff: 286720
10749 - 1205935649	Size: 15183872	PCT: 1.00	diff: -16384	max: 15200256	min: 14913536	total diff: 286720
10749 - 1205935888	Size: 15286272	PCT: 1.00	diff: 102400	max: 15286272	min: 14913536	total diff: 372736
10749 - 1205935893	Size: 15261696	PCT: 1.00	diff: -24576	max: 15286272	min: 14913536	total diff: 372736
10749 - 1205935929	Size: 15257600	PCT: 1.00	diff: -4096	max: 15286272	min: 14913536	total diff: 372736
10749 - 1205935934	Size: 15237120	PCT: 1.00	diff: -20480	max: 15286272	min: 14913536	total diff: 372736
10749 - 1205936290	Size: 15372288	PCT: 1.00	diff: 135168	max: 15372288	min: 14913536	total diff: 458752
10749 - 1205936295	Size: 15310848	PCT: 1.00	diff: -61440	max: 15372288	min: 14913536	total diff: 458752
10749 - 1205936759	Size: 15396864	PCT: 1.00	diff: 86016	max: 15396864	min: 14913536	total diff: 483328
10749 - 1205936845	Size: 15486976	PCT: 1.00	diff: 90112	max: 15486976	min: 14913536	total diff: 573440
10749 - 1205936972	Size: 15626240	PCT: 1.00	diff: 139264	max: 15626240	min: 14913536	total diff: 712704
10749 - 1205936977	Size: 15585280	PCT: 1.00	diff: -40960	max: 15626240	min: 14913536	total diff: 712704
10749 - 1205937099	Size: 15691776	PCT: 1.00	diff: 106496	max: 15691776	min: 14913536	total diff: 778240
10749 - 1205937104	Size: 15667200	PCT: 1.00	diff: -24576	max: 15691776	min: 14913536	total diff: 778240
10749 - 1205937155	Size: 15757312	PCT: 1.00	diff: 90112	max: 15757312	min: 14913536	total diff: 843776
10749 - 1205937242	Size: 15867904	PCT: 1.00	diff: 110592	max: 15867904	min: 14913536	total diff: 954368
10749 - 1205937410	Size: 15978496	PCT: 1.00	diff: 110592	max: 15978496	min: 14913536	total diff: 1064960
10749 - 1205937415	Size: 15962112	PCT: 1.00	diff: -16384	max: 15978496	min: 14913536	total diff: 1064960
10749 - 1205937552	Size: 16101376	PCT: 1.00	diff: 139264	max: 16101376	min: 14913536	total diff: 1187840
10749 - 1205937557	Size: 16072704	PCT: 1.00	diff: -28672	max: 16101376	min: 14913536	total diff: 1187840
testcase.pl (application/x-perl, 1.9 KB)
#! /usr/bin/perl
use strict;
use warnings;

use POE;
use POE::Component::Client::HTTP;
use LWP::UserAgent;

POE::Component::Client::HTTP->spawn(
    Alias   => 'ua',
    Timeout => 3,
    Agent   => 'test-me',
);

my @sites = (
    {
        hps        =>  3,
        name       => 'Testing',
        url       => 'http://www.r-stream.com/',
#        url       => 'http://poe.perl.org/',
        DEBUG => 0,
    },
    {
        hps        =>  3,
        name       => 'Testing 2',
        url       => 'http://www.r-stream.com/',
#        url       => 'http://poe.perl.org/',
        DEBUG => 0,
    },
);

foreach my $site (@sites) {
   
    my $hps        = $site->{hps};
    my $interval   = $hps ? 1/$hps : 1;
    my $next_alarm = time()  + $interval;

    POE::Session->create(
        heap           => {
            next_alarm       => 0,
            url              => $site->{url},
            hps              => $hps,
            interval         => $interval,
            next_alarm       => $next_alarm,
            in_process       => 0,
        },
        package_states => [ main => [ "_start", "snap", "got_response" ] ]
    );
}


POE::Kernel->run();
exit 0;

sub _start {
    my ($kernel, $heap) = @_[ KERNEL, HEAP ];
    $kernel->alarm( snap => $heap->{next_alarm} );
}

sub snap {
    my ($kernel, $heap) = @_[ KERNEL, HEAP ];

    if (!$heap->{in_process}) {
        $heap->{in_process}++;
        my $url = $heap->{url};
        my $req = HTTP::Request->new(GET => $url);
        $kernel->post( ua => request => got_response => $req );
    }
    $heap->{next_alarm} += $heap->{interval};
    $kernel->alarm( snap => $heap->{next_alarm} );
}

sub got_response {
    my ( $kernel, $heap, $request_packet, $response_packet ) = @_[ KERNEL, HEAP, ARG0, ARG1 ];
    $heap->{in_process} =  0;

    my $time = time();
    my $req = $request_packet->[0];
    my $response = $response_packet->[0];
    my $type = $response->header('content-type') || '';
    print "$type\n";
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.