Page 1 of 1
Memory limit :(
Posted: Thu Apr 09, 2009 10:56 am
by saiaman
I've got this problem while working with swift
PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 35 bytes) in ****************/include/Swift/classes/Swift/CharacterStream/ArrayCharacterStream.php on line 267
Can anybody help ???
Thank you
Re: Memory limit :(
Posted: Thu Apr 09, 2009 8:39 pm
by Chris Corbyn
Please can you post your code? How many emails are you trying to send too? And lastly, how big are the emails?
Re: Memory limit :(
Posted: Fri Apr 10, 2009 3:36 am
by saiaman
The fact is that i can't post the code ... but i can explain what i'm doing maybe you'll find out the issue :
in a script i unserialize data issue from a file containing : 1 swift message and 1 PHP array providing the list of emails.
Then i pass this parameters to a multithread daemon.
In this daemon there are two main methods : getNext and run
_construct:
Code: Select all
$this->message=$message;
unset($message);
$this->list = $list;
unset($list);
$this->total = count($this->list);
foreach($this->tabServers as $ip){
$this->transports[] = new Swift_Mailer(new Swift_SmtpTransport($ip,25));
}
getNext :
pops the last element from the array providing the email adresse to target
run:
this methods is launched in a child process
Code: Select all
$t = $slot%count($this->tabServers);
$mailer = &$this->transports[$t];
$this->message->getHeaders()->addTextHeader("X-******",$next);
$mailer->registerPlugin(new Swift_Plugins_DecoratorPlugin(new GibReplacements()));
$this->message->setTo($next);
$mailer->send($this->message);
Re: Memory limit :(
Posted: Fri Apr 10, 2009 3:54 am
by saiaman
The creation of the swift message consumes a lot of memory :
Code: Select all
2009-04-10 10:46:31 [3406] INFO : Memory USAGE 499764
2009-04-10 10:46:31 [3406] INFO : Initialisation of message
2009-04-10 10:46:31 [3406] INFO : Memory USAGE 1693656
Re: Memory limit :(
Posted: Fri Apr 10, 2009 11:17 am
by Chris Corbyn
Yeah Swift uses around 2MB. That's a lot less than your memory limit though (~100MB).
I'm not clear on where you're calling registerPlugin(). Are you registering a plugin for every single message sent? Also, which version of the library do you have? Is it version 4.0.3 or an earlier variant of version 4?
Re: Memory limit :(
Posted: Mon Apr 20, 2009 3:52 am
by saiaman
Yes the plugin was registered in each child process. So for each mail. But this has been modified.
I was using version 4.0.3 of swift.
But this memory problem seems to appear while building the message ( encoding ? ) before sending.
Re: Memory limit :(
Posted: Mon May 18, 2009 7:09 am
by DarkRaver
Hi all,
Is there a solution/workaround out there to the memory limit problem ?
I face this problem and can't push the memory limit too high ! (already 128M)
It looks like the problem is related to the CharacterStream and/or the ByteStream and/or UTF8 stuff that seems to be java classes ported to php.
Can we tell/configure Swift not to use these classes when we're sure to have both the scripts and the data being part of the message already utf8 encoded ?
What is the benefit of having all that classes encoding data in utf8 when everything is allready utf8 encoded ?
We (I and my company) are completely stuck with Swift crashing with memory exhausted messages as soon as the messages are more than a (very) few megabytes long.
PS : we don't use any plugin at the moment so I'm quite sure they're not the origin of the problem.
Sorry for my bad english, and hoping in a response soon.
Thanks
Re: Memory limit :(
Posted: Mon May 18, 2009 10:42 am
by Benjamin
Please post your code. In order for Chris to spend time to diagnose this issue we need to verify that the problem lies in Swfitmailer, and not your code.