A request keeps its middleware runtimes until its reply has streamed,
so its hooks share ctx.state, and moejs kept the body each hook was
given, parsed, in the runtime's registers until End: a long context's
body was alive for the whole reply, ~10 MB for a 7 MB body. The report's
inuse profile had 448 MB under moejs ParseJSON with many agents
streaming at once. Request and Tried now call ReleaseCallData on the
request's runtimes once their hooks are done; ctx, and what ctx.state
holds, stay. Not after each onEvent: an event is small and its hooks run
a thousand times a reply.
Run:
- TestStreamingRequestHoldsNoBody: 8 requests streaming with a 7 MB
body hold under 7 MB, and onEvent still reads ctx.state; with the
release commented out by hand it fails ("8 streaming requests hold 69
MB, their body is 7 MB").
- go test -count=1 ./internal/middleware/ ./internal/gwmw/: ok.
- go test -count=1 -run 'Middleware|Think|Strateg' ./internal/gateway/
./plugins/...: ok.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui
clean for internal/middleware.