in reply to Re: Peculiar Perl/R Problem - Memory?
in thread Peculiar Perl/R Problem - Memory?

OK, I've tried a few more things to test what the effects on the problem would be, now I know what the likely cause is.

->Eliminating the read commands did not affect the problem. The script still halts at arbitrary points in the loop even without the 'read from R' element.
->Restarting R at the end of the foreach loop (using the command $R -> restartR();) prevented the random halting. However, as you might expect the script is very slow with this workaround in place, since it has to load R anew with each iteration of the loop.

I am somewhat new to the use of modules in my scripts, and completely so to IPC buffering, so any more guidance you could provide into how to implement the autoflush would be very much appreciated.

Thanks for your help, M

  • Comment on Re^2: Peculiar Perl/R Problem - Memory?

Replies are listed 'Best First'.
Re^3: Peculiar Perl/R Problem - Memory?
by maybeD (Sexton) on Aug 10, 2005 at 10:45 UTC
    Update: Although because of the (greatly complicated) Perl module that this script is reliant on I wasn't able to try a lot of the suggestions, a simple modification has reduced the incidence of the problem to a much more acceptable level (now about 1 in 8 of the times the script is run). The modification is as follows:
    $R_send_0 = "$R_comment_out$R_line0"; $R_send_1 = "$R_line1$R_line2$R_line3$R_line4$R_line5"; $R_send_2 = "$R_dblquotation_start$R_line6$R_send_3"; my $r_send_comment = $R_send_0; my $r_send_string = $R_send_1; my $r_send_string2 = $R_send_2; $R->send (qq'$r_send_string'); $R->send (qq'$r_send_string2'); my $ret = $R->read; push (@R_output_store, $r_send_comment); push (@R_output_store, $ret); print $ret; print "\n\n";
    has been changed to:
    $R_send_0 = "$R_comment_out$R_line0"; $R_send_1 = "$R_line1$R_line2$R_line3$R_line4$R_line5"; $R_send_2 = "$R_dblquotation_start$R_line6$R_send_3"; $R_send = "$R_send_1\n$R_send_2"; my $r_send_comment = $R_send_0; my $r_send_string = $R_send; $R->send (qq'$r_send_string'); push (@R_output_store, $r_send_comment); print $r_send_comment; print "\n"; my $ret = $R->read; push (@R_output_store, $ret); print $ret; print "\n\n";
    The program as I say is still not completely free of problems. The freezing continues to occur at a low frequency, and a warning message of the form: 'Warning Message: cannot open file 'input.4.r' is sometimes displayed at the end of the screen-printed output.