Summary | Fatal error with very big strings conversion |
Queue | Horde Framework Packages |
Queue Version | FRAMEWORK_3 |
Type | Bug |
State | Resolved |
Priority | 2. Medium |
Owners | chuck (at) horde (dot) org |
Requester | admin (at) elektordi (dot) net |
Created | 04/28/2008 (6336 days ago) |
Due | |
Updated | 05/12/2008 (6322 days ago) |
Assigned | 04/29/2008 (6335 days ago) |
Resolved | 05/12/2008 (6322 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
Assigned to Chuck Hagenbuch
State ⇒ Resolved
for <= 16MB instead of just 1MB?
are available, then try utf8-en/de-code
Priority ⇒ 2. Medium
http://lists.horde.org/archives/cvs/Week-of-Mon-20080428/077940.html
convert a 117 bytes (with 1,000,000 iterations) from ASCII to UTF-8
takes:
utf8_encode time: 15 seconds
mb_convert_encoding time: 46 seconds
Howerver, mb_convert_encoding() is able to deal with larger strings.
Eg: 50% of max memory instead of %25 max memory.
State ⇒ Feedback
more efficient with memory and the same or faster for speed, we should
just use it first, period.
Patch ⇒ Yes
State ⇒ Unconfirmed
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ Fatal error with very big strings conversion
Type ⇒ Bug
Priority ⇒ 3. High
I got a problem today with a very big text mail (~4Mo) due to an
infinite loop in a log deamon. This causes my whole mailbox page to
crash with an PHP Fatal error:
PHP Fatal error: Allowed memory size of 33554432 bytes exhausted
(tried to allocate 16187725 bytes) in
/usr/share/horde3/lib/Horde/String.php on line 128
I managed to prevent the error with the following hack:
/* HACK by Elektordi 2008-04-28: Prevent crashs caused by
very big text mails */
if(strlen($input)>1048576 && String::extensionExists('mbstring')) {
return @mb_convert_encoding($input, $to, $from);
}
in file String.php and function _convertCharset, just before the line
/* Use utf8_[en|de]code() if possible. */
I did this because Mbstring seems to allocate much less memory than
utf8_xxcode functions. But a better test in the "if" is to check the
free memory instead of using the constant 1048576 (=1024*1024)
Hope this will help you!
Regards,
Elektordi