OutOfMemoryError - bug or human error?
От | Fischer Krisztián |
---|---|
Тема | OutOfMemoryError - bug or human error? |
Дата | |
Msg-id | 4014FE48.9000807@borganization.com обсуждение исходный текст |
Ответы |
Re: OutOfMemoryError - bug or human error?
|
Список | pgsql-jdbc |
Hi all! I execute a select on a table which contains large rows. None the less i use the setFetchSize() method i get an OutOfMemeoryError. In my test I craeted a table with an 'int' and a 'text' column. The text column - in each row - is filled with a string constructed of 65536 characters. The problem is there even if I use a fetch size of 2 rows! In a real scenario, i never use such a big text field, but this test shows, that the memory usage of the jdbc driver depends on the number of rows in the (full) result even if I use a very small fetch size. Maybe i overlook something? Previously i made the same tests with over 2 million rows - with significantly less text data - and everything worked fine. I'm afraid, if i get starting to store lot's of 'large objects' the same problem could appear. Could somebody explain how could i avoid this problem? The problem is reproducible with the following code: conn = DriverManager.getConnection("jdbc:postgresql://localhost/test", props); conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); conn.setAutoCommit(false); st = conn.createStatement(); st.executeUpdate("CREATE TABLE foo ( x int, t text )"); st.close(); PreparedStatement st2 = conn.prepareStatement("INSERT INTO foo (x,t) VALUES (?,?)"); String longString = _a string with 65 Kbyte characters_ for (int i = 0; i < 1500; i++) { st2.setInt(1,i); st2.setString(2,longString); st2.executeUpdate(); } st2.close(); st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); st1.setFetchSize(2); ResultSet rs = st1.executeQuery("select * from foo"); while (rs.next()) { //... } rs.close(); st.executeUpdate("DROP TABLE foo"); st.close(); // conn.commit(); conn.close(); Thanks! Chris -- Fischer Krisztián <fischer@borganization.com> Tel: (+36)70/3843835, (+36)1/3360547 Borganization Kft.
В списке pgsql-jdbc по дате отправления: