> The class that I use for execute a query on a mysql database is:
> <CODE>
[quoted text clipped - 22 lines]
> String param13;
> String param14;
I'd replace the above with
static final int MAXPARAMS = 14;
String[] param = new String[MAXPARAMS];
> ResultSet resultset;
>
> public ExecuteQueryDB (String sql, int nparam){
if (nparam > MAXPARAMS)
throw new IllegalArgumentException(
"Max " + NPARAMS + " params!");
> String DRIVER = "com.mysql.jdbc.Driver";
> String DB_URL = "jdbc:mysql://localhost:3306/db";
[quoted text clipped - 160 lines]
>
> }
I'd replace that 100+ line humungous switch statement with
// note: array indexed from 0, resultset from 1
for (int i = 0; i<nparam; i++) {
param[i] = resultset.getString(i+1)
}
> }
>
> }
> } catch (SQLException e) {
>
> e.toString() ;
e.toString() does nothing useful! Try removing it.
> System.out.println(e);
> } finally {
[quoted text clipped - 19 lines]
>
> The problem can be here?
I'd guess elsewhere. If you can trim it down to an SSCCE* that shows the
problem, I'm sure more people will make the effort to help you.
*SSCCE defintions:
http://homepage1.nifty.com/algafield/sscce.html
http://mindprod.com/jgloss/sscce.html
Sal - 16 Oct 2007 18:53 GMT
[..]
> I'd guess elsewhere. If you can trim it down to an SSCCE* that shows the
> problem, I'm sure more people will make the effort to help you.
Thanks Red,
for your time and your advices.
I've noted that i dont close the statement and the resultset in that
class.
useful page:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.
udb.doc/ad/cjvjdbas.htm
now i try to write a SSCCE but is a bit complicated because the
original structure is:
graphical interface - every 20 sec write and read from serial port-
than look in to a string and put some data in a DB
I could create a simulation of this process but i dont know if it is
useful for my memory problem.
Anyway i try to do it
thanks a lot
Sal
Andrew Thompson - 17 Oct 2007 02:45 GMT
...
> I could create a simulation of this process but i dont know if it is
> useful for my memory problem.
If you can create a short, self contained* simulation
and post it here, people can help you better.
If, OTOH, you can create a short example that does
*not* suffer the memory leak, the answer is 'simple'.
Just remove whatever it is in the live code that is
not in the short example, one line at a time, until the
problem is solved. The problem will be that last
line(s) removed.
* Obviously it cannot be entirely self contained
unless you have a DB available for free interrogation
from 'dudes off usenet' (which, no - don't do that),
but even short of the DB, the self contained,
failing code would be valuable.
> Anyway i try to do it
That's good strategy.
As an aside. The word 'I' should always be
Upper Case.
Andrew T.
Sal - 17 Oct 2007 08:49 GMT
I would like to use a memory profiler, do you have any suggestion?
I've found many program (also try and buy) but which is the best, less
complicated, useful, etc...
Thanks
Sal
Sal - 19 Oct 2007 18:13 GMT
Maybe i've founded the problem!
If I minimize the graphical interface and then i maximize the memory
go down from 120 Mb to 5Mb!
Can you help me?
Can i minimize and maximize the application every day?
thanks
Sal