r - Memory leak with closed connections -


i have r application interacting java daemon via stdin , stdout in infinite loop, seems have memory leaks. simplified r app:

while (true) {     con <- file('stdin', open = 'r', blocking = true)     line <- scan(con, = character(0), nlines = 1, quiet = true)     close(con) } 

this loop ends using more , more ram, , if manually gc() after close(con) call, memory footprint seems ok while, grows forever.

a basic script confirm this:

rscript --vanilla -e "while(true)cat(runif(1),'\n')" | rscript --vanilla -e "cat(sys.getpid(), '\n');while (true) {con <- file('stdin', open = 'r', blocking = true);line <- scan(con, = character(0), nlines = 1, quiet = true);close(con);gc()}" 

this start 2 r processes: 1 writing stdout , other reading stdin connected pipe (and second printing pid can monitor related memory usage):

enter image description here

i'm not sure i'm doing wrong, love stop memory leak highly appreciated.

indeed (about reading on r-devel); notably, memory leak has been plugged in development version of r, patch gabor csardi.


Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -