Lots of people have asked where most of the allocations in Mozilla come from. I’ve gzipped some dtrace output that shows number of calls per size of stacks 5 deep. Note: This log only shows allocations <= 2048 bytes. This data is pretty raw but if people want to take a look at it and see if they have ideas for how to improve some of the code paths in question, that would be great.
libSystem.B.dylib`malloc+0x37 XUL`nsStringBuffer::Alloc(unsigned long)+0x15 XUL`nsACString_internal::MutatePrep(unsigned int, char**, unsigned int*)+0xce XUL`nsACString_internal::ReplacePrep(unsigned int, unsigned int, unsigned int)+0x46 XUL`nsACString_internal::Assign(char const*, unsigned int)+0xc8 value ------------- Distribution ------------- count 4 | 0 8 |@@@@@@@@@@@@@ 9724 16 |@@@@@@@@@@@@@@@@ 11940 32 |@@@@@@ 4359 64 |@ 887 128 |@@ 1604 256 |@ 497 512 |@ 676 1024 | 47 2048 | 0
This shows that there are 9724 8 byte allocations, 11940 16 byte ones and so on.
Things to look for include:
- Things with lots of allocations
- Things that could be stack allocated to avoid memory churn
- Things that the lifetime is well understood that we could put in to pools