Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We had a similar problem. While fetching lots of images over http, there was huge growth and a sawtooth pattern in the memory allocation. We'd see the system clean up, more or less, as it went, but slowly, and not predictably. Meanwhile the downloads were streaming in, piling up on whatever was holding onto the memory. Memory allocation would crest around 200M and then we'd die. </p> <p>The problem was an NSURLCache issue. You stated that you tried [[NSURLCache sharedURLCache] removeAllCachedResponses]. We tried that, too, but then tried something a little different.</p> <p>Our downloads are done in groups of <em>N</em> images/movies, where <em>N</em> was typically 50 to 500. It was important that we get all of <em>N</em> as an atomic operation. </p> <p>Before we started our group of http downloads, we did this:</p> <pre><code>NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:0]; [NSURLCache setSharedURLCache:sharedCache]; </code></pre> <p>We then get each image in <em>N</em> over http with a synchronous call. We do this group download in an NSOperation, so we're not blocking the UI.</p> <pre><code>NSData *movieReferenceData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; </code></pre> <p>Finally, after each individual image download, and after we're done with our NSData object for that image, we call:</p> <pre><code>[sharedCache removeAllCachedResponses]; </code></pre> <p>Our memory allocation peak behavior dropped to a very comfortable handful of megabytes, and stopped growing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload