System.Data.SQLite
Check-in [6959d8f05a]
Not logged in

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

Overview
Comment:Add MemoryHighwater property to the SQLiteConnection class. Also, enhance unit test infrastructure to report it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6959d8f05a10d9672074323e846bbf6ca7d2d64f
User & Date: mistachkin 2011-11-13 21:47:27
Context
2011-11-13
22:03
More updates to docs for release 77. check-in: f0a39e8e34 user: mistachkin tags: trunk
21:47
Add MemoryHighwater property to the SQLiteConnection class. Also, enhance unit test infrastructure to report it. check-in: 6959d8f05a user: mistachkin tags: trunk
21:33
Remove unnecessary using statement from test case for ticket [7e3fa93744]. check-in: c86034a5fb user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

   119    119       internal override long MemoryUsed
   120    120       {
   121    121         get
   122    122         {
   123    123           return UnsafeNativeMethods.sqlite3_memory_used();
   124    124         }
   125    125       }
          126  +
          127  +    internal override long MemoryHighwater
          128  +    {
          129  +      get
          130  +      {
          131  +        return UnsafeNativeMethods.sqlite3_memory_highwater(0);
          132  +      }
          133  +    }
   126    134   
   127    135       /// <summary>
   128    136       /// Shutdown the SQLite engine so that it can be restarted with different config options.
   129    137       /// We depend on auto initialization to recover.
   130    138       /// </summary>
   131    139       /// <returns>Returns a result code</returns>
   132    140       internal override int Shutdown()

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

    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     35       /// <summary>
    36         -    /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
           36  +    /// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
    37     37       /// </summary>
    38     38       internal abstract long MemoryUsed { get; }
           39  +    /// <summary>
           40  +    /// Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
           41  +    /// </summary>
           42  +    internal abstract long MemoryHighwater { get; }
    39     43       /// <summary>
    40     44       /// Shutdown the SQLite engine so that it can be restarted with different config options.
    41     45       /// We depend on auto initialization to recover.
    42     46       /// </summary>
    43     47       internal abstract int Shutdown();
    44     48       /// <summary>
    45     49       /// Returns non-zero if a database connection is open.

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

  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   1040   
  1041   1041       /// <summary>
  1042         -    /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
         1042  +    /// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
  1043   1043       /// </summary>
  1044   1044   #if !PLATFORM_COMPACTFRAMEWORK
  1045   1045       [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1046   1046   #endif
  1047   1047       public long MemoryUsed
  1048   1048       {
  1049   1049         get
................................................................................
  1050   1050         {
  1051   1051           if (_sql == null)
  1052   1052             throw new InvalidOperationException("Database connection not valid for getting memory used.");
  1053   1053   
  1054   1054           return _sql.MemoryUsed;
  1055   1055         }
  1056   1056       }
         1057  +
         1058  +    /// <summary>
         1059  +    /// Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
         1060  +    /// </summary>
         1061  +#if !PLATFORM_COMPACTFRAMEWORK
         1062  +    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
         1063  +#endif
         1064  +    public long MemoryHighwater
         1065  +    {
         1066  +      get
         1067  +      {
         1068  +        if (_sql == null)
         1069  +          throw new InvalidOperationException("Database connection not valid for getting maximum memory used.");
         1070  +
         1071  +          return _sql.MemoryHighwater;
         1072  +      }
         1073  +    }
  1057   1074   
  1058   1075       /// <summary>
  1059   1076       /// Returns the version of the underlying SQLite database engine
  1060   1077       /// </summary>
  1061   1078       public static string SQLiteVersion
  1062   1079       {
  1063   1080         get { return SQLite3.SQLiteVersion; }

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

   375    375   #if !PLATFORM_COMPACTFRAMEWORK
   376    376       [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
   377    377   #else
   378    378       [DllImport(SQLITE_DLL)]
   379    379   #endif
   380    380       internal static extern long sqlite3_memory_used();
   381    381   
          382  +#if !PLATFORM_COMPACTFRAMEWORK
          383  +    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
          384  +#else
          385  +    [DllImport(SQLITE_DLL)]
          386  +#endif
          387  +    internal static extern long sqlite3_memory_highwater(int resetFlag);
          388  +
   382    389   #if !PLATFORM_COMPACTFRAMEWORK
   383    390       [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
   384    391   #else
   385    392       [DllImport(SQLITE_DLL)]
   386    393   #endif
   387    394       internal static extern int sqlite3_shutdown();
   388    395   

Changes to Tests/common.eagle.

   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    481   
   482    482       proc reportSQLiteResources { channel } {
   483         -      tputs $channel "---- memory now in use by SQLite... "
          483  +      tputs $channel "---- current memory in use by SQLite... "
          484  +
          485  +      if {[catch {object invoke -flags +NonPublic \
          486  +              System.Data.SQLite.UnsafeNativeMethods \
          487  +              sqlite3_memory_used} 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  +
          496  +      tputs $channel "---- maximum memory in use by SQLite... "
   484    497   
   485    498         if {[catch {object invoke -flags +NonPublic \
   486         -              System.Data.SQLite.UnsafeNativeMethods sqlite3_memory_used} \
   487         -              memory] == 0} then {
          499  +              System.Data.SQLite.UnsafeNativeMethods \
          500  +              sqlite3_memory_highwater 0} memory] == 0} then {
   488    501           tputs $channel [appendArgs $memory " bytes\n"]
   489    502         } else {
   490    503           #
   491    504           # NOTE: Maybe the SQLite native library is unavailable?
   492    505           #
   493    506           tputs $channel unknown\n
   494    507         }