提交 52e5f10e authored 作者: Thomas Mueller's avatar Thomas Mueller

The reserve heap memory is no longer used.

上级 2609036a
......@@ -16,7 +16,6 @@ import org.h2.message.Message;
import org.h2.message.Trace;
import org.h2.message.TraceObject;
import org.h2.result.ResultInterface;
import org.h2.util.MemoryUtils;
import org.h2.util.ObjectArray;
/**
......@@ -186,7 +185,6 @@ public abstract class Command implements CommandInterface {
public int executeUpdate() throws SQLException {
long start = startTime = System.currentTimeMillis();
Database database = session.getDatabase();
MemoryUtils.allocateReserveMemory();
Object sync = database.isMultiThreaded() ? (Object) session : (Object) database;
session.waitIfExclusiveModeEnabled();
boolean callStop = true;
......
......@@ -60,7 +60,6 @@ import org.h2.util.BitField;
import org.h2.util.ByteUtils;
import org.h2.util.ClassUtils;
import org.h2.util.FileUtils;
import org.h2.util.MemoryUtils;
import org.h2.util.NetUtils;
import org.h2.util.New;
import org.h2.util.ObjectArray;
......@@ -224,7 +223,6 @@ public class Database implements DataHandler {
private void openDatabase(int traceLevelFile, int traceLevelSystemOut, boolean closeAtVmShutdown) throws SQLException {
try {
MemoryUtils.allocateReserveMemory();
open(traceLevelFile, traceLevelSystemOut);
if (closeAtVmShutdown) {
try {
......@@ -242,7 +240,6 @@ public class Database implements DataHandler {
}
} catch (Throwable e) {
if (e instanceof OutOfMemoryError) {
MemoryUtils.freeReserveMemory();
e.fillInStackTrace();
}
if (traceSystem != null) {
......
......@@ -16,7 +16,6 @@ import java.util.Properties;
import java.util.Map.Entry;
import org.h2.constant.ErrorCode;
import org.h2.jdbc.JdbcSQLException;
import org.h2.util.MemoryUtils;
import org.h2.util.Resources;
import org.h2.util.StringUtils;
......@@ -299,10 +298,7 @@ public class Message {
*/
public static SQLException convertThrowable(Throwable e) {
if (e instanceof OutOfMemoryError) {
if (MemoryUtils.freeReserveMemory()) {
return getSQLException(ErrorCode.OUT_OF_MEMORY, e);
}
throw (OutOfMemoryError) e;
return getSQLException(ErrorCode.OUT_OF_MEMORY, e);
} else if (e instanceof StackOverflowError || e instanceof LinkageError) {
return getSQLException(ErrorCode.GENERAL_ERROR_1, e, e.toString());
} else if (e instanceof Error) {
......
......@@ -6,7 +6,6 @@
*/
package org.h2.util;
import org.h2.constant.SysProperties;
/**
* This is a utility class with functions to measure the free and used memory.
......@@ -31,7 +30,6 @@ public class MemoryUtils {
private static long lastGC;
private static final int GC_DELAY = 50;
private static final int MAX_GC = 8;
private static volatile byte[] reserveMemory;
private MemoryUtils() {
// utility class
......@@ -78,29 +76,6 @@ public class MemoryUtils {
}
}
/**
* Allocate a little main memory that is freed up when if no memory is
* available, so that rolling back a large transaction is easier.
*/
public static void allocateReserveMemory() {
if (reserveMemory == null) {
reserveMemory = new byte[SysProperties.RESERVE_MEMORY];
}
}
/**
* Free up the reserve memory.
*
* @return if memory could be freed up.
*/
public static boolean freeReserveMemory() {
if (reserveMemory == null) {
return false;
}
reserveMemory = null;
return true;
}
/**
* Create an array of bytes with the given size. If this is not possible
* because not enough memory is available, an OutOfMemoryError with the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论