Fix memory usage issue
Summary: I noticed during testing that jemalloc requests a lot more memory than is allocated by the application. This is particularly the case for allocations >4k. If the allocation is <2MB it asks for an extra 2MB region that is not used for allocated memory, and if the request is >2MB then an extra region of the same size is requested in the extent hook. Turns out the issue was that I didn't set *commit to true in the alloc hook, causing an interesting sequence of events to occur. Another issue is that when running out of space and falling back to the default hook, subsequent requests would increase in size forever. The solution here was to set the jemalloc retain grow limit. Finally, fixed a bug when reserving more than 4GB memory (size calculation was truncated to 32 bits). Reviewed By: interwq Differential Revision: D10316308 fbshipit-source-id: af47438029e85c03bf51c8d132b88de551f493f1
Showing
Please register or sign in to comment