I
Istvan
Dear Group,
I have the following problem:
In a Java program I reuse the same connection (native driver) to
connect to a MySQL database. I have decided to test the program with
large inserts, that's when I encountered this problem: after a number
of - nonconsistent - number of inserts the program throws a null
pointer exception.
I pass instances of my classes to the database insert method, which
unpacks the attributes of the objects, inserts them into an sql string
and sends it off to the database. Immediately after it reads the new
identity, and uses it to read the attributes back into the passed
object and returns it.
In my test method I then use this object to do some operations and
then loop.
The database connection class is fairly large (perhaps bloated) and
each of these passed objects have approximately 10 associated objects.
Anyway, after approx. 550 inserts the returned object is null and when
I call the aforementioned operations, quite understandably, the test
method throws a NullPointerException.
As I use Eclipse, I have tried to run the code in debug mode, there I
got to over 1000 successful inserts (and then aborted, as it took a
long time). Also, if I insert loops (up to e.g. Integer.MAX_VALUE/10)
for say each 200th insert I can get a lot more inserts, still, it
still throws that NullPointerException at some insert.
I suspect that VM runs out of memory, in some curious way. I have also
tried to call finlize() and gc() for each 200th loop, with no success.
Any thoughts? Is my code crappy so that it keeps collecting objects
somewhere without dereferencing them, thus filling up memory? Is it
Java not doing the garbagecollection thing very well (as mentioned
earlier, it helps to put in long loops or running in debug mode which
is a lot slower than normal execution)? Is it something else?
Any help would be greatly appreciated. Just please don't tell me to
use smaller/fewer objects - it's not really an option.
Thanks in advance,
Istvan
I have the following problem:
In a Java program I reuse the same connection (native driver) to
connect to a MySQL database. I have decided to test the program with
large inserts, that's when I encountered this problem: after a number
of - nonconsistent - number of inserts the program throws a null
pointer exception.
I pass instances of my classes to the database insert method, which
unpacks the attributes of the objects, inserts them into an sql string
and sends it off to the database. Immediately after it reads the new
identity, and uses it to read the attributes back into the passed
object and returns it.
In my test method I then use this object to do some operations and
then loop.
The database connection class is fairly large (perhaps bloated) and
each of these passed objects have approximately 10 associated objects.
Anyway, after approx. 550 inserts the returned object is null and when
I call the aforementioned operations, quite understandably, the test
method throws a NullPointerException.
As I use Eclipse, I have tried to run the code in debug mode, there I
got to over 1000 successful inserts (and then aborted, as it took a
long time). Also, if I insert loops (up to e.g. Integer.MAX_VALUE/10)
for say each 200th insert I can get a lot more inserts, still, it
still throws that NullPointerException at some insert.
I suspect that VM runs out of memory, in some curious way. I have also
tried to call finlize() and gc() for each 200th loop, with no success.
Any thoughts? Is my code crappy so that it keeps collecting objects
somewhere without dereferencing them, thus filling up memory? Is it
Java not doing the garbagecollection thing very well (as mentioned
earlier, it helps to put in long loops or running in debug mode which
is a lot slower than normal execution)? Is it something else?
Any help would be greatly appreciated. Just please don't tell me to
use smaller/fewer objects - it's not really an option.
Thanks in advance,
Istvan