Draft: Implement user-defined allocation limit handlers
This allows setting user-defined handlers to be called when allocation limits are exceeded.
This still needs some documentation and a test case.
I also need to expose an API for setting the allocation counter and enabling the allocation limit for another thread.