System.Data.SQLite
Check-in [dd01ee7c55]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add MemoryUsed property to the SQLiteConnection class. Also, report memory in use by the core SQLite library when running the unit test suite.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dd01ee7c559ea1dd6fa8fd14209a82e77709f6f1
User & Date: mistachkin 2011-11-13 08:59:56
Context
2011-11-13
21:33
Remove unnecessary using statement from test case for ticket [7e3fa93744]. check-in: c86034a5fb user: mistachkin tags: trunk
21:27
Formal attempt to reproduce the issue in ticket [e30b820248]. check-in: 68d2140bad user: mistachkin tags: tkt-e30b820248
08:59
Add MemoryUsed property to the SQLiteConnection class. Also, report memory in use by the core SQLite library when running the unit test suite. check-in: dd01ee7c55 user: mistachkin tags: trunk
06:24
Merge fix for ticket [7e3fa93744] and several unit test infrastructure enhancements to trunk. check-in: 8fe2a401d6 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLite3.cs.

   111    111       internal override int Changes
   112    112       {
   113    113         get
   114    114         {
   115    115           return UnsafeNativeMethods.sqlite3_changes(_sql);
   116    116         }
   117    117       }
          118  +
          119  +    internal override long MemoryUsed
          120  +    {
          121  +      get
          122  +      {
          123  +        return UnsafeNativeMethods.sqlite3_memory_used();
          124  +      }
          125  +    }
   118    126   
   119    127       /// <summary>
   120    128       /// Shutdown the SQLite engine so that it can be restarted with different config options.
   121    129       /// We depend on auto initialization to recover.
   122    130       /// </summary>
   123    131       /// <returns>Returns a result code</returns>
   124    132       internal override int Shutdown()

Changes to System.Data.SQLite/SQLiteBase.cs.

    28     28       /// Returns the rowid of the most recent successful INSERT into the database from this connection.
    29     29       /// </summary>
    30     30       internal abstract long LastInsertRowId { get; }
    31     31       /// <summary>
    32     32       /// Returns the number of changes the last executing insert/update caused.
    33     33       /// </summary>
    34     34       internal abstract int Changes { get; }
           35  +    /// <summary>
           36  +    /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
           37  +    /// </summary>
           38  +    internal abstract long MemoryUsed { get; }
    35     39       /// <summary>
    36     40       /// Shutdown the SQLite engine so that it can be restarted with different config options.
    37     41       /// We depend on auto initialization to recover.
    38     42       /// </summary>
    39     43       internal abstract int Shutdown();
    40     44       /// <summary>
    41     45       /// Returns non-zero if a database connection is open.

Changes to System.Data.SQLite/SQLiteConnection.cs.

  1033   1033         {
  1034   1034           if (_sql == null)
  1035   1035             throw new InvalidOperationException("Database connection not valid for getting number of changes.");
  1036   1036   
  1037   1037           return _sql.Changes;
  1038   1038         }
  1039   1039       }
         1040  +
         1041  +    /// <summary>
         1042  +    /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
         1043  +    /// </summary>
         1044  +#if !PLATFORM_COMPACTFRAMEWORK
         1045  +    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
         1046  +#endif
         1047  +    public long MemoryUsed
         1048  +    {
         1049  +      get
         1050  +      {
         1051  +        if (_sql == null)
         1052  +          throw new InvalidOperationException("Database connection not valid for getting memory used.");
         1053  +
         1054  +        return _sql.MemoryUsed;
         1055  +      }
         1056  +    }
  1040   1057   
  1041   1058       /// <summary>
  1042   1059       /// Returns the version of the underlying SQLite database engine
  1043   1060       /// </summary>
  1044   1061       public static string SQLiteVersion
  1045   1062       {
  1046   1063         get { return SQLite3.SQLiteVersion; }

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

   368    368   #if !PLATFORM_COMPACTFRAMEWORK
   369    369       [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
   370    370   #else
   371    371       [DllImport(SQLITE_DLL)]
   372    372   #endif
   373    373       internal static extern int sqlite3_changes(IntPtr db);
   374    374   
          375  +#if !PLATFORM_COMPACTFRAMEWORK
          376  +    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
          377  +#else
          378  +    [DllImport(SQLITE_DLL)]
          379  +#endif
          380  +    internal static extern long sqlite3_memory_used();
          381  +
   375    382   #if !PLATFORM_COMPACTFRAMEWORK
   376    383       [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
   377    384   #else
   378    385       [DllImport(SQLITE_DLL)]
   379    386   #endif
   380    387       internal static extern int sqlite3_shutdown();
   381    388   

Changes to Tests/common.eagle.

   474    474   
   475    475         #
   476    476         # NOTE: Delete the test database file now.  For now, all test database
   477    477         #       files are stored in the temporary directory.
   478    478         #
   479    479         catch {file delete [file join [getTemporaryPath] [file tail $fileName]]}
   480    480       }
          481  +
          482  +    proc reportSQLiteResources { channel } {
          483  +      tputs $channel "---- memory now in use by SQLite... "
          484  +
          485  +      if {[catch {object invoke -flags +NonPublic \
          486  +              System.Data.SQLite.UnsafeNativeMethods sqlite3_memory_used} \
          487  +              memory] == 0} then {
          488  +        tputs $channel [appendArgs $memory " bytes\n"]
          489  +      } else {
          490  +        #
          491  +        # NOTE: Maybe the SQLite native library is unavailable?
          492  +        #
          493  +        tputs $channel unknown\n
          494  +      }
          495  +    }
   481    496   
   482    497       proc runSQLiteTestPrologue {} {
   483    498         #
   484    499         # NOTE: Skip running our custom prologue if the main one has been skipped.
   485    500         #
   486    501         if {![info exists ::no(prologue.eagle)]} then {
   487    502           #
................................................................................
   547    562           # NOTE: Now, we need to know if the SQLite core library is available
   548    563           #       (i.e. because the managed-only System.Data.SQLite assembly can
   549    564           #       load without it; however, it cannot do anything useful without
   550    565           #       it).  If we are using the mixed-mode assembly and we already
   551    566           #       found it (above), this should always succeed.
   552    567           #
   553    568           checkForSQLite $::test_channel
          569  +
          570  +        #
          571  +        # NOTE: Report the resource usage prior to running any tests.
          572  +        #
          573  +        reportSQLiteResources $::test_channel
   554    574         }
   555    575       }
   556    576   
   557    577       proc runSQLiteTestEpilogue {} {
   558    578         #
   559    579         # NOTE: Skip running our custom epilogue if the main one has been skipped.
   560    580         #
   561    581         if {![info exists ::no(epilogue.eagle)]} then {
   562    582           #
   563         -        # NOTE: For now, nothing is done here.
          583  +        # NOTE: Also report the resource usage after running the tests.
   564    584           #
          585  +        reportSQLiteResources $::test_channel
   565    586         }
   566    587       }
   567    588   
   568    589       ###########################################################################
   569    590       ############################# END Eagle ONLY ##############################
   570    591       ###########################################################################
   571    592     }