• 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: Memory "weight" of objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory "weight" of objects


  • Subject: Re: Memory "weight" of objects
  • From: Daniel Jalkut <email@hidden>
  • Date: Sun, 04 Dec 2005 23:15:35 -0500

Yeah. I was wondering if Foundation might optimize the small objects by stashing more than one object into a single malloc block. But if it were doing that, I suppose it would pick a much higher number than the minimum block size from which to parcel out its sub-allocations!

Daniel

On Dec 4, 2005, at 9:46 PM, John Stiles wrote:

That's true, but your original post was already a perfect answer to the question being asked.
Even if the NSData struct is only 1 byte long, malloc(1) is going to bite off a 16-byte chunk since that's the minimum allocation size (IIRC!). So in terms of "how much memory does this allocation consume," well, it takes up 16 bytes, because malloc_size(malloc (1)) == 16.

Daniel Jalkut wrote:

I suppose I should add a disclaimer that the numbers returned by malloc_size might be larger than actually used by the object. It's probably always rounded up to whatever malloc's block sizes are. I don't know if NSObject instances are small enough to share a single 16 byte memory block, though.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Memory "weight" of objects (From: Felix Schwarz <email@hidden>)
 >Re: Memory "weight" of objects (From: Daniel Jalkut <email@hidden>)
 >Re: Memory "weight" of objects (From: Daniel Jalkut <email@hidden>)
 >Re: Memory "weight" of objects (From: John Stiles <email@hidden>)

  • Prev by Date: How To Create iCal Application Day View Task
  • Next by Date: Re: Saving C++ based data structures
  • Previous by thread: Re: Memory "weight" of objects
  • Next by thread: Search Array for Variable in Object
  • Index(es):
    • Date
    • Thread