fmbiete / Z-Push-contrib

Z-Push fork with changes that I will try to contrib
GNU Affero General Public License v3.0
134 stars 62 forks source link

Memory error #194

Open m-emelchenkov opened 9 years ago

m-emelchenkov commented 9 years ago

Z-Push crashes when processing IMAP mail.

2015/05/31 11:55:00 [error] 15634#0: *2412 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 201326592 bytes exhausted (tried to allocate 20257532 bytes) in /usr/local/share/z-push-contrib/include/mimeDecode.php on line 811" while reading response header from upstream, client: x.x.x.x, server: xxx.xxx, request: "POST /Microsoft-Server-ActiveSync?User=xxx@xxx&DeviceId=XXX&DeviceType=iPhone&Cmd=Sync HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xxx.xxx"

fmbiete commented 9 years ago

You must change a setting in your php.ini

memory_limit = 256M

Or bigger, the limit depends upon you maximum message size.

m-emelchenkov commented 9 years ago

I can't afford 256+ MB on this server, limit is set to 192M. However, it's strange because I don't have super-large messages and after all I installed "docker" branch and it works well for me (only backported one function from "master" to fix one error).

Can we re-write iconv-related code to parse message in chunks or somehow this way (in fact, I did not compared these two branches, just use "docker" now)?

fmbiete commented 9 years ago

docker branch is obsolete, use it with care. If you cannot afford to set more memory, and you are using php-fp; configure it so the workers will be restart after a few operations. So you won't lose any memory.

Also if you can program php you can searh for any memory leaks, I'm sure there are a few... :wink:

m-emelchenkov commented 9 years ago

Restarting workers is a great idea, thanks for this tip, maybe it will help. If don't — then I'll try to find the root of problem, sometime. Yes, I program in PHP, I even tried to re-write this part for chunk processing but with no big success, the result was the same — it seems somewhere a memory leak which need to be profiled.

PS: You are doing a great work!