Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -121,10 +121,18 @@
get
{
return UnsafeNativeMethods.sqlite3_memory_used();
}
}
+
+ internal override long MemoryHighwater
+ {
+ get
+ {
+ return UnsafeNativeMethods.sqlite3_memory_highwater(0);
+ }
+ }
///
/// Shutdown the SQLite engine so that it can be restarted with different config options.
/// We depend on auto initialization to recover.
///
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -31,13 +31,17 @@
///
/// Returns the number of changes the last executing insert/update caused.
///
internal abstract int Changes { get; }
///
- /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
+ /// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
///
internal abstract long MemoryUsed { get; }
+ ///
+ /// Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
+ ///
+ internal abstract long MemoryHighwater { get; }
///
/// Shutdown the SQLite engine so that it can be restarted with different config options.
/// We depend on auto initialization to recover.
///
internal abstract int Shutdown();
Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -1037,11 +1037,11 @@
return _sql.Changes;
}
}
///
- /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
+ /// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
///
#if !PLATFORM_COMPACTFRAMEWORK
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
#endif
public long MemoryUsed
@@ -1052,10 +1052,27 @@
throw new InvalidOperationException("Database connection not valid for getting memory used.");
return _sql.MemoryUsed;
}
}
+
+ ///
+ /// Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
+ ///
+#if !PLATFORM_COMPACTFRAMEWORK
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+ public long MemoryHighwater
+ {
+ get
+ {
+ if (_sql == null)
+ throw new InvalidOperationException("Database connection not valid for getting maximum memory used.");
+
+ return _sql.MemoryHighwater;
+ }
+ }
///
/// Returns the version of the underlying SQLite database engine
///
public static string SQLiteVersion
Index: System.Data.SQLite/UnsafeNativeMethods.cs
==================================================================
--- System.Data.SQLite/UnsafeNativeMethods.cs
+++ System.Data.SQLite/UnsafeNativeMethods.cs
@@ -377,10 +377,17 @@
#else
[DllImport(SQLITE_DLL)]
#endif
internal static extern long sqlite3_memory_used();
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+#else
+ [DllImport(SQLITE_DLL)]
+#endif
+ internal static extern long sqlite3_memory_highwater(int resetFlag);
+
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
Index: Tests/common.eagle
==================================================================
--- Tests/common.eagle
+++ Tests/common.eagle
@@ -478,15 +478,28 @@
#
catch {file delete [file join [getTemporaryPath] [file tail $fileName]]}
}
proc reportSQLiteResources { channel } {
- tputs $channel "---- memory now in use by SQLite... "
+ tputs $channel "---- current memory in use by SQLite... "
+
+ if {[catch {object invoke -flags +NonPublic \
+ System.Data.SQLite.UnsafeNativeMethods \
+ sqlite3_memory_used} memory] == 0} then {
+ tputs $channel [appendArgs $memory " bytes\n"]
+ } else {
+ #
+ # NOTE: Maybe the SQLite native library is unavailable?
+ #
+ tputs $channel unknown\n
+ }
+
+ tputs $channel "---- maximum memory in use by SQLite... "
if {[catch {object invoke -flags +NonPublic \
- System.Data.SQLite.UnsafeNativeMethods sqlite3_memory_used} \
- memory] == 0} then {
+ System.Data.SQLite.UnsafeNativeMethods \
+ sqlite3_memory_highwater 0} memory] == 0} then {
tputs $channel [appendArgs $memory " bytes\n"]
} else {
#
# NOTE: Maybe the SQLite native library is unavailable?
#