Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.1

Request #17887 Patch to reduce peak memory usage in the data() function
Submitted: 2010-09-23 06:48 UTC
From: hloeung Assigned: jon
Status: Closed Package: Net_SMTP (version 1.4.2)
PHP Version: 5.3.3 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2010-09-23 06:48 UTC] hloeung (Haw Loeung)
Description: ------------ This patch reduces the peak memory usage by breaking up large data() into smaller blocks and running quotedata() on these smaller blocks. Test script: --------------- <?php require 'Net/SMTP.php'; $fh = fopen('20mbody.txt', 'r'); $body = fread($fh, filesize('20mbody.txt')); fclose($fh); if (! ($smtp = new Net_SMTP('mail.tpg.com.au'))) { die("Unable to instantiate Net_SMTP object\n"); } $smtp->connect(); $smtp->mailFrom('hawl@tpg.com.au'); $smtp->rcptTo('hawl@tpg.com.au'); echo 'file=' . substr(__FILE__, strrpos(__FILE__, '/') + 1) . '; line=' . __LINE__ . '; mem_used=' . memory_get_usage(0) . ' [' . memory_get_usage(1) . ']; peak_mem=' . memory_get_peak_usage(0) . ' [' . memory_get_peak_usage(1) . "]\n"; $smtp->data($body, 'Test message'); echo 'file=' . substr(__FILE__, strrpos(__FILE__, '/') + 1) . '; line=' . __LINE__ . '; mem_used=' . memory_get_usage(0) . ' [' . memory_get_usage(1) . ']; peak_mem=' . memory_get_peak_usage(0) . ' [' . memory_get_peak_usage(1) . "]\n"; $smtp->disconnect(); ?> Expected result: ---------------- file=test.php; line=15; mem_used=23665104 [23855104]; peak_mem=23675304 [23855104] file=test.php; line=17; mem_used=23665152 [23855104]; peak_mem=26745888 [27000832] Actual result: -------------- file=test.php; line=14; mem_used=23661688 [23855104]; peak_mem=23671888 [23855104] file=test.php; line=16; mem_used=23661736 [23855104]; peak_mem=158207704 [159121408]

Comments

 [2010-09-23 06:49 UTC] hloeung (Haw Loeung)
 [2010-09-28 09:02 UTC] jon (Jon Parise)
-Status: Open +Status: Closed -Assigned To: +Assigned To: jon
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Thanks for the suggestion!