diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 210345431..477739919 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -137,13 +137,13 @@ public final class DatabasePool: DatabaseWriter { // Be a nice iOS citizen, and don't consume too much memory // See https://github.com/groue/GRDB.swift/#memory-management - #if canImport(UIKit) - setupMemoryManagement() + #if os(iOS) + setupAutomaticMemoryManagement() #endif } deinit { - // Undo job done in setupMemoryManagement() + // Undo job done in setupAutomaticMemoryManagement() // // https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error // Explicit unregistration is required before iOS 9 and OS X 10.11. @@ -196,8 +196,6 @@ extension DatabasePool { /// /// This method blocks the current thread until all database accesses /// are completed. - /// - /// See also setupMemoryManagement(application:) public func releaseMemory() { // Release writer memory writer.sync { $0.releaseMemory() } @@ -208,7 +206,12 @@ extension DatabasePool { } - #if canImport(UIKit) + #if os(iOS) + @available(*, deprecated, message: "Memory management is now enabled by default. This deprecated method does nothing.") + public func setupMemoryManagement(in application: UIApplication) { + // No op. + } + /// Listens to UIApplicationDidEnterBackgroundNotification and /// UIApplicationDidReceiveMemoryWarningNotification in order to release /// as much memory as possible. @@ -216,7 +219,7 @@ extension DatabasePool { /// - param application: The UIApplication that will start a background /// task to let the database pool release its memory when the application /// enters background. - private func setupMemoryManagement() { + private func setupAutomaticMemoryManagement() { let center = NotificationCenter.default center.addObserver( self, diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 446c3785d..77af619e7 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -43,8 +43,8 @@ public final class DatabaseQueue: DatabaseWriter { // Be a nice iOS citizen, and don't consume too much memory // See https://github.com/groue/GRDB.swift/#memory-management - #if canImport(UIKit) - setupMemoryManagement() + #if os(iOS) + setupAutomaticMemoryManagement() #endif } @@ -65,7 +65,7 @@ public final class DatabaseQueue: DatabaseWriter { } deinit { - // Undo job done in setupMemoryManagement() + // Undo job done in setupAutomaticMemoryManagement() // // https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error // Explicit unregistration is required before iOS 9 and OS X 10.11. @@ -80,13 +80,16 @@ extension DatabaseQueue { /// Free as much memory as possible. /// /// This method blocks the current thread until all database accesses are completed. - /// - /// See also setupMemoryManagement(application:) public func releaseMemory() { writer.sync { $0.releaseMemory() } } - #if canImport(UIKit) + #if os(iOS) + @available(*, deprecated, message: "Memory management is now enabled by default. This deprecated method does nothing.") + public func setupMemoryManagement(in application: UIApplication) { + // No op. + } + /// Listens to UIApplicationDidEnterBackgroundNotification and /// UIApplicationDidReceiveMemoryWarningNotification in order to release /// as much memory as possible. @@ -94,7 +97,7 @@ extension DatabaseQueue { /// - param application: The UIApplication that will start a background /// task to let the database queue release its memory when the application /// enters background. - private func setupMemoryManagement() { + private func setupAutomaticMemoryManagement() { let center = NotificationCenter.default center.addObserver( self,