Limit use of RAM in R

Asked

Viewed 396 times

2

I’m running some analysis and would like to fix the use of RAM in R to be able to use other software simultaneously without any problem. So I’d like to, for example, limit the 4gb of RAM memory, even if it makes the analysis take longer.

I tried this strategy available here, where a limit is created in the properties of the program, but it does not work.

I am currently working with calculation of distance matrices 62 variables x 60 thousand observations.

Another option was to use H20, but I end up using more RAM because I have to call JAVA.

  • 1

    I don’t understand anything of [tag:r], but the whole problem seems to me some more "error" of how he designed the script, for example, the LACK of a delay between a series of operations and another would cause such a problem if the algorithm is written well and with a good strategy it is likely that memory consumption rarely needs absurd 4GB (all this seems to me an exaggeration, but I may be wrong).

  • 1

    Tried this: https://stackoverflow.com/a/1395256/1518921 ?

  • 3

    Try memory.limit(size = 4000). If you are concatenating multiple analyzes, it is also a good idea to clear the workspace at each step, e.g. saving objects in files, deleting objects that will no longer be used and using gc() to wipe the memory.

  • Thanks @Guilhermenascimento, maybe I’m programming the code a little wrong. Because I am doing a relatively heavy analysis, I will try to introduce time between them. R is occupying my RAM completely.

  • @Carloseduardolagosta, thanks for the statement. I didn’t know the gc() command and I will test the memory limit this way. In fact I am accumulating mt objects throughout the code, I will try to eliminate them. Every case I think q analysis of Space Join is kind of heavy.

  • @Carloseduardolagosta gave this error: In memory.limit(size = 4000) : cannot decrease memory limit: Ignored, I’m looking for how to resolve, but nothing solvable so far

  • If you’re running a heavy analysis and/or a lot of data, then go for code optimization instead of trying to limit the use of RAM. But this is a very broad topic.

  • Which Operating System are you running the analysis on? Share the result of sessionInfo(), can help us understand the case

  • I am using Windows 7 64bits, the version of R is 3.6.1. R version 3.6.1 (2019-07-05) Platform: x86_64-W64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 The analysis in thesis is simple in terms of commands is three commands: 2 are to open the files and the last is to perform space Join between polygon and points Shape.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.