GeeCON Prague 2014*
The moose likes JDBC and the fly likes memory impact on statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "memory impact on statement" Watch "memory impact on statement" New topic
Author

memory impact on statement

bhagyaapatil apatil
Greenhorn

Joined: Aug 30, 2007
Posts: 6
Hi ,

I am getting outofmemory exception in a webpage.In the related java class i have used Statement to retrieve the data from DB (oracle).
does usage of prepared statement and statement makes any impact on
memory?
If i presume there is memory problem.
But this exceptions occurs only at particular page rest of the things are working fine.
and i have increased the jvm headp size by setting a catalina_opts environment var and in Catalina.bat also i have set this JAVA_OPTS .

Can any one help me to find out what could be the problem?
whether it is related to statment or preparedstatement or something else.
or any other suggestions for how we can debug for memory leak in java class.

thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

The first thing to do is use a memory profiler to see if you actually have a memory problem in this class.

Presuming you do, the problem is highly unlikely to be the choice of Statement vs PreparedStatement. I would check if you have any static variables (the only practical way to have a memory leak in Java) or if you are returning a tremendous amount of data from the query.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
bhagyaapatil apatil
Greenhorn

Joined: Aug 30, 2007
Posts: 6
Thanks for the reply.

May I know how memory profiler is used which you mentioned.
Do you mean logging the max memory, total memory and free memory?

I have done it. even though i have set max memory as 700MB its showing max memory very less.
As Max Memory 694MB
Total Memory 76MB
Free memory 3MB
I would like to know how we set jvm max memory size.
catalina.bat java_opts=-X..
or setting java_opts as environment


In my java class i am using Prepared statment in all methods.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

Originally posted by bhagyaapatil apatil:
May I know how memory profiler is used which you mentioned.

There are a number of different memory profiling tools. Here's a list of open source ones.


Originally posted by bhagyaapatil apatil:
Do you mean logging the max memory, total memory and free memory?

No. That just tells you that you are low on memory. A memory profiler will tell you which class it is.
bhagyaapatil apatil
Greenhorn

Joined: Aug 30, 2007
Posts: 6
Thank you.
 
GeeCON Prague 2014
 
subject: memory impact on statement