• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Heap Space Error

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm launching applet from jsp. For some data its working fine. when the data are really too big,its throwing Java heap space error. I increased the JVM to -Xmx512m
in Java Runtime Environment Settings.

But still getting the same error. If i run from html i'm not getting the error. Only when i launch it from Jsp i'm getting this error. I'm using Tomcat 5.5
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the exception happening, on the server (JSP Tomcat side) or in the browser (Applet sandbox).

Can you post the relevant part of the stacktrace?
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getting browser.


Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Java heap space
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:433)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

javax.servlet.ServletException: Java heap space
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.index_jsp._jspService(index_jsp.java:118)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

java.lang.OutOfMemoryError: Java heap space


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, you're seeing the error in the browser but the OOME is happening on the server within Tomcat.

Without seeing your code it will be impossible to tell what's causing this.
Probably 90% of the times that I've seen an OOME like this, it's due to something causing an infinite recursive loop.

Can you post the code to the JSP that you're hitting when this happens?

 
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can increase heap size for Tomcat.
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i believe it can't be due to infinite loop. because i getting this error in a place where i tried to reterive data from a database.From database i will get a xml. the xml is really a huge on.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinoth Thirunavukarasu wrote:You can increase heap size for Tomcat.



It's always a good idea to read all the post in a thread before suggesting a solution.
In this case, you'll notice that the original poster already mentioned increasing heap size in his first post.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just how big is this XML String?

If it's big enough that one call uses up all the ram you have in a JVM with 512m allotted, then it's probably more than what you want to be loading into a JSP to pass to an applet. You might find that increasing the heap space further will stop the problem in Tomcat but I suspect that you're going to run into issues either with the network or in the client.

Have you considered restructuring your app to first load the applet and then have the applet make calls to the server to get chunks of XML data as it needs it, instead of trying to pass the whole thing to your applet right up front?
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should i have to increase m/y space for tomcat seperately? I have just set the memory space in control Panel --->java ---->java ---->runtime settings.

have to set for Tomcat seperately?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have the Tomcat manager app installed log into it and go to the Server Status page.
It will show you how much ram is allocated to Tomcat's JVM.

How to increase the heap space for Tomcat depends on which OS you're using and how you've installed Tomcat.
 
Vt Guru
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Just add
export JAVA_OPTS="-Xmx128000000 " in catalina.sh or .bat file In this way I had done.
We have already discussed about this webpage


@Ben Souther
I made that solution He haven't increased heap size for tomcat.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinoth Thirunavukarasu wrote:Just add
export JAVA_OPTS="-Xmx128000000 " in catalina.sh or .bat file



Again, how you do this depends on how you've installed Tomcat.
If it's been installed as a Windows service, your instructions won't work because the catalina wrapper files never get run.
 
Vt Guru
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are right.
Thanks for notifying me.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First it is a good idea to move this piece of code out from JSP to a Java class. It may not help you with the OutOfMemoryError but it is a good practice..

What is the size of the xml you store in your database column?

Usually BLOB datatype is used for storing such huge amount of Data. Instead of loading the entire data into a String i would suggest you to get an InputStream for this BLOB and use SAX parser to parse it.
I am sure not all details in the file needs to be passed to the client

Not sure if increasing the Heap size would help to a great extent, more the number of users more the memory usage and more the chances of OOME, you need to redesign somewhere.

If you can give some details of what you are trying to achieve maybe somebody can throw some light on it.
 
Greenhorn
Posts: 3
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To avoid this issue.I simply stop writing the data's into excel instead of that i write data's into streams and retrieved from that. here the code snippet.

reply
    Bookmark Topic Watch Topic
  • New Topic