doubiantiao4994 2015-03-11 19:23
浏览 139

长时间运行的PHP脚本使httpd.exe使用大量内存

I've written a script that connects to a mail server to download all attachments and store them on a database.

Since the mailbox is very large, and the mail server is quite slow, it takes a few hours to complete.

After processing about 10.000 messages (message count is not exact and varies), the script dies with error: "PHP Fatal error: Out of memory (allocated 7077888) (tried to allocate 2815819 bytes)"

I've checked Task Manager and the memory usage of httpd.exe process gradually rises up to 1.5GB (after 1 and a half hours while the script is running), altough memory_get_usage() placed within the loop constantly reports something about 351.33kB, wich doesn't make me feel that there is a leak in my script. And even if there is a leak, how am I supposed to check it?

I'm running Apache/2.2.17 (Win32) with PHP/5.4.16 (SAPI) on Windows Server 2008 R2

My loop consists of reading email content with imap functions and storing attachment contents in database, one by one

I have switched to memory_get_usage(true), wich reported almost constantly 1.25MB

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料