You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7718,12 +7718,36 @@ dbPool.releaseMemory()
7718
7718
7719
7719
This method blocks the current thread until all current database accesses are completed, and the memory collected.
7720
7720
7721
+
> :warning: **Warning**: If `DatabasePool.releaseMemory()` is called while a long read is performed concurrently, then no other read access will be possible until this long read has completed, and the memory has been released. If this does not suit your application needs, look for the asynchronous options below:
7722
+
7723
+
You can release memory in an asynchronous way as well:
7724
+
7725
+
```swift
7726
+
// On a DatabaseQueue
7727
+
dbQueue.asyncWriteWithoutTransaction { db in
7728
+
db.releaseMemory()
7729
+
}
7730
+
7731
+
// On a DatabasePool
7732
+
dbPool.releaseMemoryEventually()
7733
+
```
7734
+
7735
+
`DatabasePool.releaseMemoryEventually()` does not block the current thread, and does not prevent concurrent database accesses. In exchange for this convenience, you don't know when memory has been freed.
7736
+
7721
7737
7722
7738
### Memory Management on iOS
7723
7739
7724
7740
**The iOS operating system likes applications that do not consume much memory.**
7725
7741
7726
-
[Database queues](#database-queues) and [pools](#database-pools) automatically call the `releaseMemory` method when the application receives a memory warning, and when the application enters background.
7742
+
[Database queues](#database-queues) and [pools](#database-pools) automatically free non-essential memory when the application receives a memory warning, and when the application enters background.
7743
+
7744
+
You can opt out of this automatic memory management:
7745
+
7746
+
```swift
7747
+
var config = Configuration()
7748
+
config.automaticMemoryManagement = false
7749
+
let dbQueue = try DatabaseQueue(path: dbPath, configuration: config) // or DatabasePool
0 commit comments