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