about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwAttach.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-11 06:28:16 +0000
committerEric Wong <e@yhbt.net>2020-01-12 21:26:42 +0000
commit195c40c82e77c73e171f75529b80c7561565d512 (patch)
tree738c85840311d34629ae46bbc3ceb4cd9e5d8095 /lib/PublicInbox/WwwAttach.pm
parent80e819ceebf922ecda684cc8ef0848ddc709a73c (diff)
downloadpublic-inbox-195c40c82e77c73e171f75529b80c7561565d512.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/WwwAttach.pm')
-rw-r--r--lib/PublicInbox/WwwAttach.pm2
1 files changed, 1 insertions, 1 deletions
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
 }