• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: +[NSData dataWithContentsOfURL:] leaks memory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: +[NSData dataWithContentsOfURL:] leaks memory?


  • Subject: Re: +[NSData dataWithContentsOfURL:] leaks memory?
  • From: Lee Morgan <email@hidden>
  • Date: Mon, 5 Dec 2005 22:18:20 -0500

I had (what seems) to be the same problem a few months back...
I "fixed" it by using NSURL's resourceDataUsingCache instead.

--- Lee ---

"The price of greatness is responsibility."
- Sir Winston Churchill


On Dec 5, 2005, at 5:43 PM, Mike Morton wrote:

All --

Our app loads a lot of data using +[NSData dataWithContentsOfURL:] and this seems to use up memory, even though it loads inside the scope of an autorelease pool.

Here’s a simple (I hope) example, which seems to grow without bound. Each time it prints its own memory size, the size has grown by 112Kb, exactly the size of the downloaded image.

A few years back (at http://www.cocoabuilder.com/archive/message/ cocoa/2002/3/15/62361 ) some folks discussed whether +dataWithContentsOfURL: leaks, but I can’t find any workaround. Does anyone know if NSURLHandle works better?


(I’m not sure it always uses up memory. Among the many testbed tools I wrote while investigating this, I found some cases where the memory does seem to get freed — sometimes upon loading an image larget than the earlier ones. I figured I should stick with a simple example…)

-- Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >+[NSData dataWithContentsOfURL:] leaks memory? (From: Mike Morton <email@hidden>)

  • Prev by Date: Re: +[NSData dataWithContentsOfURL:] leaks memory?
  • Next by Date: Slightly OT: simulating a dock icon click via an AppleEvent (or otherwise)
  • Previous by thread: Re: +[NSData dataWithContentsOfURL:] leaks memory?
  • Next by thread: MEETING: Chicago - CAWUG December 6th
  • Index(es):
    • Date
    • Thread