On Jun 11, 2011, at 12:03 PM, Bing Li wrote:

> Dear all,
> 
> I sent a large number, e.g., 200,000, of XML to a remote node. Each time,
> the XML was created by the following method. Because of the large number, I
> noticed the consumed memory was large (more then 1G!) from Activity Monitor.
> Even after the sending was done, the memory was still kept in a high degree
> without any decreasing.
> 
> However, the method below should be able to collect the consumed memory,
> right?

Not always.

> Why wasn't memory collected?

If you're not using GC, and you're creating a lot of temporary objects in a 
loop, then you'll need to manually create and drain an autorelease pool inside 
that loop while being careful not to delete objects you don't want to delete. I 
find that it helps to use Instruments' object allocation tool, and watch for 
places where memory usage increases and then suddenly falls off. Those are the 
places where you need to set inline pools.

If you're using GC, then this will not be a problem, although if you create and 
drain an autorelease pool anyway, draining the pool will force the collector to 
begin if it hasn't already.

Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________

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