Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -113,10 +113,18 @@
get
{
return UnsafeNativeMethods.sqlite3_changes(_sql);
}
}
+
+ internal override long MemoryUsed
+ {
+ get
+ {
+ return UnsafeNativeMethods.sqlite3_memory_used();
+ }
+ }
///
/// 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
@@ -30,10 +30,14 @@
internal abstract long LastInsertRowId { get; }
///
/// 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.
+ ///
+ internal abstract long MemoryUsed { 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
@@ -1035,10 +1035,27 @@
throw new InvalidOperationException("Database connection not valid for getting number of changes.");
return _sql.Changes;
}
}
+
+ ///
+ /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
+ ///
+#if !PLATFORM_COMPACTFRAMEWORK
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+ public long MemoryUsed
+ {
+ get
+ {
+ if (_sql == null)
+ throw new InvalidOperationException("Database connection not valid for getting memory used.");
+
+ return _sql.MemoryUsed;
+ }
+ }
///
/// 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
@@ -370,10 +370,17 @@
#else
[DllImport(SQLITE_DLL)]
#endif
internal static extern int sqlite3_changes(IntPtr db);
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+#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
Index: Tests/common.eagle
==================================================================
--- Tests/common.eagle
+++ Tests/common.eagle
@@ -476,10 +476,25 @@
# NOTE: Delete the test database file now. For now, all test database
# files are stored in the temporary directory.
#
catch {file delete [file join [getTemporaryPath] [file tail $fileName]]}
}
+
+ proc reportSQLiteResources { channel } {
+ tputs $channel "---- memory now 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
+ }
+ }
proc runSQLiteTestPrologue {} {
#
# NOTE: Skip running our custom prologue if the main one has been skipped.
#
@@ -549,21 +564,27 @@
# load without it; however, it cannot do anything useful without
# it). If we are using the mixed-mode assembly and we already
# found it (above), this should always succeed.
#
checkForSQLite $::test_channel
+
+ #
+ # NOTE: Report the resource usage prior to running any tests.
+ #
+ reportSQLiteResources $::test_channel
}
}
proc runSQLiteTestEpilogue {} {
#
# NOTE: Skip running our custom epilogue if the main one has been skipped.
#
if {![info exists ::no(epilogue.eagle)]} then {
#
- # NOTE: For now, nothing is done here.
+ # NOTE: Also report the resource usage after running the tests.
#
+ reportSQLiteResources $::test_channel
}
}
###########################################################################
############################# END Eagle ONLY ##############################