Skip to content

Commit

Permalink
Fix memory leak with file upload (#437)
Browse files Browse the repository at this point in the history
fix: fix memory leak with file upload

Fix the issue because of which `PNFilesManager` leaked each time when PubNub client was created.
  • Loading branch information
parfeon authored Sep 9, 2022
1 parent 3520a12 commit 4d60f01
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 27 deletions.
17 changes: 11 additions & 6 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion Example/PubNub/PNAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-iOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-tvOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-watchOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion PubNub.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 2 additions & 0 deletions PubNub/Core/PubNub+Core.m
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ - (void)dealloc {
[_serviceNetwork invalidate];
_serviceNetwork = nil;
[_telemetryManager invalidate];
[_filesManager invalidate];
_filesManager = nil;
}

#pragma mark -
Expand Down
8 changes: 8 additions & 0 deletions PubNub/Data/Managers/PNFilesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 -


Expand Down
4 changes: 4 additions & 0 deletions PubNub/Data/Managers/PNFilesManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PubNub/Misc/PNConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Tests/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -32,7 +32,7 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
Cucumberish: 6cbd0c1f50306b369acebfe7d9f514c9c287d26c
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992
PubNub: b218a66a1f4c772e2eb55a889aa349feb1fbd25e
PubNub: 49b8a60d845c722ef636b9db5ede52d6f962cc18
YAHTTPVCR: e2aa406443a4db12585ff626b445369e1953a729

PODFILE CHECKSUM: 569ce5fdb7670790d6d4a9d1a5a304a20781e374
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.1.1

0 comments on commit 4d60f01

Please sign in to comment.