[imp] IMP Memory usage
sotero at uolsinectis.com.ar
sotero at uolsinectis.com.ar
Fri Jan 14 08:06:56 PST 2005
Hi.
I have been doing some simple tests with IMP4. It's a great piece of
software and excellent functionality.
I'm setting it up to be used by several thousands of clients and although
it'll run in pretty big machines (a couple of Dual Xeon 2.8Ghz, 2Gb Ram,
SCSI RAID 6) I am evaluating some more of the cpu/memory intensive
caracteristics (compression, mime decode, text processing -Filter class-).
We allow our clients mails up to 13Mb each. Now, I tested IMP with a 8Mb
attachment and got:
(I started using a 20Mb limit)
PHP Fatal error: Allowed memory size of 20971520 bytes exhausted (tried
to allocate 10646241 bytes) in /usr/local/lib/php/Horde/MIME/Part.php on
line 306
and after moving to 50Mb limit:
PHP Fatal error: Allowed memory size of 50331648 bytes exhausted (tried
to allocate 10646241 bytes) in /usr/local/lib/php/Horde/MIME/Part.php on
line 1209
I think 10646241 is the sizes of the base 64 encoded attachment.
After a short following of the code, I found lot of memory copies. Don't
know if they´re unnecesary, but I took a chance and made some changes:
After this:
Index: lib/MIME/Contents.php
===================================================================
RCS file: /repository/imp/lib/MIME/Contents.php,v
retrieving revision 1.155
diff -u -b -r1.155 Contents.php
--- lib/MIME/Contents.php 7 Jan 2005 19:09:07 -0000 1.155
+++ lib/MIME/Contents.php 14 Jan 2005 15:28:03 -0000
@@ -155,15 +155,14 @@
*
* @return string The text of the part.
*/
- function getBodyPart($id)
+ function &getBodyPart($id)
{
- $contents = '';
if (!isset($this->_bodypart[$id])) {
$this->_bodypart[$id] =
@imap_fetchbody($GLOBALS['imp']['stream'], $this->_index, $id, FT_UID);
}
- return ($contents . $this->_bodypart[$id]);
+ return !empty($this->_bodypart[$id])?$this->_bodypart[$id]:'';
}
And
Index: Part.php
===================================================================
RCS file: /repository/framework/MIME/MIME/Part.php,v
retrieving revision 1.178
diff -u -b -r1.178 Part.php
--- Part.php 3 Jan 2005 13:09:09 -0000 1.178
+++ Part.php 14 Jan 2005 15:40:09 -0000
@@ -301,9 +301,9 @@
* @param string $contents The part body.
* @param optional string $encoding The current encoding of the
contents.
*/
- function setContents($contents, $encoding = null)
+ function setContents(&$contents, $encoding = null)
{
- $this->_contents = $contents;
+ $this->_contents = &$contents;
$this->_flags['contentsSet'] = true;
$this->_currentEncoding = (is_null($encoding)) ?
$this->getCurrentEncoding() : MIME::encoding($encoding, MIME_STRING);
}
@@ -382,7 +382,7 @@
*/
function transferDecodeContents()
{
- $contents = $this->transferDecode();
+ $contents = &$this->transferDecode();
$this->_currentEncoding = $this->_flags['lastTransferDecode'];
$this->setTransferEncoding($this->_currentEncoding);
@@ -1190,7 +1190,8 @@
*/
function transferDecode()
{
- $contents = $this->getContents();
+
+ $contents = &$this->getContents();
$encoding = $this->getCurrentEncoding();
/* If the contents are empty, return now. */
I was able to download the attachment with the same php.ini settings. Can
anyone see a problem with this?
--
Juan Germano
Ingeniería de Portal
UOLSinectis Argentina
More information about the imp
mailing list