Skip to content

Commit 0bfb4de

Browse files
committed
Enhance DatabaseQueue automatic memory management
We have async methods, now: no need to use a global dispatch queue.
1 parent d72b710 commit 0bfb4de

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

GRDB/Core/DatabaseQueue.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,21 @@ extension DatabaseQueue {
119119

120120
let task: UIBackgroundTaskIdentifier = application.beginBackgroundTask(expirationHandler: nil)
121121
if task == .invalid {
122-
// Perform releaseMemory() synchronously.
122+
// Release memory synchronously
123123
releaseMemory()
124124
} else {
125-
// Perform releaseMemory() asynchronously.
126-
DispatchQueue.global().async {
127-
self.releaseMemory()
125+
// Release memory asynchronously
126+
writer.async { db in
127+
db.releaseMemory()
128128
application.endBackgroundTask(task)
129129
}
130130
}
131131
}
132132

133133
@objc
134134
private func applicationDidReceiveMemoryWarning(_ notification: NSNotification) {
135-
DispatchQueue.global().async {
136-
self.releaseMemory()
135+
writer.async { db in
136+
db.releaseMemory()
137137
}
138138
}
139139
#endif

0 commit comments

Comments
 (0)