The patch I attached actually frees memory before the connection ends but do a lot of assumptions that might not work. The cleanest solution is probably just to disable chunked transfer encoding with the option:
I am using 0.7.65 and it does not support this option.
which removes the problem at the root (if it is ok for you to disable chunked transfer encoding, of if you already implement it in the proxied server).
AFAIK nginx does not support memory freeing/reuse before connection ends and, with current architecture, is not a trivial job to do (requires to handle reuse of non-contiguous allocations).