The Artima Developer Community
Sponsored Link

Weblogs Forum
Is your Sybase Java application running out of memory?

3 replies on 1 page. Most recent reply: Feb 4, 2006 11:07 PM by ted lowe

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Is your Sybase Java application running out of memory? (View in Weblogs)
Posted: Jan 5, 2006 11:59 AM
Reply to this message Reply
Summary
Sybase's implementation of PreparedStatement does not use Statement.clearWarnings() automatically on repeated uses. This results in the accumulation of SybSQLWarning and SybSQLResultSet objects, one pair per call use.
Advertisement
I've been using the Your-Kit Java Profiler on one of my customer's systems to identify the source of an OutOfMemoryError and occasional SIGSEGV or SIGBUS termination that seemed to happen intermitently.

What I discovered was that there were a large number of SybSQLWarning and SybSQLResultSet objects hanging off of the cached PreparedStatement objects that my JDBC connection manager was using. I found that the SybSQLWarning objects were all chained together, one after another, and that each had a reference to the SybSQLResultSet that it came from.

After adding a call Statement.clearWarnings() in the leg of code that reuses PreparedStatements, the stray objects went away. Great I said!

Well, I didn't really think that I should need to call Statement.clearWarnings(), and so I did some more looking around on the internet and found the link:

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
which includes the following text:
SQL Warnings

An SQLWarning is a subclass of SQLException, but is not thrown like other exceptions. The programmer must specifically ask for warnings. Connections, Statements, and ResultSets all have a getWarnings() method that allows retrieval. There is also a clearWarnings() method to avoid duplicate retrievals. The SQLWarning class itself only adds the methods getNextWarning() and setNextWarning().

An SQLWarning is very similar to traditional compiler warnings: something not exactly right occurred, but its effect was not severe enough to end processing. Whether it is important enough to investigate depends on the operation and context. An example of an SQLWarning is mentioned in the Scrollable Result Sets section.

Statements clear warnings automatically on the next execution. ResultSets clear warnings every time a new row is accessed. The API documentation is silent regarding Connection; to be cautious, issue clearWarnings() after warnings are obtained.

This seems like an implementation shortcomming. Has anyone else been bit by this Sybase "feature"?


chris norris

Posts: 1
Nickname: thechris
Registered: Jan, 2006

Re: Is you Sybase Java application running out of memory? Posted: Jan 6, 2006 5:30 AM
Reply to this message Reply
> Is you Sybase Java application running out of memory?

Is you blog title grammatically correct?

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: Is you Sybase Java application running out of memory? Posted: Jan 6, 2006 6:08 AM
Reply to this message Reply
> > Is you Sybase Java application running out of memory?
>
> Is you blog title grammatically correct?


Ouch! Thanks for pointing this out!

ted lowe

Posts: 1
Nickname: trl
Registered: Feb, 2006

Re: Is your Sybase Java application running out of memory? Posted: Feb 4, 2006 11:07 PM
Reply to this message Reply
i completely agree. Nothing more to discuss. End of story.
trl was here. :-)

Flat View: This topic has 3 replies on 1 page
Topic: A-Posteriori Subtyping and Case Classes Previous Topic   Next Topic Topic: Feedback: Bliki Software

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use