unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: unicorn-public@bogomips.org
Subject: [PATCH] http_response: clear header buffer before response body iteration
Date: Thu, 23 Feb 2017 18:07:49 +0000	[thread overview]
Message-ID: <20170223180749.29081-1-e@80x24.org> (raw)

To alleviate some memory pressure during response body
iteration, rely on String#clear to free(3) memory used for the
large header buffer.  Given the size of some response headers
such as cookies, this can release several kilobytes of malloc
heap memory for immediate use by other layers of the application
 lib/unicorn/http_response.rb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb
index ec128e4..284fc68 100644
--- a/lib/unicorn/http_response.rb
+++ b/lib/unicorn/http_response.rb
@@ -49,6 +49,7 @@ def http_response_write(socket, status, headers, body,
       socket.write(buf << "\r\n".freeze)
+      buf.clear
     if hijack

                 reply	other threads:[~2017-02-23 18:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170223180749.29081-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=unicorn-public@bogomips.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).