Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

 
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans
View previous topic :: View next topic  
Author Message
juniormember



Joined: 28 Jun 2008
Posts: 154

PostPosted: Fri Nov 21, 2008 5:53 am    Post subject: java.lang.OutOfMemoryError: Java heap space Reply with quote

Hi,
I am using a java method in my web application in that i have to use recursive queries to fetch data in tree format. But when i execute query i get exception of java heap size space, and execution terminated.
Quote:

javax.servlet.ServletException: java.lang.OutOfMemoryError: Java heap space
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


Please tell me to remove this error
Back to top
View user's profile Send private message
javatech



Joined: 19 Jan 2007
Posts: 39

PostPosted: Fri Nov 21, 2008 11:07 am    Post subject: Reply with quote

Two ways to remove java heap space exception from your program.

1. Difficult
2. Easy

Difficult way is to reconsider your logic once again. Check your recursive query and rows, and how much space it take in memory. How much rows you are fetching from database and populate on web page. All things should think twice, and use other things like pagination and fetch limited records in web page.

Easy way is to remove java heap size to increase JVM allocated memory. By default, it is less, 64MB .
You can increase this JVM memory size by modifying environment variables parameter
Back to top
View user's profile Send private message
seniormember
Site Admin


Joined: 20 Jul 2008
Posts: 77

PostPosted: Sat Nov 22, 2008 5:16 am    Post subject: Reply with quote

Right easy way and hard way to remove heap space error.

I will tell you to check your source code, why you are getting this heap error in your program. One thing you can also try, remove unwanted jar file from your application which use memory space. Most of people copy all jar file or API which they are not using in their application and tomcat load these API also when it booted. Use simple queries instead of recursive queries, if one problem in database record which means recursive become indefinite and execute never end, result to heap space error.

Check database logic too
Back to top
View user's profile Send private message
pruthivi.r@gmail.com



Joined: 16 Dec 2008
Posts: 1

PostPosted: Tue Dec 16, 2008 2:50 pm    Post subject: Reply with quote

Hello, I\'m getting error of this kind when running an application: SEVERE: Servlet.service() for servlet jsp threw exception java.lang.OutOfMemoryError: PermGen space
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack