Error: cannot allocate vector of size 5.1 Gb (32 GB RAM)


I am trying to work on the big raster

[1] 1e+13
wh_chm_p2r = locate_trees(chm_p2r_vr, lmf(f_h, hmin = 4, shape = "circular"), uniqueness = "incremental")

I have the error "Error: cannot allocate vector of size 5.1 Gb" and 32,0 GB RAM.
Is there something I can do to solve this problem? Even for that one operation?

If you are on macOS/Linux, you may need to adjust ulimit (see the man documentation) because the OS does not allow any one process to use more than that amount of RAM.

1 Like

I am working on Windows, so I suppose this will not work...?

There may be something comparable, but I have just not had to do anything under Windows since I gave up waiting for Vista to come out.

1 Like

I did memory.limit(99999999999999) but maybe there is something more.

I don't have a solution for you but I'll explain a liittle to you about your issue ; (as far as I know, and if I'm mistaken I hope to be corrected : )
in R a vector's memory must be contigious ; i..e if memory is fragmented, whilst there may be many Gb's of free memory if all free parts are summed together, this alone does not say what the single large continous piece of free memory might be.

1 Like

chm_p2r_vr - this is virtual raster made for about 1000 tif. I also tried to merge all the tifs together and then raster::raster on one big tif raster, not virtual, but it did not help.
I am trying to avoid duplicate trees if I cut the raster (the same tree which will be on the border on the one raster will be also on the second one).

How much memory does it take to load one such tif ?
pryr/lobstr packages have functions to more accurately tell the size of an R object; though base R's object.size() may often work also.

1 Like

Thanks for your tips. I turn on computer again, turn off all the other applications, in R read only packages I use, use memory.limit(999999999), raster on disk = on, gc() and somehow it worked... I think that I am just lucky in this situation, but maybe someone will have similar problem.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.