0

I'm relatively new to R and seem to be having a memory limit issue with a new laptop. When I run a large dataset of about 50K survey respondents and over 500 variables I receive the error message: Error: cannot allocate vector of size 413 Kb

I got around this issue fine on my old laptop by increasing the memory limit size via the code: memory.limit(size = 10000). Everything worked fine but on my new laptop which is faster and more powerful, the memory limit fills up very fast and will crash at size 27000 after I run about 7 models.

I have tried closing all unnecessary programs, removing all the unneeded objects in R, and clearing the garbage can: gc(). I was using latest version of R 4.14 and have now gone back to 4.04 where it worked fine on my old PC - but none of these help really.

I am running the 64bit version of R on a 64bit PC that has 8GB capacity.

Does anyone know why this might be occurring on a brand new laptop that runs faster while running slower on my 4-year old PC but atleast worked with it.

Also, how high can you set the memory limit as the manual says R can handle 8TB? And how do you permanently set a memory limit?

Thanks

  • Suggested duplicates [increasing or decreasing memory limit available to R processes](https://stackoverflow.com/q/1395229/903061) or the FAQ [R memory management / cannot allocate vector of size n Mb](https://stackoverflow.com/q/5171593/903061) – Gregor Thomas Nov 17 '21 at 20:10
  • 1
    That seems very strange. I don't think there's any point in setting the R memory limit beyond how much RAM you have--the R manual saying R can handle 8TB means that if you have a computer with 8TB of memory, R can use it. My best guess would be bloatware that came installed on your new computer. Open up the windows Resource Monitor and see what programs are using your memory. The only R-based possibility I can think of is if your new data is "bigger" in some way than your old data - maybe some of your 500 columns have categories with 1000s of levels and a model matrix size blows up... – Gregor Thomas Nov 17 '21 at 20:14

0 Answers0