Hello All.

I found memory leak in POE::Component::IKC::Server per every client
connect (~16kB).

What's wrong?

Examples:

Server from http://poe.perl.org/?POE_Cookbook/Application_Servers_2
Client (sub SimplyTask from
http://poe.perl.org/?POE_Cookbook/Application_Servers_2):
------------------------------------------------------------------------------------------------------------
#!/usr/local/bin/perl

use warnings;
use strict;

use Data::Dumper;
use Time::HiRes;
use POE::Component::IKC::ClientLite;

my ($RequestsCount, $ParallelProcessesCount, $RandomDelayMax) = @ARGV;

$RequestsCount ||= 200;
$ParallelProcessesCount ||=20;
$RandomDelayMax ||= 0.1;

for(my $i=0; $i<$ParallelProcessesCount; $i++) {
    if(fork()== 0) {
        # Child
        sleep(rand()*$RandomDelayMax);
        print "Child: $$\n";
        SimplyTask();
        exit;
    }
    else {
        $RequestsCount--;
    }
};

while($RequestsCount) {
    wait();
    if(fork()== 0) {
        # Child
        sleep(rand()*$RandomDelayMax);
        print "Child: $$\n";
        SimplyTask();
        exit;
    }
    else {
        $RequestsCount--;
    }
};

for(my $i=0; $i<$ParallelProcessesCount; $i++) {
    wait();
}


sub SimplyTask {
    # Create an IKC client.  This also establishes a connection to an IKC
    # server.  Part of the registration process is choosing a unique name
    # for ourselves, which we do naively by abusing the process ID.

    my $name   = "Client$$";
    my $remote = create_ikc_client(
        port    => 31338,
        name    => $name,
        timeout => 5,
    );
    die $POE::Component::IKC::ClientLite::error unless $remote;

    # We want the server to add up a list of numbers.  Using
    # post_return(), we can send a detached event to the server and wait
    # for its response.  The response can be delayed up to the
    # create_ikc_client() timeout.  post_return() returns the value that
    # was posted back to us from service_response() in the corresponding
    # server example.

    my $return_value;
    my @numbers = qw(8 6 7 5 3 0 9);
    print "Summing $$  : @numbers\n";

    $return_value = $remote->post_respond( 'application/calc_sum', [EMAIL 
PROTECTED] );
    die $POE::Component::IKC::ClientLite::error unless defined $return_value;

    print "The sum is $$ : $return_value\n";
};
------------------------------------------------------------------------------------------------------------

Reply via email to