Skip to main content

OutOfMemoryError: Java heap space --> How to fix this

10 replies [Last post]
tmilard
Offline
Joined: 2004-03-25
Points: 0

Hello my java3D colleagues and Friends.
I am aware thet this memory issue from the JVM should perhaps be elsewere than on this java3D forum .... but well I like this forum.

Before:
- I am using a recent 4G Bytes computer.
- The parameters I put for my Applet is -Xms1290m -Xmx1290m
- I load about 30 10MB-photos.

Present :
- At the 22 photos I get the infamous "OutOfMemoryError: Java heap space"
- I tryed to put more heap space ( -Xms2000m -Xmx2000m ) but the OutOfMemory exception is raised also at the 22th photo about when my applet uses 1300 M bytes of memory. It seems there is a CAP on the memory heap space I can give to the JVM.... (?)

Furure/questions :
- I really would love to have a heap space bigger than 1290MBytes. Is is possible. I have windows7-with-64bit

- I wonder if it is not possible to give the JVM a memory-space (ie heap space) that never crash [I mean when there is no physical memory it saves the memory pages on the hard drive... without crashing].

Thanks for your time reading this. Don't hesitate to educate me about the heapspace things on the JVM.... I am no expert at all ;)

Thierry Milard
free-visit.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tmilard
Offline
Joined: 2004-03-25
Points: 0

> (running 64 bit JVM )

- One last things, I succeded in running a JVM "inside my java dev tool".
- But I failed to understand how in JNLP we ask to run a 64 bit JVM", in place of a standard 32 bit one. (even my friend google is speachless...).

[b]Question :
[/b]Is it by putting -d64 inside the java-vm-args of the tag ?

Explanations :
1) Default 32 bit JNLP Tag :


1) The 64 bit JNLP tag [is it -d64 ?] :

Thank for your help.
Thierry Milard
free-visit.net

darwinjob
Offline
Joined: 2004-11-16
Points: 0

>Question 2 : Even if this is the reason, does it mean that all the 32 bit Pc won't use my applet ?

If you want more then 1300M memory - then no.

Alternately, you can take a look at JAI/JAI-IMAGEIO projects. They deal with huge images in very smart way. In short: you can keep the originals, crop ROI and get down-sampled versions at any time you need without keeping the images in the memory. In this case you can fit into 32bit environment.

tmilard
Offline
Joined: 2004-03-25
Points: 0

> IMHO the problem here is an applet itself. It runs
> via plugin, so you have to use 64bit browser AND
> 64bit plugin. That 1300M cap seems like you are still
> in 32bit environment.

SUCCESS !!
Here is what I have managed to do :
-- I did install the java jvm for 64 bit machines.
-- I also had to install a specific version of the java3D Direct3D dll :' link http://www.zumodrive.com/share/6YuzZTc1MD )

And now I can with Success give the Heap a (big) 3000 MegaByte memory cap.
I tested it, it works fine.

Thanks again for your helpfull answers.

Thierry
www.free-visit.net

grelf
Offline
Joined: 2007-11-14
Points: 0

I believe the problem is not due to heap space at all, but to the parallel garbage collector that is used by default in 64-bit JVMs. Unfortunately it fails with Out of memory errors, which make everyone investigate the wrong thing.
I have posted my humble summary of the situation here: http://forums.oracle.com/forums/thread.jspa?threadID=1773080&tstart=0

in the (probably forlorn) hope that someone at Oracle will take note and do something.

aces
Offline
Joined: 2003-07-17
Points: 0

Avoid using large initial memory , i.e. -XMS parameter. It slow down start up.

A tip : after you load a photo for internal use, you can resize it down. There are some nice filters for downsizing as java.awt.image.AreaAveragingScaleFilter.

Of course it is not applicable for some applications, but for 3D the max recomended size is 2048x2048, while 1024x1024 already gives first class textures.

tmilard
Offline
Joined: 2004-03-25
Points: 0

> Avoid using large initial memory , i.e. -XMS
> parameter. It slow down start up.
--> Ok. Got it...

> A tip : after you load a photo for internal use, you
> can resize it down. There are some nice filters for
> downsizing as
> java.awt.image.AreaAveragingScaleFilter.
> Of course it is not applicable for some applications,
> but for 3D the max recomended size is 2048x2048,
> while 1024x1024 already gives first class textures.
---> Yes but my applet is a bit like photoshop : Yon't won't exort a full 2048x2048 for 3D ... but you keep it full size in the software ... because the user might select the small uperright corner : If you have resized it before the quality of the 3D texture will therefore be too bad.

Ps :This limitation of the jvm is really something they should put in priority URGENT.
It's incredible with an average computer having 4GB of memory.

darwinjob
Offline
Joined: 2004-11-16
Points: 0

IMHO the problem here is an applet itself. It runs via plugin, so you have to use 64bit browser AND 64bit plugin. That 1300M cap seems like you are still in 32bit environment.

Go here:
http://www.java.com/en/download/help/testvm.xml

and see what architecture you have.

tmilard
Offline
Joined: 2004-03-25
Points: 0

> IMHO the problem here is an applet itself. It runs
> via plugin, so you have to use 64bit browser AND
> 64bit plugin. That 1300M cap seems like you are still
> in 32bit environment.
>
> Go here:
> http://www.java.com/en/download/help/testvm.xml
>
> and see what architecture you have.

Thanks, I gave it a try. It says this :
"Vendor: Sun Microsystems Inc. Version: Java 6 Update 21 Operating System: Windows 7 6.1 Architecture: x86 "
- Is this suppose to say I am using a 32 VM ?

Question 2 : Even if this is the reason, does it mean that all the 32 bit Pc won't use my applet ?

darwinjob
Offline
Joined: 2004-11-16
Points: 0

>Architecture: x86
You are in 32bit mode. For 64bit this field is AMD64. AFAIK the only official 64 bit browser is IE, so I strongly recommend to switch from an applet to an application and deploy it via WebStart.

tmilard
Offline
Joined: 2004-03-25
Points: 0

> >Architecture: x86
> You are in 32bit mode. For 64bit this field is AMD64.
> AFAIK the only official 64 bit browser is IE, so I
> strongly recommend to switch from an applet to an
> application and deploy it via WebStart.
---> Yes this is what I do. I do use JWS.