From 4d60f01f7dbed71c7c354455631c4714ae8afac5 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Fri, 9 Sep 2022 21:36:54 +0200 Subject: [PATCH] Fix memory leak with file upload (#437) fix: fix memory leak with file upload Fix the issue because of which `PNFilesManager` leaked each time when PubNub client was created. --- .pubnub.yml | 17 +++++++++++------ CHANGELOG.md | 6 ++++++ Example/PubNub/PNAppDelegate.m | 2 +- Framework/PubNub/Info.plist | 6 +++--- Framework/PubNub/PubNub-iOS-Info.plist | 6 +++--- Framework/PubNub/PubNub-tvOS-Info.plist | 6 +++--- Framework/PubNub/PubNub-watchOS-Info.plist | 6 +++--- PubNub.podspec | 2 +- PubNub/Core/PubNub+Core.m | 2 ++ PubNub/Data/Managers/PNFilesManager.h | 8 ++++++++ PubNub/Data/Managers/PNFilesManager.m | 4 ++++ PubNub/Misc/PNConstants.h | 2 +- README.md | 2 +- Tests/Podfile.lock | 8 ++++---- VERSION | 2 +- 15 files changed, 52 insertions(+), 27 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 50b0e27af..cb2780ff5 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,14 @@ --- name: objective-c scm: github.com/pubnub/objective-c -version: "5.1.0" +version: "5.1.1" schema: 1 changelog: + - date: 2022-09-06 + version: v5.1.1 + changes: + - type: bug + text: "Fix issue because of which `PNFilesManager` leaked each time when PubNub client created." - date: 2022-03-11 version: v5.1.0 changes: @@ -1300,7 +1305,7 @@ sdks: - distribution-type: source distribution-repository: GitHub release package-name: PubNub.framework - location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.1.0.zip + location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.1.1.zip supported-platforms: supported-operating-systems: macOS: @@ -1361,7 +1366,7 @@ sdks: - distribution-type: library distribution-repository: GitHub release package-name: PubNub.catalyst.xcframework.tar.gz - location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.catalyst.xcframework.tar.gz + location: https://github.com/pubnub/objective-c/releases/download/v5.1.1/PubNub.catalyst.xcframework.tar.gz supported-platforms: supported-operating-systems: macOS: @@ -1390,7 +1395,7 @@ sdks: - distribution-type: library distribution-repository: GitHub release package-name: PubNub.ios.xcframework.tar.gz - location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.ios.xcframework.tar.gz + location: https://github.com/pubnub/objective-c/releases/download/v5.1.1/PubNub.ios.xcframework.tar.gz supported-platforms: supported-operating-systems: iOS: @@ -1409,7 +1414,7 @@ sdks: - distribution-type: library distribution-repository: GitHub release package-name: PubNub.macos.framework.tar.gz - location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.macos.framework.tar.gz + location: https://github.com/pubnub/objective-c/releases/download/v5.1.1/PubNub.macos.framework.tar.gz supported-platforms: supported-operating-systems: macOS: @@ -1425,7 +1430,7 @@ sdks: - distribution-type: library distribution-repository: GitHub release package-name: PubNub.tvos.xcframework.tar.gz - location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.tvos.xcframework.tar.gz + location: https://github.com/pubnub/objective-c/releases/download/v5.1.1/PubNub.tvos.xcframework.tar.gz supported-platforms: supported-operating-systems: tvOS: diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eb56f05b..642f210dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v5.1.1 +September 06 2022 + +#### Fixed +- Fix the issue because of which `PNFilesManager` leaked each time when PubNub client was created. + ## v5.1.0 March 11 2022 diff --git a/Example/PubNub/PNAppDelegate.m b/Example/PubNub/PNAppDelegate.m index d0b6e616d..4c143799b 100644 --- a/Example/PubNub/PNAppDelegate.m +++ b/Example/PubNub/PNAppDelegate.m @@ -77,7 +77,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (void)pubNubInit { // Initialize PubNub client. - self.myConfig = [PNConfiguration configurationWithPublishKey:_pubKey subscribeKey:_subKey]; + self.myConfig = [PNConfiguration configurationWithPublishKey:_pubKey subscribeKey:_subKey uuid:@"pubnub"]; [self updateClientConfiguration]; [self printClientConfiguration]; diff --git a/Framework/PubNub/Info.plist b/Framework/PubNub/Info.plist index 2bf955957..ea6a55cc2 100644 --- a/Framework/PubNub/Info.plist +++ b/Framework/PubNub/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable PubNub CFBundleGetInfoString - 5.1.0 + 5.1.1 CFBundleIdentifier com.pubnub.pubnub-objc CFBundleInfoDictionaryVersion @@ -17,11 +17,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.1.0 + 5.1.1 CFBundleSignature ???? CFBundleVersion - 5.1.0 + 5.1.1 NSHumanReadableCopyright © 2010 - 2020 PubNub, Inc. NSPrincipalClass diff --git a/Framework/PubNub/PubNub-iOS-Info.plist b/Framework/PubNub/PubNub-iOS-Info.plist index 2bf955957..ea6a55cc2 100644 --- a/Framework/PubNub/PubNub-iOS-Info.plist +++ b/Framework/PubNub/PubNub-iOS-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable PubNub CFBundleGetInfoString - 5.1.0 + 5.1.1 CFBundleIdentifier com.pubnub.pubnub-objc CFBundleInfoDictionaryVersion @@ -17,11 +17,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.1.0 + 5.1.1 CFBundleSignature ???? CFBundleVersion - 5.1.0 + 5.1.1 NSHumanReadableCopyright © 2010 - 2020 PubNub, Inc. NSPrincipalClass diff --git a/Framework/PubNub/PubNub-tvOS-Info.plist b/Framework/PubNub/PubNub-tvOS-Info.plist index 2bf955957..ea6a55cc2 100644 --- a/Framework/PubNub/PubNub-tvOS-Info.plist +++ b/Framework/PubNub/PubNub-tvOS-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable PubNub CFBundleGetInfoString - 5.1.0 + 5.1.1 CFBundleIdentifier com.pubnub.pubnub-objc CFBundleInfoDictionaryVersion @@ -17,11 +17,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.1.0 + 5.1.1 CFBundleSignature ???? CFBundleVersion - 5.1.0 + 5.1.1 NSHumanReadableCopyright © 2010 - 2020 PubNub, Inc. NSPrincipalClass diff --git a/Framework/PubNub/PubNub-watchOS-Info.plist b/Framework/PubNub/PubNub-watchOS-Info.plist index 2bf955957..ea6a55cc2 100644 --- a/Framework/PubNub/PubNub-watchOS-Info.plist +++ b/Framework/PubNub/PubNub-watchOS-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable PubNub CFBundleGetInfoString - 5.1.0 + 5.1.1 CFBundleIdentifier com.pubnub.pubnub-objc CFBundleInfoDictionaryVersion @@ -17,11 +17,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.1.0 + 5.1.1 CFBundleSignature ???? CFBundleVersion - 5.1.0 + 5.1.1 NSHumanReadableCopyright © 2010 - 2020 PubNub, Inc. NSPrincipalClass diff --git a/PubNub.podspec b/PubNub.podspec index 209dc911f..581b3ba3b 100644 --- a/PubNub.podspec +++ b/PubNub.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |spec| spec.name = 'PubNub' - spec.version = '5.1.0' + spec.version = '5.1.1' spec.summary = 'The PubNub Real-Time Network. Build real-time apps quickly and scale them globally.' spec.homepage = 'https://github.com/pubnub/objective-c' diff --git a/PubNub/Core/PubNub+Core.m b/PubNub/Core/PubNub+Core.m index 93a7f6011..547f7c19d 100644 --- a/PubNub/Core/PubNub+Core.m +++ b/PubNub/Core/PubNub+Core.m @@ -788,6 +788,8 @@ - (void)dealloc { [_serviceNetwork invalidate]; _serviceNetwork = nil; [_telemetryManager invalidate]; + [_filesManager invalidate]; + _filesManager = nil; } #pragma mark - diff --git a/PubNub/Data/Managers/PNFilesManager.h b/PubNub/Data/Managers/PNFilesManager.h index a7ebfe43a..4c830a196 100644 --- a/PubNub/Data/Managers/PNFilesManager.h +++ b/PubNub/Data/Managers/PNFilesManager.h @@ -72,6 +72,14 @@ NS_ASSUME_NONNULL_BEGIN completion:(void(^)(NSURLRequest *request, NSURL * _Nullable location, NSError * _Nullable error))block; + +#pragma mark - Misc + +/** + * @brief Invalidate and reclaim all resources allocated by files manager. + */ +- (void)invalidate; + #pragma mark - diff --git a/PubNub/Data/Managers/PNFilesManager.m b/PubNub/Data/Managers/PNFilesManager.m index dd52a75d5..30a8073f4 100644 --- a/PubNub/Data/Managers/PNFilesManager.m +++ b/PubNub/Data/Managers/PNFilesManager.m @@ -431,6 +431,10 @@ - (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *) #pragma mark - Misc +- (void)invalidate { + [self.session finishTasksAndInvalidate]; +} + - (NSError *)uploadErrorForTask:(NSURLSessionDataTask *)task httpResponse:(NSHTTPURLResponse *)response responseData:(NSData *)data diff --git a/PubNub/Misc/PNConstants.h b/PubNub/Misc/PNConstants.h index 2cc9b29cd..ac4c5561d 100644 --- a/PubNub/Misc/PNConstants.h +++ b/PubNub/Misc/PNConstants.h @@ -15,7 +15,7 @@ #pragma mark General information constants // Stores client library version number -static NSString * const kPNLibraryVersion = @"5.1.0"; +static NSString * const kPNLibraryVersion = @"5.1.1"; // Stores information about SDK codebase static NSString * const kPNCommit = @"fd5c7ed678527fce07eaf7eb162935caf1bfd303"; diff --git a/README.md b/README.md index 028431e28..3df21a5a9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PubNub 5.1.0 for iOS 9+ +# PubNub 5.1.1 for iOS 9+ [![Twitter](https://img.shields.io/badge/twitter-%40PubNub-blue.svg?style=flat)](https://twitter.com/PubNub) [![Twitter Releases](https://img.shields.io/badge/twitter-%40PubNubRelease-blue.svg?style=flat)](https://twitter.com/PubNubRelease) [![License](https://img.shields.io/github/license/pubnub/objective-c.svg?style=flat)](https://img.shields.io/github/license/pubnub/objective-c.svg) diff --git a/Tests/Podfile.lock b/Tests/Podfile.lock index c56fc57ae..36cd0acee 100644 --- a/Tests/Podfile.lock +++ b/Tests/Podfile.lock @@ -1,9 +1,9 @@ PODS: - Cucumberish (1.4.0) - OCMock (3.6) - - PubNub (5.0.0): - - PubNub/Core (= 5.0.0) - - PubNub/Core (5.0.0) + - PubNub (5.1.0): + - PubNub/Core (= 5.1.0) + - PubNub/Core (5.1.0) - YAHTTPVCR (1.4.2) DEPENDENCIES: @@ -32,7 +32,7 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: Cucumberish: 6cbd0c1f50306b369acebfe7d9f514c9c287d26c OCMock: 5ea90566be239f179ba766fd9fbae5885040b992 - PubNub: b218a66a1f4c772e2eb55a889aa349feb1fbd25e + PubNub: 49b8a60d845c722ef636b9db5ede52d6f962cc18 YAHTTPVCR: e2aa406443a4db12585ff626b445369e1953a729 PODFILE CHECKSUM: 569ce5fdb7670790d6d4a9d1a5a304a20781e374 diff --git a/VERSION b/VERSION index 831446cbd..ac14c3dfa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.1.0 +5.1.1