Skip to content

Commit

Permalink
Merge pull request #14 from jensmeder/#12-fix-for-files-larger-than-1…
Browse files Browse the repository at this point in the history
…00MB

Add @autoreleasepool to prevent excessive memory usage in JMSocketCon…
  • Loading branch information
jensmeder authored Aug 3, 2016
2 parents e71b855 + 532c62e commit 983feb0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: objective-c
osx_image: xcode7.2
before_install:
- brew update
- brew upgrade xctool
osx_image: xcode7.3
script:
- xctool -project DarkLightning.xcodeproj -scheme OSX build test -sdk macosx GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES
after_success:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

`DarkLightning` adheres to [Semantic Versioning](http://semver.org/).

## 1.0.1

### Bugfix

* Fixed a bug that caused excessive memory usage when transmitting `NSData` objects larger than 100MB

## 1.0.0

### Additions
Expand Down
2 changes: 1 addition & 1 deletion DarkLightning.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DarkLightning"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "Simply the fastest way to transmit data between iOS/tvOS and OSX"
s.description = <<-DESC
DarkLightning is a lightweight Objective-C library to allow data transmission between iOS/tvOS devices (Lightning port, Dock connector, USB-C) and OSX (USB) at 480MBit.
Expand Down
12 changes: 6 additions & 6 deletions DarkLightning.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
10851441A6D47B3ADEB6922E /* debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = debug.xcconfig; sourceTree = "<group>"; };
1154B9D0A45B742AEEF2C58D /* JMHostSocketTests.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = JMHostSocketTests.m; sourceTree = "<group>"; };
15C87AD7C1ED29774E55A369 /* JMPathSocket.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = JMPathSocket.m; sourceTree = "<group>"; };
17EAA4271F51B960B346013D /* OSX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = OSX.framework; path = DarkLightning.framework; sourceTree = BUILT_PRODUCTS_DIR; };
17EAA4271F51B960B346013D /* DarkLightning.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DarkLightning.framework; sourceTree = BUILT_PRODUCTS_DIR; };
213E0165478BBEFCE41BCF03 /* debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = debug.xcconfig; sourceTree = "<group>"; };
2415CCAE390D0979CF3A6CB1 /* release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = release.xcconfig; sourceTree = "<group>"; };
279002F386B533E3F1A5B790 /* JMUSBMuxDecoderTests.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = JMUSBMuxDecoderTests.m; sourceTree = "<group>"; };
Expand All @@ -160,7 +160,7 @@
5F06D2796A71888616A3A3AC /* JMUSBMuxPacketFactory.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = JMUSBMuxPacketFactory.h; sourceTree = "<group>"; };
61CCC54181C7198A64E6574C /* usbmux_packet.c */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.c; path = usbmux_packet.c; sourceTree = "<group>"; };
6212F80B2F4A89F74F915E50 /* DarkLightning.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DarkLightning.h; sourceTree = "<group>"; };
6485B4A9EEDFD6ED0617C58B /* iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = iOS.framework; path = DarkLightning.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6485B4A9EEDFD6ED0617C58B /* DarkLightning.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DarkLightning.framework; sourceTree = BUILT_PRODUCTS_DIR; };
64B0B239B10A8DDA345DD690 /* JMUSBMuxPacketFactory.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = JMUSBMuxPacketFactory.m; sourceTree = "<group>"; };
6504B4CFE635AD1154DFAC3C /* JMTaggedPacketProtocol.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = JMTaggedPacketProtocol.m; sourceTree = "<group>"; };
6BA793266A28729E93FBFE7D /* DarkLightning.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = DarkLightning.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -553,8 +553,8 @@
E627AB7A4B3BCD8A1359D6DD /* Products */ = {
isa = PBXGroup;
children = (
6485B4A9EEDFD6ED0617C58B /* iOS.framework */,
17EAA4271F51B960B346013D /* OSX.framework */,
6485B4A9EEDFD6ED0617C58B /* DarkLightning.framework */,
17EAA4271F51B960B346013D /* DarkLightning.framework */,
81702C6B97F6B67AE17551C4 /* OSX-Tests.xctest */,
43D4C682A41BDDDEDC93D8C5 /* DarkLightning.framework */,
);
Expand Down Expand Up @@ -658,7 +658,7 @@
);
name = OSX;
productName = OSX;
productReference = 17EAA4271F51B960B346013D /* OSX.framework */;
productReference = 17EAA4271F51B960B346013D /* DarkLightning.framework */;
productType = "com.apple.product-type.framework";
};
73A159361E1E24E71DC9C3A9 /* tvOS */ = {
Expand Down Expand Up @@ -692,7 +692,7 @@
);
name = iOS;
productName = iOS;
productReference = 6485B4A9EEDFD6ED0617C58B /* iOS.framework */;
productReference = 6485B4A9EEDFD6ED0617C58B /* DarkLightning.framework */;
productType = "com.apple.product-type.framework";
};
F37A69E4885F6469753208BE /* OSX-Tests */ = {
Expand Down
11 changes: 7 additions & 4 deletions Source/Sockets/JMSocketConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,20 @@ -(BOOL)disconnect

-(BOOL)writeData:(NSData *)data
{
if (!data || data.length == 0 || _connectionState != JMSocketConnectionStateConnected)
{
if (!data || data.length == 0 || _connectionState != JMSocketConnectionStateConnected) {
return NO;
}

NSInteger bytesWritten = [_socket.outputStream write:data.bytes maxLength:data.length];

while (bytesWritten != (NSInteger)data.length) {

NSData* subData = [data subdataWithRange:NSMakeRange(bytesWritten, data.length-bytesWritten)];
bytesWritten += [_socket.outputStream write:subData.bytes maxLength:subData.length];
@autoreleasepool {

NSData* subData = [data subdataWithRange:NSMakeRange(bytesWritten, data.length-bytesWritten)];
bytesWritten += [_socket.outputStream write:subData.bytes maxLength:subData.length];
}
}

if(bytesWritten > 0)
Expand Down

0 comments on commit 983feb0

Please sign in to comment.