Re: Why Wasn't Memory Collected?
Re: Why Wasn't Memory Collected?
- Subject: Re: Why Wasn't Memory Collected?
- From: Bing Li <email@hidden>
- Date: Sun, 12 Jun 2011 13:39:22 +0800
Dear Nick,
I appreciate so much for your reply!
I add a sub-autoreleasepool immediately outside the method that created XML.
Once if the XML is sent, the memory should be released, right? Now the
amount of memory consumed is very limited, almost no change in Activity
Monitor.
So I guess sub-autoreleasepool is important. We should not depend on the
most high level autoreleasepool to collect memory. Am I right?
Thanks,
Bing
On Sun, Jun 12, 2011 at 7:12 AM, Nick Zitzmann <email@hidden> wrote:
>
> 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@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