freeing buffers after sending them
George .
george at ucdn.com
Wed Oct 12 10:22:08 UTC 2016
Hi all,
What do you think about freeing buffers after being sent by send_chain?
Because we have a special case were we use 4 megabyte buffer instead of
nginx default 8 * 8 K and we found that these buffers are actually freed
after request had been finished, so if there hundreds of slow downstream
connection nginx will eat a lot of RAM.
I'm just curious if I explicitly return already consumed buffer with
ngx_pfree will affect something (our bunch of tests shows at least there
is not crash or unexpected behaviour)
@@ -284,6 +284,13 @@ ngx_http_write_filter(ngx_http_request_t *r,
ngx_chain_t *in)
chain = c->send_chain(c, r->out, limit);
+ /* free buffs that are already sent */
+ for (cl = r->out; cl; /* void */) {
+ ln = cl;
+ cl = cl->next;
+ ngx_pfree(c->pool, ln->buf);
+ }
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http write filter %p", chain)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20161012/c8efcf59/attachment.html>
More information about the nginx-devel
mailing list