[R] Memory leak in system() command?

Duncan Murdoch murdoch.duncan at gmail.com
Tue Sep 7 12:50:56 CEST 2010


Rob Steele wrote:
> I run an external program a few hundred times via
>
> status <- system(command = "blah blah blah")
>
> and pretty soon Linux thinks R is using tons of memory.  R doesn't think
> so, at least not according to gc().  I'm also opening, reading and
> closing files but I don't think that's where the problem lies.
> Eventually the system command fails with a status of -1 and a message like:
>
> cannot popen 'blah blah blah', probable reason 'Cannot allocate memory'
>   

I think you need to put together a reproducible example.  When I try

repeat {
  system(command = "echo hello")
}

It just goes on printing hello over and over again, without growing the 
allocation.  This is on MacOSX, so your problem might be a Redhat thing, 
but just as likely it's something specific about your loop.

Duncan Murdoch
> Any ideas?
> Thanks!
>
>   
>> R.Version()
>>     
> $platform
> [1] "x86_64-redhat-linux-gnu"
>
> $arch
> [1] "x86_64"
>
> $os
> [1] "linux-gnu"
>
> $system
> [1] "x86_64, linux-gnu"
>
> $status
> [1] ""
>
> $major
> [1] "2"
>
> $minor
> [1] "11.1"
>
> $year
> [1] "2010"
>
> $month
> [1] "05"
>
> $day
> [1] "31"
>
> $`svn rev`
> [1] "52157"
>
> $language
> [1] "R"
>
> $version.string
> [1] "R version 2.11.1 (2010-05-31)"
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list