> Cornelius Bartke wrote: >> However, while processing the output, W:P:PS seems to allocate memory >> and running a rsync process again does not reuse the memory. Per >> 10.000 lines of STDOUT processed, my process grows by 45MB (Debian >> Lenny, perl 5.10, Wx v0.92, wxWidgets 2.6.3.2, on winXP it is 33MB but >> basically the same problem).
Hi! Update: Using wxWidgets 2.8.10, the behaviour is the same. I've been trying to implement the required functionality using Wx::Process/Wx::ExecuteCommand, but so far I mostly get segfaults near the readline() call. Obviously I am doing something very wrong. Are there any examples I could look at how for these modules? The test-script can be seen at: http://www.nabble.com/Memory-Leak-%28in-Wx%3A%3APerl%3A%3AProcessStream%29--p25366474.html My drop-in replacement using Wx::Process/Wx::ExecuteCommand looks like this: sub _evt_button_clicked { my ($self, $event) = @_; $self->{button}->Disable; my $cmd = $self->{cmd}->GetValue; $self->{linecount} = 0; $self->{status}->SetLabel(sprintf( 'starting command "%s" at %d', $cmd, time() )); my $id = Wx::NewId; my $proc = Wx::Process->new($self, $id); $proc->Redirect; $proc->CloseOutput; my $pid = Wx::ExecuteCommand($cmd, wxEXEC_ASYNC, $proc); defined($pid) or die "no pid\n"; # handle output while (1) { unless ($proc->IsInputAvailable) { Wx::wxTheApp->Yield; unless (Wx::Process::Exists($pid)) { print STDERR "pid $pid gone\n"; last; } next; } my $tmp = readline($proc->GetInputStream); unless ($self->{linecount} % 100) { $self->{status}->SetLabel(sprintf( 'pid %d, lines read: %d', $pid, $self->{linecount} )); Wx::wxTheApp->Yield; $self->{panel}->Layout; } $self->{linecount}++; } $self->{status}->SetLabel(sprintf( 'pid %d, lines read: %d (finished)', $pid, $self->{linecount} )); $self->{panel}->Layout; $self->{button}->SetLabel('Run again'); $self->{button}->Enable; $self->{panel}->Layout; return; } Any help is appreciated. -Cornelius