Discussion:
[stats-rosuda-devel] How to increase java heap size?
Willem Ligtenberg
2011-02-09 10:16:51 UTC
Permalink
Hi,

While using the xlsx package to read xlsx files, I get an error that
it has run out of java heap space.
However, I can't seem to find a way to increase the heap size.
I have found that this should do the trick:
options( java.parameters = "-Xmx1200m" )

Xlsx still crashes and didn't seem to take more memory.
Therefore, I tried to see what the maximum available amount of heap
space is in an instance.
By:
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")

returning:
16318464
and:
259522560

I have also tried the following:
.jinit(parameters="-Xmx1200m")
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")

Same result.

And I have just found:
system("java -Xms512m -Xmx1536m")
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")

And that also yields the same result.

Of course, I might be doing the measurement wrong, however I tested it
on another machine and it gave other results...
Could someone please help me with a good way to get at the available
heap space, and how to increase it for RJava?

Kind regards,

Willem
Simon Urbanek
2011-02-09 16:25:32 UTC
Permalink
Willem,
library(rJava)
options( java.parameters = "-Xmx1200m" )
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
[1] 85000192
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
[1] 1242562560

What really happens depends on your Java implementation - depending on the OS and Java it can refuse requests that are too big for your machine so it will revert to the default. So try clearing up some memory on your machine or lower your limit. Note that on 32-bit systems you'll need contiguous memory of that size for the heap. You didn't say which OS you use but some of the less capable OSes like 32-bit Windows have hard time providing large contiguous memory to applications.

Cheers,
Simon
Hi,
While using the xlsx package to read xlsx files, I get an error that
it has run out of java heap space.
However, I can't seem to find a way to increase the heap size.
options( java.parameters = "-Xmx1200m" )
Xlsx still crashes and didn't seem to take more memory.
Therefore, I tried to see what the maximum available amount of heap
space is in an instance.
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
16318464
259522560
.jinit(parameters="-Xmx1200m")
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
Same result.
system("java -Xms512m -Xmx1536m")
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
And that also yields the same result.
Of course, I might be doing the measurement wrong, however I tested it
on another machine and it gave other results...
Could someone please help me with a good way to get at the available
heap space, and how to increase it for RJava?
Kind regards,
Willem
_______________________________________________
stats-rosuda-devel mailing list
stats-rosuda-devel at listserv.uni-augsburg.de
http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel
Willem Ligtenberg
2011-02-09 19:21:59 UTC
Permalink
Hi Simon,

Unfortunately, the machine I am trying this on runs Windows XP 32 bit.
(3GB RAM).
Which might explain the issues. Then my methods aren't wrong, but the OS is. :)
Thanks for the information, also that my method of checking the heap
space is right.

Cheers,

Willem
Post by Simon Urbanek
Willem,
library(rJava)
options( java.parameters = "-Xmx1200m" )
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
[1] 85000192
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
[1] 1242562560
What really happens depends on your Java implementation - depending on the OS and Java it can refuse requests that are too big for your machine so it will revert to the default. So try clearing up some memory on your machine or lower your limit. ?Note that on 32-bit systems you'll need contiguous memory of that size for the heap. You didn't say which OS you use but some of the less capable OSes like 32-bit Windows have hard time providing large contiguous memory to applications.
Cheers,
Simon
Hi,
While using the xlsx package to read xlsx files, I get an error that
it has run out of java heap space.
However, I can't seem to find a way to increase the heap size.
options( java.parameters = "-Xmx1200m" )
Xlsx still crashes and didn't seem to take more memory.
Therefore, I tried to see what the maximum available amount of heap
space is in an instance.
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
16318464
259522560
.jinit(parameters="-Xmx1200m")
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
Same result.
system("java -Xms512m -Xmx1536m")
.jinit()
.jcall(.jnew("java/lang/Runtime"), "J", "totalMemory")
.jcall(.jnew("java/lang/Runtime"), "J", "maxMemory")
And that also yields the same result.
Of course, I might be doing the measurement wrong, however I tested it
on another machine and it gave other results...
Could someone please help me with a good way to get at the available
heap space, and how to increase it for RJava?
Kind regards,
Willem
_______________________________________________
stats-rosuda-devel mailing list
stats-rosuda-devel at listserv.uni-augsburg.de
http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel
Continue reading on narkive:
Loading...