How can I clear the network requests and responses left in the device memory?

I'm using AFNetworking as my basic networking library. When I do a memory dump on a jailbroken phone (iPhone 4, iOS 7.1), I can easily see request urls and/or responses (such as json objects) in the dump files in plain text. I checked with the memory leak tool in Xcode and there is no memory leak based on that.

My app has sensitive data in the urls or responses (Like user's name, email address, etc), which are listed in the OWASP mobile risks (M4: Unintended Data Leakage). We are required to be in compliance with these standards so I want to clean this information right after the connection finished. What I have done so far:

1) Set the cache policy in the AFNetworking to NSURLRequestReloadIgnoringLocalCacheData

2) Disabling the NSURLCache in the app:

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];

3) I also tried:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

or

[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest];

after every network request.

But none of the above have resolved the problem. Can anyone help me figure out how to do this? Any help will be appreciated.

AFNetworking is

Copyright (c) 2011–2015 Alamofire Software Foundation (http://http://alamofire.org/)


So please explain what you are asking AFNetwork to do, and how it is doing it.

The moment you note Jailbroken, the discussion is over. Apple does not support such configurations and

your app should not either. Either implement detection methods to determine this is the case or forget about

being in compliance. There is no way around it on a jailbroken device.

Thank you for your reply. I used jailbroken phone to get the memory dump. The issue is not because of jailbroken phone, the url requests and responses stay in the memory reguardless it's jailbroken or not.

How can I clear the network requests and responses left in the device memory?
 
 
Q