I notice $event->GetProcess->Destroy should reset the buffer.
On Wed, Sep 9, 2009 at 10:00 PM, Mark Dootson <mark.doot...@znix.com> wrote: > Hi, > > I'm not entirely certain this is really a Wx::Perl::ProcessStream issue. > > For sure, it is Wx::Perl::ProcessStream consuming the memory. I am not sure > it is a fault in Wx::Perl::ProcessStream that causes perl to allocate > additional memory when additional processes are run. > > I will have to run some tests at some point to confirm this or fix problem. > > However, you can limit the memory consumed by Wx::Perl::ProcessStream. > > In addition to passing out each line in an event, the module stores lines > in a buffer for later retrieval. Accessing the contents of this buffer > clears it. > > So - for your purposes, in your event handlers > > sub _evt_stdout { > ..... > $event->GetProcess->GetStdOutBuffer; > ..... > } > > sub _evt_stderr { > ..... > $event->GetProcess->GetStdErrBuffer; > ..... > } > > should reduce memory consumption on each process. > > Regards > > Mark > > > > Cornelius Bartke wrote: > >> Hi there. >> >> I have a question about Wx::Perl::ProcessStream and memory usage. >> >> My background is a long running GUI application that (from time to time) >> executes external commands, for example running rsync processes. In my GUI >> I'd like to give some feedback about what is happening. My plan was to have >> Wx::Perl::ProcessStream runs the rsync command and to use an eventhandler >> for STDOUT to process the output of a dry run (basically a long list of >> filenames). >> >> 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). I have built a test case (attached) to illustrate the behaviour. >> Just run a command that produces output on STDOUT a few times in a row and >> watch the memory usage of the perl process (using top or process manager). >> >> Now my questions: >> * is my usage of W:P:PS "correct" or am I misunderstanding the concept? >> * is this a known problem? I found nothing on the net so far. >> * is there a way force W:P:PS ro release allocated memory back to perl >> once it has processed STDOUT and the external process terminated? >> * do you have any other suggestions how to handle the scenario outlined >> above? >> >> I've had a look at Padre's background task handling but I wanted to avoid >> having to use threads ... >> >> Any help or pointers are appreciated! >> >> -Cornelius >> >> >> >