Opening a zip causes OutOfMemoryError

Y

Yeah I Know

Guys,

I have been having a lot of problems with opening zip files in our web
application. It is deployed on Gentoo server (dual xeons, 4gb RAM)
running Tomcat 5.5.9.

Intially things are fine but after couple of days of running when you
try to upload a zip file, it throws an OutOfMemoryError even though it
has plenty of memory avialable. From doing a little bit of reading,
what I understand is that this has nothing to do with JVM's heap. But
when you upload a zip, the VM tries to allocate virtual memory (namap)
and in effect, it is this memory which gets exhausted.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705373

Does anybody know a workaround for this? May be there are some of you
who have already come across this problem.

Also, yesterday I saw this stack trace:

java.lang.OutOfMemoryError
java.util.zip.ZipFile.open(Native Method)
java.util.zip.ZipFile.<init>(ZipFile.java:112)
java.util.jar.JarFile.<init>(JarFile.java:127)
java.util.jar.JarFile.<init>(JarFile.java:92)

org.apache.catalina.loader.WebappClassLoader.openJARs(WebappClassLoader.java:1544)

org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:1763)

org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1570)

org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:850)

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1299)

org.apache.catalina.loader.WebappClassLoader.loadClass(Webapp



Has anybody seen stuff like this before...

I found something interesting on Caucho's website under
OutOfMemoryError section:
http://www.caucho.com/resin-3.0/troubleshoot/symptoms.xtp

"for .jar/.zip files (specifically ZipFile), the JDK allocates virtual
memory. If you have a large number of jars open, you can run into
problems. It's conceivable that a getResourceAsStream for a jar file
that wasn't closed would use up .jar memory"

It all sounds very confusing to me. What is .jar memory. Are we just
inventing terms just for the heck of it or is there such thing called
..jar memory?

Anyway, I would really appreciate your feedback, comments, experiences
- in fact anything on this topic.

Kind regards...
Arup Vidyerthy
 
R

Robert Klemme

Yeah said:
Guys,

I have been having a lot of problems with opening zip files in our web
application. It is deployed on Gentoo server (dual xeons, 4gb RAM)
running Tomcat 5.5.9.

Intially things are fine but after couple of days of running when you
try to upload a zip file, it throws an OutOfMemoryError even though it
has plenty of memory avialable. From doing a little bit of reading,
what I understand is that this has nothing to do with JVM's heap. But
when you upload a zip, the VM tries to allocate virtual memory (namap)
and in effect, it is this memory which gets exhausted.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705373

Does anybody know a workaround for this? May be there are some of you
who have already come across this problem.

For large files it's more efficient to use the stream base approach IMHO:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/ZipInputStream.html
Also, yesterday I saw this stack trace:

java.lang.OutOfMemoryError
java.util.zip.ZipFile.open(Native Method)
java.util.zip.ZipFile.<init>(ZipFile.java:112)
java.util.jar.JarFile.<init>(JarFile.java:127)
java.util.jar.JarFile.<init>(JarFile.java:92)

org.apache.catalina.loader.WebappClassLoader.openJARs(WebappClassLoader.ja
va:1544)
org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappCl
assLoader.java:1763)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClass
Loader.java:1570)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.j
ava:850)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.j
ava:1299)

org.apache.catalina.loader.WebappClassLoader.loadClass(Webapp



Has anybody seen stuff like this before...

I found something interesting on Caucho's website under
OutOfMemoryError section:
http://www.caucho.com/resin-3.0/troubleshoot/symptoms.xtp

"for .jar/.zip files (specifically ZipFile), the JDK allocates virtual
memory. If you have a large number of jars open, you can run into
problems. It's conceivable that a getResourceAsStream for a jar file
that wasn't closed would use up .jar memory"

It all sounds very confusing to me. What is .jar memory. Are we just
inventing terms just for the heck of it or is there such thing called
.jar memory?

No, there is not. He's probably talking about the memory occupied by the
jar file.
Anyway, I would really appreciate your feedback, comments, experiences
- in fact anything on this topic.

Kind regards

robert
 
Y

Yeah I Know

Hi Robert,

Thanks for your prompt reply.

I will try out using ZipInputStream and see if that improves the
situation on our server. I will post back my findings in a couple of
days.

In the mean time, thanks for your suggestion.

Kind regards...
Arup
 
Y

Yeah I Know

Hi Robert,

Using ZipInputStream has seemed to help and now I dont get the OOME
anymore... well its been two days and no problem.

So thanks a lot again.

Arup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top