aspose file tools*
The moose likes JDBC and the fly likes Java Memory Heap Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java Memory Heap Exception" Watch "Java Memory Heap Exception" New topic
Author

Java Memory Heap Exception

anil katta
Greenhorn

Joined: Jun 18, 2008
Posts: 5
I am using dbutils to connect to data base using following resource in context.xml

<Context path="/SFE" reloadable="true">
<Resource name="jdbc/salesForce" auth="Container" type="javax.sql.DataSource"
connectionProperties="databasename=salesforcerpt_dev"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
maxActive="10"
maxIdle="-1"
maxWait="5000"
initialSize="10"
password="salesforce"
removeAbandoned="true"
url="jdbc:sqlserver://myauvwv00100430:1433"
username="salesforceuser"
validationQuery="select 1"
/>
</Context>


now my application is throwing java.sql.SQLException: The system is out of memory. Use server side cursors for large result sets:Java heap space. Result set size:42,174,756. JVM total memory size:1,069,678,592.

please could you help me out
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What heap size is your JVM using? Have you tried increasing this?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
anil katta
Greenhorn

Joined: Jun 18, 2008
Posts: 5
java.sql.SQLException: The system is out of memory. Use server side cursors for large result sets:Java heap space. Result set size:42,174,756. JVM total memory size:1,069,678,592.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

OK. And have you tried increasing the available heap?
anil katta
Greenhorn

Joined: Jun 18, 2008
Posts: 5
there is lot of heap size rite.. please let me know how to increase a web application heap size
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

1Gb for a web applicaton? It depends on the load its under, but I wouldn't consider that that big. If you are not doing much with the application and its hitting this sort of limit you probably have to go an investigate what your application is doing (are you caching loads of stuff in the session? are you returning huge result sets? Are you releasing JDBC resopurces when you don't need them? etc. )

Assuming its a Sun JVM, this will tell you how to increase heap size.
anil katta
Greenhorn

Joined: Jun 18, 2008
Posts: 5
yes I'm returning Huge resultset..
in this what i need to do could you please guide me...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Huge result sets usually don't really have a place in web applications; are you really expecting users to wade through tens of thousands of results? Or just look through the first twenty and search again?

The usual way to handle this is to use paging. Have a search through this forum, there are hundreds of examples.
anil katta
Greenhorn

Joined: Jun 18, 2008
Posts: 5
There is already a paging functionality included for the same. but still it comes.. could you please guide me for other alternatives

I tried with
<Context path="/SFE" reloadable="true">
<Resource name="jdbc/salesForce" auth="Container" type="javax.sql.DataSource"
connectionProperties="databasename=salesforcerpt_dev"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
maxActive="10"
maxIdle="-1"
maxWait="1000"
initialSize="10"
password="salesforce"
removeAbandoned="true"
url="jdbc:sqlserver://myauvwv00100430:1433"
username="salesforceuser"
validationQuery="select 1"
/>
</Context>

keeping maxIdle to -1 and inserted a initialiSize to 10.. it is not giving any exception so called Java memory heap but some times socket connection is not getting

java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:531)
at org.apache.jk.common.JkInputStream.endMessage(JkInputStream.java:121)
at org.apache.jk.core.MsgContext.action(MsgContext.java:304)
at org.apache.coyote.Response.action(Response.java:183)
at org.apache.coyote.Response.finish(Response.java:305)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:276)
at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:104)
at org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader.writeResource(MyFacesResourceLoader.java:244)
at org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader.serveResource(MyFacesResourceLoader.java:217)
at org.apache.myfaces.renderkit.html.util.DefaultAddResource.serveResource(DefaultAddResource.java:606)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:128)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:209)
at org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:347)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)


Could you please guide me Paul??
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2510
    
  10

anil katta wrote:yes I'm returning Huge resultset..
in this what i need to do could you please guide me...
Huge ResultSets usually don't take lots of memory, except if you define a large fetch size.

It is when you put each record of that huge ResultSet in a huge collection that it would result in Heap issues.

And yes - Huge ResultSets are typically useless in most applications. Refine your sql conditions, so that the filtering is done in the database.

OCUP UML fundamental and ITIL foundation
youtube channel
sentu trivedi
Greenhorn

Joined: Jun 22, 2009
Posts: 1
hey guys i needed you arer help i want create a combobox in that item will fatch from database table then
when i was select any item and click on button that time that item related data disply me in Table
 
wood burning stoves
 
subject: Java Memory Heap Exception