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 protected]> 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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to