From 195c40c82e77c73e171f75529b80c7561565d512 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Jan 2020 06:28:16 +0000 Subject: www: discard multipart parent on iteration We're often iterating through messages while writing to another buffer in our WWW interface, causing memory usage to multiply. Since we know we won't need to keep the MIME object around in some cases, and can tell msg_iter to clobber the on-stack variable while it operates on subparts of multipart messages. With xt/mem-msgview.t switched to multipart from the previous commit, this shows a 13 MB memory reduction on that test. --- lib/PublicInbox/WwwAttach.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/PublicInbox/WwwAttach.pm') diff --git a/lib/PublicInbox/WwwAttach.pm b/lib/PublicInbox/WwwAttach.pm index cda1c6c8..92f47e49 100644 --- a/lib/PublicInbox/WwwAttach.pm +++ b/lib/PublicInbox/WwwAttach.pm @@ -40,7 +40,7 @@ sub get_attach ($$$) { my $mime = $ctx->{-inbox}->msg_by_mid($ctx->{mid}) or return $res; $mime = PublicInbox::MIME->new($mime); $res->[3] = $idx; - msg_iter($mime, \&get_attach_i, $res); + msg_iter($mime, \&get_attach_i, $res, 1); pop @$res; # cleanup before letting PSGI server see it $res } -- cgit v1.2.3-24-ge0c7