In order to profile memory leakage/heap growth in Swift on Linux, you need to a) run it on Linux b) use a profiling tool.
Docker and Valgrind to the rescue.
We're using the official Swift image here: FROM swift:4.
I hereby claim:
To claim this, I am signing this object:
| public final class LiteralColor: UIColor, IntegerLiteralConvertible { | |
| public typealias IntegerLiteralType = Int | |
| public init(integerLiteral value: Int) { | |
| let netHex = value | |
| let red = (netHex >> 16) & 0xff | |
| let green = (netHex >> 8) & 0xff | |
| let blue = netHex & 0xff | |
| assert(red >= 0 && red <= 255, "Invalid red component") | |
| assert(green >= 0 && green <= 255, "Invalid green component") | |
| assert(blue >= 0 && blue <= 255, "Invalid blue component") |
| // Creates a new in memory realm for testing | |
| internal func NewTestRealm() -> Realm { | |
| let idString = NSUUID().UUIDString | |
| let config = Realm.Configuration(inMemoryIdentifier: idString) | |
| return try! Realm(configuration: config) | |
| } | |
| import RealmSwift | |
| import Foundation |
| diff --git a/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift b/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift | |
| index faabbf4..55d0420 100755 | |
| --- a/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift | |
| +++ b/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift | |
| @@ -67,21 +67,20 @@ public extension RACSignal { | |
| /// Maps data received from the signal into a JSON object. If the conversion fails, the signal errors. | |
| public func mapJSON() -> RACSignal { | |
| - return tryMap({ (object, error) -> AnyObject! in | |
| + return tryMap({ (object, retError) -> AnyObject! in |
| source.lang.swift.decl.function.free | |
| source.lang.swift.ref.function.free | |
| source.lang.swift.decl.function.method.instance | |
| source.lang.swift.ref.function.method.instance | |
| source.lang.swift.decl.function.method.static | |
| source.lang.swift.ref.function.method.static | |
| source.lang.swift.decl.function.method.class | |
| source.lang.swift.ref.function.method.class | |
| source.lang.swift.decl.function.accessor.getter | |
| source.lang.swift.ref.function.accessor.getter |
| // Warnings | |
| WARNING_CFLAGS = -Weverything -Wno-error-auto-import -Wno-error-documentation-unknown-command -Wno-error-super-class-method-mismatch -Wno-error-incomplete-module -Wno-objc-missing-property-synthesis -Wno-gnu -Wno-error-undef -Wno-error-receiver-is-weak -Wno-error-missing-variable-declarations -Wno-error-objc-interface-ivars -Wno-error-documentation | |
| GCC_WARN_PEDANTIC = YES | |
| GCC_TREAT_WARNINGS_AS_ERRORS = YES | |
| CLANG_WARN_DOCUMENTATION_COMMENTS = YES | |
| CLANG_WARN_EMPTY_BODY = YES | |
| GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES | |
| GCC_WARN_SHADOW = YES | |
| CLANG_WARN_BOOL_CONVERSION = YES |
| @interface LMLPlaintextResponseSerializer : AFHTTPResponseSerializer | |
| @end | |
| @implementation LMLPlaintextResponseSerializer | |
| - (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error { | |
| [super responseObjectForResponse:response data:data error:error]; //BAD SIDE EFFECTS BAD BUT NECESSARY TO CATCH 500s ETC | |
| NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)([response textEncodingName] ?: @"utf-8"))); | |
| return [[NSString alloc] initWithData:data encoding:encoding]; |