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 Unified Diffs Show Whitespace Changes Patch

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

119
120
121
122
123
124
125








126
127
128
129
130
131
132
    internal override long MemoryUsed
    {
      get
      {
        return UnsafeNativeMethods.sqlite3_memory_used();
      }
    }









    /// <summary>
    /// Shutdown the SQLite engine so that it can be restarted with different config options.
    /// We depend on auto initialization to recover.
    /// </summary>
    /// <returns>Returns a result code</returns>
    internal override int Shutdown()







>
>
>
>
>
>
>
>







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    internal override long MemoryUsed
    {
      get
      {
        return UnsafeNativeMethods.sqlite3_memory_used();
      }
    }

    internal override long MemoryHighwater
    {
      get
      {
        return UnsafeNativeMethods.sqlite3_memory_highwater(0);
      }
    }

    /// <summary>
    /// Shutdown the SQLite engine so that it can be restarted with different config options.
    /// We depend on auto initialization to recover.
    /// </summary>
    /// <returns>Returns a result code</returns>
    internal override int Shutdown()

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

29
30
31
32
33
34
35
36
37
38




39
40
41
42
43
44
45
    /// </summary>
    internal abstract long LastInsertRowId { get; }
    /// <summary>
    /// Returns the number of changes the last executing insert/update caused.
    /// </summary>
    internal abstract int Changes { get; }
    /// <summary>
    /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
    /// </summary>
    internal abstract long MemoryUsed { get; }




    /// <summary>
    /// Shutdown the SQLite engine so that it can be restarted with different config options.
    /// We depend on auto initialization to recover.
    /// </summary>
    internal abstract int Shutdown();
    /// <summary>
    /// Returns non-zero if a database connection is open.







|


>
>
>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    /// </summary>
    internal abstract long LastInsertRowId { get; }
    /// <summary>
    /// Returns the number of changes the last executing insert/update caused.
    /// </summary>
    internal abstract int Changes { get; }
    /// <summary>
    /// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
    /// </summary>
    internal abstract long MemoryUsed { get; }
    /// <summary>
    /// Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
    /// </summary>
    internal abstract long MemoryHighwater { get; }
    /// <summary>
    /// Shutdown the SQLite engine so that it can be restarted with different config options.
    /// We depend on auto initialization to recover.
    /// </summary>
    internal abstract int Shutdown();
    /// <summary>
    /// Returns non-zero if a database connection is open.

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

1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
....
1050
1051
1052
1053
1054
1055
1056

















1057
1058
1059
1060
1061
1062
1063
          throw new InvalidOperationException("Database connection not valid for getting number of changes.");

        return _sql.Changes;
      }
    }

    /// <summary>
    /// Returns the amount of memory, in bytes, currently in use by SQLite core library.
    /// </summary>
#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;
      }
    }


















    /// <summary>
    /// Returns the version of the underlying SQLite database engine
    /// </summary>
    public static string SQLiteVersion
    {
      get { return SQLite3.SQLiteVersion; }







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
....
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
          throw new InvalidOperationException("Database connection not valid for getting number of changes.");

        return _sql.Changes;
      }
    }

    /// <summary>
    /// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
    /// </summary>
#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;
      }
    }

    /// <summary>
    /// Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
    /// </summary>
#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;
      }
    }

    /// <summary>
    /// Returns the version of the underlying SQLite database engine
    /// </summary>
    public static string SQLiteVersion
    {
      get { return SQLite3.SQLiteVersion; }

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

375
376
377
378
379
380
381







382
383
384
385
386
387
388
#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
    internal static extern int sqlite3_shutdown();








>
>
>
>
>
>
>







375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#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
    internal static extern long sqlite3_memory_highwater(int resetFlag);

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern int sqlite3_shutdown();

Changes to Tests/common.eagle.

476
477
478
479
480
481
482
483
484
485
486
487













488
489
490
491
492
493
494
      # 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
      }







|


|
|
>
>
>
>
>
>
>
>
>
>
>
>
>







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
      # 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 "---- 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_highwater 0} memory] == 0} then {
        tputs $channel [appendArgs $memory " bytes\n"]
      } else {
        #
        # NOTE: Maybe the SQLite native library is unavailable?
        #
        tputs $channel unknown\n
      }