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.
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.
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.
author & internet detective