★ What's on your heap, mister?

 — 1 minute read


If you ever wondered or have been confronted with the question, what actually is on your heap, the answer is surprisingly simple: Strings, Collections, and boxed numbers make the majority.

For example, see the statistics for Mac OS X 10.8 Calendar and Safari below. non-object represents direct allocations with malloc et al.

Top 8 for Calendar:

    COUNT     BYTES   CLASS_NAME
    53561  10591424   non-object
    19368   1033616   __NSCFString
    14132    226112   _NSObjectID_48_1d
     7053    789936   CalManagedAlarm_Alarm_
     3511    168528   __NSArrayM
     2781    177984   __NSCFDictionary
     1808     86784   __NSDictionaryM
     1555     49760   __NSCFNumber

Top 8 for Safari:

    COUNT     BYTES   CLASS_NAME
   200113  50402208   non-object
   111900   9927472   __NSCFString
    17341   1109824   __NSCFDictionary
    12519    600912   __NSDictionaryM
     9715    466320   __NSArrayM
     5122   2082400   __NSCFData
     3434    175600   __NSArrayI
     3392    108544   __NSCFNumber

But then, this is not surprising at all. Seriously, what else could there be on the heap if you think about it?!