Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix incorrect memory allocation counts in the SQLiteSession class for SQLite memory obtained without using the SQLiteMemory class. Only debug builds with TRACK_MEMORY_BYTES defined were impacted. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
395909320d3e88d951f44dae514d1a59 |
User & Date: | mistachkin 2017-11-07 01:42:51.394 |
Context
2017-11-07
| ||
03:33 | Fix an incorrect memory allocation count in the SQLiteIndex class for SQLite memory freed without using the SQLiteMemory class. Only debug builds with TRACK_MEMORY_BYTES defined were impacted. check-in: 52d29df7aa user: mistachkin tags: trunk | |
01:42 | Fix incorrect memory allocation counts in the SQLiteSession class for SQLite memory obtained without using the SQLiteMemory class. Only debug builds with TRACK_MEMORY_BYTES defined were impacted. check-in: 395909320d user: mistachkin tags: trunk | |
01:00 | Avoid unnecessary lock contention and managed heap allocations in the data type mapping subsystem. check-in: ca18c8f4dd user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteModule.cs.
︙ | ︙ | |||
3284 3285 3286 3287 3288 3289 3290 | /////////////////////////////////////////////////////////////////////// #region Memory Allocation Helper Methods /// <summary> /// Allocates at least the specified number of bytes of native memory /// via the SQLite core library sqlite3_malloc() function and returns | | > > | 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 | /////////////////////////////////////////////////////////////////////// #region Memory Allocation Helper Methods /// <summary> /// Allocates at least the specified number of bytes of native memory /// via the SQLite core library sqlite3_malloc() function and returns /// the resulting native pointer. If the TRACK_MEMORY_BYTES option /// was enabled at compile-time, adjusts the number of bytes currently /// allocated by this class. /// </summary> /// <param name="size"> /// The number of bytes to allocate. /// </param> /// <returns> /// The native pointer that points to a block of memory of at least the /// specified size -OR- <see cref="IntPtr.Zero" /> if the memory could |
︙ | ︙ | |||
3323 3324 3325 3326 3327 3328 3329 | return pMemory; } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the actual size of the specified memory block that | | > | | 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 | return pMemory; } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the actual size of the specified memory block that /// was previously obtained from the <see cref="Allocate" /> method or /// the SQLite core library. /// </summary> /// <param name="pMemory"> /// The native pointer to the memory block previously obtained from the /// <see cref="Allocate" /> method or the SQLite core library. /// </param> /// <returns> /// The actual size, in bytes, of the memory block specified via the /// native pointer. /// </returns> public static int Size(IntPtr pMemory) { |
︙ | ︙ | |||
3352 3353 3354 3355 3356 3357 3358 | #endif } /////////////////////////////////////////////////////////////////////// /// <summary> /// Frees a memory block previously obtained from the | | > > | 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 | #endif } /////////////////////////////////////////////////////////////////////// /// <summary> /// Frees a memory block previously obtained from the /// <see cref="Allocate" /> method. If the TRACK_MEMORY_BYTES option /// was enabled at compile-time, adjusts the number of bytes currently /// allocated by this class. /// </summary> /// <param name="pMemory"> /// The native pointer to the memory block previously obtained from the /// <see cref="Allocate" /> method. /// </param> public static void Free(IntPtr pMemory) { |
︙ | ︙ | |||
3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 | { bytesAllocated -= blockSize; } } } #endif UnsafeNativeMethods.sqlite3_free(pMemory); } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// | > > > > > > > > > > > > > > > > > | 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 | { bytesAllocated -= blockSize; } } } #endif UnsafeNativeMethods.sqlite3_free(pMemory); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Frees a memory block previously obtained from the SQLite core /// library without adjusting the number of bytes currently allocated /// by this class. This is useful when dealing with blocks of memory /// that were not allocated using this class. /// </summary> /// <param name="pMemory"> /// The native pointer to the memory block previously obtained from the /// SQLite core library. /// </param> public static void FreeUntracked(IntPtr pMemory) { UnsafeNativeMethods.sqlite3_free(pMemory); } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteSession.cs.
︙ | ︙ | |||
2372 2373 2374 2375 2376 2377 2378 | rawData = SQLiteBytes.FromIntPtr(pData, nData); } finally { if (pData != IntPtr.Zero) { | | | 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 | rawData = SQLiteBytes.FromIntPtr(pData, nData); } finally { if (pData != IntPtr.Zero) { SQLiteMemory.FreeUntracked(pData); pData = IntPtr.Zero; } } } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
2954 2955 2956 2957 2958 2959 2960 | rawData = SQLiteBytes.FromIntPtr(pData, nData); } finally { if (pData != IntPtr.Zero) { | | | 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 | rawData = SQLiteBytes.FromIntPtr(pData, nData); } finally { if (pData != IntPtr.Zero) { SQLiteMemory.FreeUntracked(pData); pData = IntPtr.Zero; } } } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
3030 3031 3032 3033 3034 3035 3036 | rawData = SQLiteBytes.FromIntPtr(pData, nData); } finally { if (pData != IntPtr.Zero) { | | | 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 | rawData = SQLiteBytes.FromIntPtr(pData, nData); } finally { if (pData != IntPtr.Zero) { SQLiteMemory.FreeUntracked(pData); pData = IntPtr.Zero; } } } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
3132 3133 3134 3135 3136 3137 3138 | "sqlite3session_diff", error)); } } finally { if (pError != IntPtr.Zero) { | | | 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 | "sqlite3session_diff", error)); } } finally { if (pError != IntPtr.Zero) { SQLiteMemory.FreeUntracked(pError); pError = IntPtr.Zero; } } } #endregion /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
3590 3591 3592 3593 3594 3595 3596 | return new SQLiteMemoryChangeSet( newData, GetHandle(), GetFlags()); } finally { if (pOutData != IntPtr.Zero) { | | | 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 | return new SQLiteMemoryChangeSet( newData, GetHandle(), GetFlags()); } finally { if (pOutData != IntPtr.Zero) { SQLiteMemory.FreeUntracked(pOutData); pOutData = IntPtr.Zero; } if (pInData != IntPtr.Zero) { SQLiteMemory.Free(pInData); pInData = IntPtr.Zero; |
︙ | ︙ | |||
3667 3668 3669 3670 3671 3672 3673 | return new SQLiteMemoryChangeSet( newData, GetHandle(), GetFlags()); } finally { if (pOutData != IntPtr.Zero) { | | | 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 | return new SQLiteMemoryChangeSet( newData, GetHandle(), GetFlags()); } finally { if (pOutData != IntPtr.Zero) { SQLiteMemory.FreeUntracked(pOutData); pOutData = IntPtr.Zero; } if (pInData2 != IntPtr.Zero) { SQLiteMemory.Free(pInData2); pInData2 = IntPtr.Zero; |
︙ | ︙ |