Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-04-11 06:28:50 +0000
committerEike Stepper2013-04-11 06:28:50 +0000
commit4280908ac24814f10686075c911e0612b4e72e7b (patch)
tree177cc838a9cb88388bad51a3b26029930e49e6cb
parent7d07ea3ab9a7b9c83535783a1785db6ec6a1dea0 (diff)
downloadcdo-4280908ac24814f10686075c911e0612b4e72e7b.tar.gz
cdo-4280908ac24814f10686075c911e0612b4e72e7b.tar.xz
cdo-4280908ac24814f10686075c911e0612b4e72e7b.zip
[405345] [DB] DBUtil.deserializeTable - Out of Memory
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405345
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java38
1 files changed, 30 insertions, 8 deletions
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index 2678d75db8..d59246329a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -24,6 +24,7 @@ import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -54,6 +55,12 @@ import java.util.Set;
*/
public final class DBUtil
{
+ /**
+ * @since 4.2
+ */
+ public static final int MAX_BATCH_SIZE = Integer.parseInt(OMPlatform.INSTANCE.getProperty(
+ "org.eclipse.net4j.db.MAX_BATCH_SIZE", "2000"));
+
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SQL, DBUtil.class);
private DBUtil()
@@ -1263,6 +1270,7 @@ public final class DBUtil
Object[] values = handler != null ? new Object[fields.length] : null;
+ int batchSize = 0;
for (int row = 0; row < size; row++)
{
for (int i = 0; i < fields.length; i++)
@@ -1284,17 +1292,17 @@ public final class DBUtil
}
monitor.worked();
- }
-
- Async async = monitor.forkAsync(size);
- try
- {
- statement.executeBatch();
+ if (++batchSize == MAX_BATCH_SIZE)
+ {
+ executeBatch(statement, batchSize, monitor);
+ batchSize = 0;
+ }
}
- finally
+
+ if (batchSize != 0)
{
- async.stop();
+ executeBatch(statement, batchSize, monitor);
}
successful = true;
@@ -1324,6 +1332,20 @@ public final class DBUtil
}
}
+ private static void executeBatch(PreparedStatement statement, int batchSize, OMMonitor monitor) throws SQLException
+ {
+ Async async = monitor.forkAsync(batchSize);
+
+ try
+ {
+ statement.executeBatch();
+ }
+ finally
+ {
+ async.stop();
+ }
+ }
+
/**
* @since 3.0
*/

Back to the top