Skip to content

Commit 413a130

Browse files
authored
Expose methods to release memory (#56)
- Expose releaseMemory() and releaseMemoryEventually() - Update GRDB
1 parent 09d4b60 commit 413a130

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
),
2121
.package(
2222
url: "https://github.com/groue/GRDB.swift.git",
23-
from: "6.24.2"
23+
from: "6.29.3"
2424
),
2525
.package(
2626
url: "https://github.com/shareup/precise-iso-8601-date-formatter.git",

Sources/SQLite/SQLiteDatabase.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,28 @@ public final class SQLiteDatabase: DatabaseProtocol, @unchecked Sendable {
118118
)
119119
}
120120

121+
public func releaseMemory() {
122+
switch database {
123+
case let .pool(pool):
124+
pool.releaseMemory()
125+
126+
case let .queue(queue):
127+
queue.releaseMemory()
128+
}
129+
}
130+
131+
public func releaseMemoryEventually() {
132+
switch database {
133+
case let .pool(pool):
134+
pool.releaseMemoryEventually()
135+
136+
case let .queue(queue):
137+
queue.asyncWriteWithoutTransaction { db in
138+
db.releaseMemory()
139+
}
140+
}
141+
}
142+
121143
public func truncate() throws {
122144
let coordinator = NSFileCoordinator(filePresenter: nil)
123145
var coordinatorError: NSError?

0 commit comments

Comments
 (0)