nsEventQueue uses a linked list of Page objects to pass pointers to nsThreads. A Page is a struct containing 251 pointers. Depending on sizeof(void*), a Page uses only 1004 or 2008 bytes of its heap block's actual 1024 or 2048 bytes before allocating the next Page. Also, one might ask whether 250 is a reasonable value for EVENTS_PER_PAGE. In my testing, most nsEventQueues have a high-water mark less than ~50 events. https://hg.mozilla.org/mozilla-central/file/4930fdea3efa/xpcom/threads/nsEventQueue.h#l63
If you change it to 255, a static assertion that sizeof(Page) is a power of two would be great!
Created attachment 798703 [details] [diff] [review] EVENTS_PER_PAGE.patch Increase nsEventQueue::EVENTS_PER_PAGE from 250 to 255 so sizeof(nsEventQueue::Page) will be a power of two to avoid heap allocation slop.
bsmedberg: btw, here are your original comments on EVENTS_PER_PAGE from 2006: https://bugzilla.mozilla.org/show_bug.cgi?id=326273#c54