• 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: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)


  • Subject: Re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
  • From: email@hidden
  • Date: Sun, 4 Nov 2007 06:27:23 -0500


On Nov 3, 2007, at 7:08 PM, Ben Trumbull wrote:

You mean RSIZE as reported by 'top', not malloc's free heap space as reported by 'heap'.

Actually, I was observing VSIZE (which I thought should track with RSIZE as long as the system isn't swapping my app) and also the graph in ObjectAlloc, which appeared to correlate with VSIZE. In other words, even the graph of all allocations in ObjectAlloc shows only a small reduction when the document is closed. 'heap' is the tool I needed, though. Thanks!


the peak memory doesn't go up, so the memory is apparently reused.

Correct. The memory is freed (heap space), but not returned to the kernel (VM mapping). This is the behavior of malloc on OSX. You will see a high watermark effect.


I've read that, but forgot to consider it in this case. However, I'm confused by the test case below. When the memory is malloc'ed, VSIZE goes up. When the memory is used, RSIZE goes up. When the memory is freed, both VSIZE and RSIZE go back down. Does this contradict what you are saying?

#include <stdlib.h>

int main( int argc, char *argv[])
{
    sleep(5);
    char *ptr;
    while (1) {
        ptr = malloc(10 * 1024 * 1024);
        sleep(10);

        int i;
        for( i = 0; i < (10 * 1024 * 1024); i++)
            *(ptr + i) = 'x';
        sleep(10);

        free(ptr);
        sleep(10);
    }
}


No, allocation events for managed objects are not currently tracked by ObjectAlloc except as general blocks. The 'heap' and 'leaks' tools both perceive managed objects. You'll probably find the 'heap' tool useful for experimenting with these questions. Also, 'malloc_history' is much improved on Leopard and often overlooked.

I was using 'leaks' and had a few leaks, but nothing that explained the large amount of memory I was using, so I suspected I had a retain cycle with some managed objects. Ultimately, I found I forgot to add an autorelease pool to one of my loops.


You are right, 'heap' would have been very useful for this. I've used malloc_history for an over-release/BAD_EXEC bug, and it was great for that.

Thanks, Ben.

Aaron
_______________________________________________

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: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
      • From: Ben Trumbull <email@hidden>
References: 
 >re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops) (From: Ben Trumbull <email@hidden>)

  • Prev by Date: Re: [WebFrame url] -- How to get the initial URL from WebView or WebFrame?
  • Next by Date: Re: Why initialize the menubar without Interface Builder
  • Previous by thread: re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
  • Next by thread: Re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
  • Index(es):
    • Date
    • Thread