mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Don't invoke sqlite3_db_release_memory on closed database connections
This commit is contained in:
1 parent
f4b4035704
commit
cdb181d9ca
3 files changed
+18
-1
No files matched your search
@@ -1575,7 +1575,9 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
||||
/// Frees as much memory as possible.
|
||||
public func releaseMemory() {
|
||||
SchedulingWatchdog.preconditionValidQueue(self)
|
||||
sqlite3_db_release_memory(sqliteConnection)
|
||||
if let sqliteConnection {
|
||||
sqlite3_db_release_memory(sqliteConnection)
|
||||
}
|
||||
schemaCache.clear()
|
||||
internalStatementCache.clear()
|
||||
publicStatementCache.clear()
|
||||
|
||||
@@ -439,4 +439,12 @@ class DatabasePoolTests: GRDBTestCase {
|
||||
// In the zombie state, closing is a noop
|
||||
try dbPool.close()
|
||||
}
|
||||
|
||||
// Regression test for <https://github.com/groue/GRDB.swift/issues/1612>
|
||||
func test_releaseMemory_after_close() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.read { _ in } // Create a reader
|
||||
try dbPool.close()
|
||||
dbPool.releaseMemory()
|
||||
}
|
||||
}
|
||||
@@ -467,4 +467,11 @@ class DatabaseQueueTests: GRDBTestCase {
|
||||
try db.execute(sql: "SELECT * FROM sqlite_master")
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test for <https://github.com/groue/GRDB.swift/issues/1612>
|
||||
func test_releaseMemory_after_close() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.close()
|
||||
dbQueue.releaseMemory()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user