1

I am running R 64 bit on windows 7 64 bit. While running my script, I get an error message that cannot allocate a vector of size x (in my case about 200MB). My data.frame has about 200.000 rows, not more. How can it happen that there is not enough storage space to allocate another vector? I know that the operation itself works since the script runs through with a smaller, subsetted file.

I know too that this question has been asked before but none of the answers solved my problem. there are many different answers out-there which one is correct? Is it related to the RAM of the system or of the memory of R?

I increased the memory size manually:

memory.limit()
# set max memory usage is 2G
memory.size(max=10000)

Then r says that the memory limit is 10.000

memory.limit()
[1] 10000 

but still there is the same error. it is even the same size of the vector that cannot be allocated.

I cleaned up my computer and set more space free on my drive too. but it doesn´t change anything either.

On what is the memory size dependent and how can I increase it?

Jaap
  • 81,064
  • 34
  • 182
  • 193
Ben Mat
  • 31
  • 1
  • 1
  • 8
  • 1
    Could you provide an [example that reproduces the problem](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610)? It might also be a result of how you've written your code. – Jaap Jan 08 '18 at 11:10
  • 2
    Related: [*Memory management / cannot allocate vector of size n Mb*](https://stackoverflow.com/questions/5171593/memory-management-cannot-allocate-vector-of-size-n-mb) – Jaap Jan 08 '18 at 11:14
  • 1
    One of the calculations you do needs a lot of memory. Memory demand can grow quadratic or worse with data size. Without showing your code in a reproducible example there is not much advice to give. You could profile memory demand with increasing data size and predict what you'd need for the whole dataset. – Roland Jan 08 '18 at 11:15
  • ok, thank you for this short explanation. sometimes some background info is enough. I will try to split the code and get rid of some rubbish. – Ben Mat Jan 08 '18 at 12:58

1 Answers1

0

Like people have been commenting, one would need to see your actual code for more specific answers.

However, a couple of general things you could consider are:

i) using remove() or rm() functions within your script on auxiliary / intermediate objects / results

ii) read the help of the gc() function, which triggers the garbage collection explicitly (which should usually not be necessary but there are cases where this is justified)

RolandASc
  • 3,863
  • 1
  • 11
  • 30