Summary:
I noticed that after a long-running flipper session, 11% of the memory was composed of millions of tiny PromiseReaction records (https://github.com/domenic/promises-unwrapping#promisereaction-records).
It seems this method of chaining promises meant that it was forming a linked list of these from the most recent, back to the very first invocation.
Instead of using a home-rolled lock, I'm replacing it with an actual library. Haven't verified the fix, but this seems like a better approach regardless.
Reviewed By: passy
Differential Revision: D15853570
fbshipit-source-id: 1626d9f25cba809794b13ee920bdec2cd1d4b874