As is possibly well known, Jai uses a "context" that can be pushed / popped.
If the standard malloc and libraries then uses the context we gain some very powerful abilities.
For example, consider handling a web request (I'm going to use C syntax here)
int process_request(Request *request)
{ ... }
int handle_request(Request *request)
{
....
Context *context = push_context();
BumpAllocator allocator = BumpAllocator.create(MAX_MEM);
context.allocator = allocator;
int err = process_request(request);
pop_context();
allocator.release();
return err;
}
That is we emulate the php memory allocator.