13 messages in com.mysql.lists.javaRe: Fwd: java.lang.OutOfMemoryError o...| From | Sent On | Attachments |
|---|---|---|
| Sean Erickson | 21 Nov 2003 06:48 | |
| Christian Mack | 21 Nov 2003 11:42 | |
| Morten Norby Larsen | 21 Nov 2003 12:06 | |
| Kip Krueger | 21 Nov 2003 12:17 | |
| Kip Krueger | 21 Nov 2003 12:25 | |
| Jeff Mathis | 21 Nov 2003 12:39 | |
| Sean Erickson | 21 Nov 2003 13:46 | |
| Sean Erickson | 21 Nov 2003 13:59 | |
| Jeff Mathis | 21 Nov 2003 13:59 | |
| Mark Matthews | 21 Nov 2003 14:12 | |
| Jeff Mathis | 21 Nov 2003 14:37 | |
| Sean Erickson | 21 Nov 2003 15:58 | |
| Mark Matthews | 21 Nov 2003 17:34 |
| Subject: | Re: Fwd: java.lang.OutOfMemoryError on closing resultset![]() |
|---|---|
| From: | Sean Erickson (sean...@ia-inc.com) |
| Date: | 11/21/2003 01:59:34 PM |
| List: | com.mysql.lists.java |
Hmm, well, when I put a "stmt.close()" inside the loop, I get an OutOfMemory error there also.
I occurs to me that I must be doing something very wrong, although I cannot guess what it would be. The error is more so related to the size of the table that I am accessing than to the contrived example - as it happens even for the first time through the loop; in other words, the error occurs, IFF the table size > approx. 40-50 Megs.
thanks again for the responses,
-Sean
Jeff Mathis wrote:
java does automatic garbage collection. its one of the huge benefits -- you do not need to concern yourself with memory management. creating a new object in a loop more than likely is not the cause of the error. making sure to close the statement would be a better avenue to pursue.
jeff
Kip Krueger wrote:
Or can someone set me straight regarding "disposal of instantiated objects" - is that something that you even need to do in Java?
Begin forwarded message:
From: Kip Krueger <ki...@bigpikture.com>
Date: November 21, 2003 12:18:20 PM PST To: Christian Mack <mack...@gmx.de> Cc: Sean Erickson <sean...@ia-inc.com>, ja...@lists.mysql.com Subject: Re: java.lang.OutOfMemoryError on closing resultset
I'm no expert java programmer, but my C++ and Objective C experiences make me strongly agree with Christian on this one. Inside a loop instantiating a new object every iteration with no disposal? Seems a likely candidate for memory leakage. Try disposing of the "object" at the end of the loop each time and I bet the error goes away.
K
On Nov 21, 2003, at 11:42 AM, Christian Mack wrote:
Hi Sean
Why are you creating this DataObject in the while() loop?
object = new DataObject();
It will create a lot of objects never used.
Bye Christian
Sean Erickson wrote:
Hi all, ... # I then fill this table with 50,000 records # upon retrieving it, I get repeated "java.lang.OutOfMemory" errors at the position indicated below int setSize = 50000; int incSize = 10000; int position = 0; int rsSize = 100; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setMaxRows(rsSize); stmt.setFetchSize(Integer.MIN_VALUE); query = "SELECT ID, SUMMARY, PRIORITY, DESCRIPTION FROM " + table + " LIMIT " + position + "," + rsSize; rs = stmt.executeQuery( query); int count =1; while( rs.next() ) { object = new DataObject(); alert.id = rs.getLong(1); alert.summary = rs.getString(2); alert.priority = rs.getInt(3); description = rs.getString(4); count++; if(count == rsSize ) { System.out.println("id: " + alert.id); position += count; rs.close(); rs = null;
stmt.close(); // <--------- "OutOfMemory error"....
query = "SELECT ID, SUMMARY, PRIORITY, DESCRIPTION FROM " + table + " LIMIT " + position + "," + rsSize; System.out.println("query: " + query); try{ rs = stmt.executeQuery(query); // <------------ "OutOfMemory" Errors are thrown here } catch(java.lang.OutOfMemoryError t ) { System.out.println("OutOfMemoryError: " + t ); System.out.println("freeMemory: " + runtime.freeMemory() ); rs = stmt.executeQuery(query); // <------------ this call works } System.out.println("id: " + alert.id); System.gc() ; count =1; } } - some system specs: # java -version java version "1.4.1" Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.4.1-beta) Java HotSpot(TM) Client VM (build Blackdown-1.4.1-beta, mixed mode) # mysqladmin version mysqladmin Ver 8.23 Distrib 3.23.56, for redhat-linux-gnu on i386 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version 3.23.56-log Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 2 hours 29 min 0 sec Threads: 1 Questions: 795888 Slow queries: 5520 Opens: 132 Flush tables: 1 Open tables: 1 Queries per second avg: 89.026 erickson@gandalf:/home/mysql$ # uname -ar Linux gandalf 2.4.22-09032003a-smp #1 SMP Wed Sep 3 11:26:08 EDT 2003 i686 athlon i386 GNU/Linux #df -h /home/mysql Filesystem Size Used Avail Use% Mounted on /dev/hda5 28G 8.3G 19G 31% /home
-- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/java?unsub=kkru...@best.com




