I have noticed that sort_hook function don't destroy temporary pool. This leads to a memory consumption of ~500K (=68 hooks * 8K) per PROCESS! The resolution is very simple - destroy this pool after usage (before returning the sorted hooks array). Since the sorted hooks are memcpy'ed to another pool anyway, no one need this pool.
Created attachment 27052 [details] destroy the pool after usage
committed in r1127053 Thanks!