0

If R is no longer using some memory and has not released it, if I do a system() call to run another process, it gives Cannot allocate memory error. Why does R automatically not release memory here?

Even multiple gc() calls do not help many times instantaneously...

Miha
  • 2,559
  • 2
  • 19
  • 34
cryptickey
  • 169
  • 8
  • related to https://stackoverflow.com/questions/53211195/why-system-command-in-r-are-very-memory-intensive – abhiieor Feb 25 '19 at 13:15
  • `gc()` runs when there is need of extra memory, not perfectly though like other languages https://stackoverflow.com/questions/1467201/forcing-garbage-collection-to-run-in-r-with-the-gc-command and https://stackoverflow.com/questions/14580233/why-does-gc-not-free-memory but `system()` somehow demands so big that freed up memory is not enough for it. If possible try doing without system command. – abhiieor Feb 25 '19 at 15:02
  • When I run a vanilla R session, there system can allocate memory, as in the linked question. Is it the max memory allocated to a process kicks in ?. Actually I am using R markdown, which internally calls the system command, so I might not have control over it...How did you work around your issue ? – cryptickey Feb 25 '19 at 15:05
  • Both R and the operating system are lazy: they won’t reclaim memory until it’s actually needed. R might be holding on to memory because the OS hasn’t yet asked for it back. http://adv-r.had.co.nz/memory.html – cryptickey Feb 25 '19 at 15:53

0 Answers0