System.Data.SQLite

Check-in [33eaa98450]
Login

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

Overview
Comment:Correct vtable related maximum memory allocation calculation. Also, always use a lock statement for better portability to the .NET Compact Framework.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | virtualTables
Files: files | file ages | folders
SHA1: 33eaa984509b50c579f1fc45978e7735fb6f3d35
User & Date: mistachkin 2013-06-21 18:13:50.149
Context
2013-06-21
21:01
Fix vtshim error message handling. Adjust the data-1.28 test to account for the new SQLite3 constructor parameters. Fix delegate declaration for the xFilter method. check-in: ee4c57e435 user: mistachkin tags: virtualTables
18:13
Correct vtable related maximum memory allocation calculation. Also, always use a lock statement for better portability to the .NET Compact Framework. check-in: 33eaa98450 user: mistachkin tags: virtualTables
07:23
Remove unused GetNativeModule method. check-in: e550e1282e user: mistachkin tags: virtualTables
Changes
Unified Diff Ignore Whitespace Patch
Changes to System.Data.SQLite/SQLiteModule.cs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/********************************************************
 * ADO.NET 2.0 Data Provider for SQLite Version 3.X
 * Written by Joe Mistachkin (joe@mistachkin.com)
 *
 * Released to the public domain, use at your own risk!
 ********************************************************/

using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;

#if TRACK_MEMORY_BYTES
using System.Threading;
#endif

namespace System.Data.SQLite
{
    #region SQLiteContext Helper Class
    public sealed class SQLiteContext
    {
        #region Private Data
        private IntPtr pContext;












<
<
<
<







1
2
3
4
5
6
7
8
9
10
11
12




13
14
15
16
17
18
19
/********************************************************
 * ADO.NET 2.0 Data Provider for SQLite Version 3.X
 * Written by Joe Mistachkin (joe@mistachkin.com)
 *
 * Released to the public domain, use at your own risk!
 ********************************************************/

using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;





namespace System.Data.SQLite
{
    #region SQLiteContext Helper Class
    public sealed class SQLiteContext
    {
        #region Private Data
        private IntPtr pContext;
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
    ///////////////////////////////////////////////////////////////////////////

    #region SQLiteMemory Static Class
    internal static class SQLiteMemory
    {
        #region Private Data
#if TRACK_MEMORY_BYTES
#if PLATFORM_COMPACTFRAMEWORK
        private static object syncRoot = new object();
#endif

        ///////////////////////////////////////////////////////////////////////

        private static int bytesAllocated;
        private static int maximumBytesAllocated;
#endif
        #endregion







<

<







1340
1341
1342
1343
1344
1345
1346

1347

1348
1349
1350
1351
1352
1353
1354
    ///////////////////////////////////////////////////////////////////////////

    #region SQLiteMemory Static Class
    internal static class SQLiteMemory
    {
        #region Private Data
#if TRACK_MEMORY_BYTES

        private static object syncRoot = new object();


        ///////////////////////////////////////////////////////////////////////

        private static int bytesAllocated;
        private static int maximumBytesAllocated;
#endif
        #endregion
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382


1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
#if TRACK_MEMORY_BYTES
            if (pMemory != IntPtr.Zero)
            {
                int blockSize = Size(pMemory);

                if (blockSize > 0)
                {
#if !PLATFORM_COMPACTFRAMEWORK
                    Interlocked.Add(ref bytesAllocated, blockSize);
                    Interlocked.Add(ref maximumBytesAllocated, blockSize);
#else
                    lock (syncRoot)
                    {
                        bytesAllocated += blockSize;


                        maximumBytesAllocated += blockSize;
                    }
#endif
                }
            }
#endif

            return pMemory;
        }








<
<
<
<



>
>
|

<







1363
1364
1365
1366
1367
1368
1369




1370
1371
1372
1373
1374
1375
1376

1377
1378
1379
1380
1381
1382
1383
#if TRACK_MEMORY_BYTES
            if (pMemory != IntPtr.Zero)
            {
                int blockSize = Size(pMemory);

                if (blockSize > 0)
                {




                    lock (syncRoot)
                    {
                        bytesAllocated += blockSize;

                        if (bytesAllocated > maximumBytesAllocated)
                            maximumBytesAllocated = bytesAllocated;
                    }

                }
            }
#endif

            return pMemory;
        }

1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
#if TRACK_MEMORY_BYTES
            if (pMemory != IntPtr.Zero)
            {
                int blockSize = Size(pMemory);

                if (blockSize > 0)
                {
#if !PLATFORM_COMPACTFRAMEWORK
                    Interlocked.Add(ref bytesAllocated, -blockSize);
#else
                    lock (syncRoot)
                    {
                        bytesAllocated -= blockSize;
                    }
#endif
                }
            }
#endif

            UnsafeNativeMethods.sqlite3_free(pMemory);
        }
        #endregion







<
<
<




<







1399
1400
1401
1402
1403
1404
1405



1406
1407
1408
1409

1410
1411
1412
1413
1414
1415
1416
#if TRACK_MEMORY_BYTES
            if (pMemory != IntPtr.Zero)
            {
                int blockSize = Size(pMemory);

                if (blockSize > 0)
                {



                    lock (syncRoot)
                    {
                        bytesAllocated -= blockSize;
                    }

                }
            }
#endif

            UnsafeNativeMethods.sqlite3_free(pMemory);
        }
        #endregion