• 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: Aaron Burghardt <email@hidden>
  • Date: Sun, 4 Nov 2007 22:01:01 -0500


On Nov 4, 2007, at 5:36 PM, Ben Trumbull wrote:

On Nov 4, 2007, at 3:27 AM, email@hidden wrote:


No. The relationship is more complicated. For large blocks of memory, malloc will return the allocation back to the kernel. For small blocks, it will not, but instead coalesce the free space for reuse later. The objects used in Core Data are almost exclusively small. Amit


ptr = malloc(10 * 1024 * 1024);

Try again with something closer to the size of your managed objects. Like 96-256 bytes.


Generally, I find RSIZE to reflect the high watermark of the process, and use 'heap' to examine the currently free space within it. Your mileage may vary. There's some pretty vociferous disagreement over the "ideal" way to measure memory utilization (available v.s. vm deallocated v.s. internal fragmentation, etc)

Yup, even 10 KB mallocs were small enough. For anyone that may be following this thread, the following test looks different in Activity Monitor (and and presumably ObjectAlloc). Once the VSIZE and RSIZE go up, they stay at that level until the test quits:

#include <stdlib.h>

int main( int argc, char *argv[])
{
    sleep(5);
    char *ptr[1000];
    int i;
    while (1) {
        for( i = 0; i < 1000; i++)
            ptr[i] = malloc(10 * 1024);
        sleep(10);

        int j;
        for( i = 0; i < 1000; i++) {
            for( j = 0; j < (10 * 1024); j++)
                *(ptr[i] + j) = 'x';
        }
        sleep(10);

        for( i = 0; i < 1000; i++)
            free(ptr[i]);
        sleep(10);
    }
}

Thanks again,

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

  • Prev by Date: Re: Comparing NSColor instances
  • Next by Date: Converting *u unicode hex sequences
  • 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