2

To be able to run the package extraTrees (which i need to make extreme randomised trees) I needed to install the Rjava package in my RStudio. The code below works perfectly when i use it in a limited amount of data (1000 observations..) However i need to be able to run the code on a dataset of 50 000-100 000 observations, an iterate it around 50 times...

library(rJava)
library(extraTrees)

et <- extraTrees(Input, Output, ntree = 300 ,nodesize=3, numRandomCuts=2, numThreads= 4)

When I try to run this I get the following error:

 Error in .jarray(m) : java.lang.OutOfMemoryError: Java heap space 

Does anyone know how to fix it? I have been looking for an answer but didn't find how to fit it in a RStudio environment.

2 Answers 2

3

The Xmx flag controls the size of the Java runtime heap. You can increase this to a larger value which may allow your R code to run without hitting the ceiling:

> options(java.parameters = "-Xmx4g")     # or 8g, or larger than this, ...

Note that this should increase the heap only for the Java process called by your R script. Outside R, whatever heap size was being used by your Java should remain the same. You could also change it externally if you wanted to.

I know about Xmx but did not know how to do this from within the R console. For that, I found this useful blog post:

http://www.bramschoenmakers.nl/en/node/726

Sign up to request clarification or add additional context in comments.

Comments

0

In my case I could solve that problem , using:

options(java.parameters = "-Xmx1024m")

before loading any packages or library.

Example:
> options(java.parameters = "-Xmx1024m")
> library(RJDBC)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.