• 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: Mike Morton <email@hidden>
  • Date: Tue, 6 Dec 2005 09:21:18 -0500

All --

Daniel Jalkut wrote:

I wouldn't let these memory readings cause you too much worry. I can't exactly explain the trends you observe, but I don't want to have to explain them, either! I assume there are minor implementation details about the memory allocation system that you should choose to "not be concerned with" unless you have a specific reason to be. I ran your program and then ran the "leaks" command against it. It revealed only one leak, of 1024 bytes, which I'm not sure is even a true leak. I would use more sanctioned memory management tools than "ps" -- I could easily see the fluctuations of actual memory usage as being misleading in attempting to gauge your true memory problems.

Our real app, when running for very long periods, sucks up memory to the point that it runs out of VM, so we clearly have a problem -- though the toy app may not be modeling the problem correctly.


For example, I took your tool and added a loop criteria to the while loop that it would run for 100 times. I let it go, and later looked at the output. On the 1st loop, the memory usage was 51148. Later, it was as high as 63076. By the 100th loop, the memory usage was back down to 52796. I would consider all of this to be statistical noise. Trust the leaks tool and MallocDebug, unless you have specific reasons to worry that serious inefficiencies are escaping their grasp.

On my 10.3.x system, it never seems to release much memory. I ran 1,000 iterations and it grew from 32824K to 144920K. Most jumps were 112K, the size of the downloaded image. Memory dropped by as much as 104K and grew by as much as 320K in a single iteration.

MallocDebug does show this tool allocating memory and not freeing it. I think 'leaks' is silent because some cache is pointing to the memory.


Lee Morgan wrote:

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

I tried this, but still see memory growth (using 'ps' or MallocDebug).


I’d be interested in hearing more ideas, but I think it’s time to use a DTS incident on this one…

Thanks,

-- 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
  • Follow-Ups:
    • Re: +[NSData dataWithContentsOfURL:] leaks memory?
      • From: Daniel Jalkut <email@hidden>
References: 
 >+[NSData dataWithContentsOfURL:] leaks memory? (From: Mike Morton <email@hidden>)
 >Re: +[NSData dataWithContentsOfURL:] leaks memory? (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: Re: Double-clicking multiple selection in a TableView
  • Next by Date: Generation of a Waveform
  • Previous by thread: Re: +[NSData dataWithContentsOfURL:] leaks memory?
  • Next by thread: Re: +[NSData dataWithContentsOfURL:] leaks memory?
  • Index(es):
    • Date
    • Thread