OutOfMemoryError при чтении одного столбца из PostgreSQL

Я пытаюсь прочитать один из столбцов из одной таблицы из моего локально установленного PostgreSQL 10.3

Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/vk", "postgres", "qwerty");
Statement statement = conn.createStatement();
statement.setFetchSize(10);
ResultSet rs = statement.executeQuery("select POST_CONTENT from VK_GROUP_POST");
System.out.println("rs is ready " + rs);

Я запускаю программу с -verbose:gc -Xmx512M Варианты ВМ. Проект имеет только зависимость: org.postgresql:postgresql:42.2.1

И я всегда получаю ошибку OOM:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
...
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2134)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:224)
at my.SaveRepostedToFile.main(SaveRepostedToFile.java:10)

Есть ли способ избежать ООМ?

0 ответов

Другие вопросы по тегам