0

I'm trying to load a binary decision tree into R; but I get the error: Error: cannot allocate vector of size 2.0 Mb. The file size is actually 900 MB

enter image description here

My PC's specs are:

Processor Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz 1.80 GHz

Installed RAM 8.00 GB (7.85 GB usable)

System type 64-bit operating system, x64-based processor

Pen and touch No pen or touch input is available for this display

With my working environment fully loaded, it's telling me I'm only using 600 B of memory. Even though when I clear it with the same syntax, it manages to find 1.87 GB worth of stuff to erase.

> object_size(list = ls())
600 B
> mem_change(rm(list = ls()))
-1.87 GB
> object_size(list = ls())
48 B

With at least 1.87 GB of unused memory in my working environment, I attempt to load in the 900 MB file:

>   load("testtree.RData")
Error: cannot allocate vector of size 2.0 Mb

In its failed attempt, the used memory ballooned up to over 4 GB. Here's the before:

enter image description here

And here's what it looks like while trying to load:

enter image description here

My background processes are taking up 30-40% of memory. I've read that I can buy more RAM, but I'd rather optimize the use of what I already have.

Why does it take R 4.6 GB to open a 900 MB file? What is the actual limit to my working environment? Is there a coding solution to loading this file?

DataProphets
  • 156
  • 3
  • 17
  • 1
    When R saves files, it compresses them, but in memory they are uncompressed. You'll need to get more memory or break your file up into smaller pieces if you want to read it on that machine. – user2554330 Oct 02 '22 at 13:04
  • That makes sense; but, my MAC desktop, which also has 8 GB of RAM, can load and work with the file. So, it can't purely be a function of physical memory, can it? – DataProphets Oct 02 '22 at 14:51
  • 1
    R doesn't have access to all 8 GB. You said 30-40% is used by other processes, and during a session, the memory used by R doesn't necessarily make perfect use of available space: deleted objects may leave gaps too small for whatever it is trying to allocate for the new object. – user2554330 Oct 02 '22 at 15:49

0 Answers0