unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] http_response: clear header buffer before response body iteration
@ 2017-02-23 18:07 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-02-23 18:07 UTC (permalink / raw)
  To: unicorn-public

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
stack.
---
 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,
         end
       end
       socket.write(buf << "\r\n".freeze)
+      buf.clear
     end
 
     if hijack
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-23 18:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 18:07 [PATCH] http_response: clear header buffer before response body iteration Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

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).