Cina Cina - 1 month ago 16
R Question

clear memory allocated by R session (gc() doesnt help !)

I am doing machine learning in large scale but after while my compute getting so slow because of R memory occupation.

I cleared my objects and also I tried

gc()
and the result:

used (Mb) gc trigger (Mb) max used (Mb)
Ncells 4460452 231.5 15288838 1116.6 36599071 1954.7
Vcells 29572776 349.4 324509788 2712.9 350796378 3376.4


My task manager shows R session still allocated over 3GB of my memory and my computer is still slow.

How can I release the memory taken by R? (I don't want restart the pc)

Answer

best solution i found is restarting R session. in R studio ctr+shft+f10

and if you dont want to save workspace

makeActiveBinding("refresh", function() { system(paste0(R.home(),"/bin/i386/R")); q("no") }, .GlobalEnv)

paste0(R.home(),"/bin/i386/R --no-save") #--save will save workspace

cheers.