Question

I am building a large species distribution model using the package "dismo" in the latest version of r. When I go to process the basic model using the code:

me <- maxent(x=train, p=p)

I get the following error:

> Error in .jcall(mxe, "S", "fit", c("autorun", "-e", afn, "-o", dirout,
> :    java.lang.OutOfMemoryError: unable to create new native thread

There is some discussion in stackoverflow and the internet about this error but none seem to address how to resolve the issue in the r code. Any input on this issue would be appreciated.

Cheers, Israel

Was it helpful?

Solution

from the dismo package: If you want to give MaxEnt (the Java virtual machine that runs it) more memory, you can do that by running something like this (for 1 GB) before you load the dismo library.

options(java.parameters = "-Xmx1g" )

Some people have reported problems when using this function on a Mac (Apple) computer. Specifically, the following error message occurs:

Error in .jcall(mxe, "S", "fit", c("autorun", "-e", afn, "-o", dirout, : java.lang.InternalError: Can’t start the AWT because
Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line.

This is a known problem with certain Java applications on Macs. There are two work-arounds that we are aware of:

1) run Sys.setenv(NOAWT=TRUE) before running library rJava (this is what dismo does if rJava is not loaded). 2) use the JGR interface (a Java based R GUI). You can install JGR from here:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top