• 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: If No Memory Leaks, Is It Good Enough for Memory Management?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: If No Memory Leaks, Is It Good Enough for Memory Management?


  • Subject: Re: If No Memory Leaks, Is It Good Enough for Memory Management?
  • From: Conrad Shultz <email@hidden>
  • Date: Mon, 20 Jun 2011 01:12:31 -0700

First, please tell me you have read up on memory management after every person on this list told you to do so. And bought a C book.

That said, no, Instruments not showing any leaks is not itself sufficient to prove you are managing memory properly.

For one, Instruments will generally only show a leak when an allocated object no longer has anything referencing it.  You can easily circumvent this with a retain cycle, for example.

Second, I'm not sure what its current level of support for Foundation objects (and C in general) is. I vaguely recall having to manually hunt down a missing CGGradientRelease() when Leaks proved less than helpful. If this is still an issue, it will not help you with your C memory management.

As for your situation, repeat after me: "Activity Monitor is not a profiling tool." This should be recited about as often as "I shall not examine retainCount for any reason whatsoever."

There are all sorts of things that can go on behind the scenes to cause memory usage to grow. For example, some classes may implement a concealed cache that will be purged as needed with no intervention needed on your part.

If you want to get a better grasp on what might be happening, use heapshot analysis to start. (This is far from the first time I have mentioned this to you.) Bill Bumgarner has a nice post on its use (http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/). There is also coverage in the 2010 WWDC videos.

Given your recent posts, if I had to hazard a guess I would predict that in your C code you have a malloc() not paired with a free() or something to that effect.

(Sent from my iPad.)

--
Conrad Shultz

On Jun 20, 2011, at 0:26, Bing Li <email@hidden> wrote:

> Dear all,
>
> I am still a new programmer of Cocoa. In my program, at least right now,
> there are no memory leaks according to Instruments. Is it good enough for
> memory management?
>
> What I designed is a TCP server which receives TCP messages. When I tested
> it, 200,000 XML were sent to it with a loop without any delays. Each XML had
> 800 bytes. In this case, no any memory leaks when testing it with
> Instruments. However, according to Activity Monitor, the consumed memory was
> increased from 17.9M to more than 400M. Immediately after the sending, the
> consumed memory started to be lowered until it was stopped to 100M. Was it
> normal? Why wasn't it 17.9M eventually?
>
> Thanks so much for your help!
>
> Best,
> greatfree
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >If No Memory Leaks, Is It Good Enough for Memory Management? (From: Bing Li <email@hidden>)

  • Prev by Date: Re: Automatically mirroring folders
  • Next by Date: Re: Progress Indicators Spin vs Bar
  • Previous by thread: If No Memory Leaks, Is It Good Enough for Memory Management?
  • Next by thread: Re: If No Memory Leaks, Is It Good Enough for Memory Management?
  • Index(es):
    • Date
    • Thread