Implemented post task using NSURLSession and was sending a dectionary in the body of NSMutableURLRequest. The Strings in the dictionary stays in the memory even after the task is done.
NSError *error;
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:3030/validate"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60.0];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setHTTPMethod:@"POST"];
NSMutableDictionary *mapData = [[NSMutableDictionary alloc] initWithObjectsAndKeys: @"darkhorse", @"usrname",
nil];
NSData *postData = [NSJSONSerialization dataWithJSONObject:mapData options:0 error:&error];
[request setHTTPBody:postData];
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
}];
[postDataTask resume];
Was able to dump the strings using below commands:
Step 1 : Connect lldb debugger to device/simulator
Step 2 : Import => "script import lldb.macosx.heap"
Step 3 : Search for strings "cstr_refs CSTRING "darkhorse"" after the NSURLSessionDataTask is done