• 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: Why Wasn't Memory Collected?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why Wasn't Memory Collected?


  • Subject: Re: Why Wasn't Memory Collected?
  • From: Nick Zitzmann <email@hidden>
  • Date: Sat, 11 Jun 2011 17:12:01 -0600

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

  • Follow-Ups:
    • Re: Why Wasn't Memory Collected?
      • From: Bing Li <email@hidden>
References: 
 >Why Wasn't Memory Collected? (From: Bing Li <email@hidden>)

  • Prev by Date: Re: Mac OS Leopard: how to spawn an child "application"?
  • Next by Date: Getting CGColor components
  • Previous by thread: Why Wasn't Memory Collected?
  • Next by thread: Re: Why Wasn't Memory Collected?
  • Index(es):
    • Date
    • Thread