dtm37893 2012-04-18 14:38
浏览 100
已采纳

Doctrine中允许的内存大小耗尽

I use symfony 1.4 (from a task) and Doctrine 1.2 to import data from a lot of files.

It works well, but after a few minutes I get an "Allowed memory size exhausted" fatal error from PHP, not in my code but in Doctrine…

Call Stack:
    0.0004     325216   1. {main}() C:\wamp\www\XPower\symfony:0
    0.0125     587704   2. include('C:\wamp\www\XPower\lib\vendor\symfony\lib\command\cli.php') C:\wamp\www\XPower\symfony:14
    1.9202    6981872   3. sfSymfonyCommandApplication->run() C:\wamp\www\XPower\lib\vendor\symfony\lib\command\cli.php:20
    1.9233    6983528   4. sfTask->runFromCLI() C:\wamp\www\XPower\lib\vendor\symfony\lib\command\sfSymfonyCommandApplication.class.php:76
    1.9234    6983688   5. sfBaseTask->doRun() C:\wamp\www\XPower\lib\vendor\symfony\lib\task\sfTask.class.php:97
    3.0794    7047088   6. dataImportTask->execute() C:\wamp\www\XPower\lib\vendor\symfony\lib\task\sfBaseTask.class.php:68
    3.2731    8663752   7. dataImportTask->traiterDossier() C:\wamp\www\XPower\lib\task\dataImportTask.class.php:36
    7.7762   17906824   8. dataImportTask->traiterDossier() C:\wamp\www\XPower\lib\task\dataImportTask.class.php:55
  264.4390  133557080   9. xPower::importerXml() C:\wamp\www\XPower\lib\task\dataImportTask.class.php:64
  264.5919  133609328  10. xPower::importerFichierXml() C:\wamp\www\XPower\lib\XPower.class.php:312
  265.4313  134048568  11. InverterTable->findOneBySerialNumber() C:\wamp\www\XPower\lib\XPower.class.php:445
  265.4313  134048776  12. Doctrine_Table->__call() C:\wamp\www\XPower\lib\XPower.class.php:445

i've tried adding some "->free()" to Doctrine calls, but now it seems to fail on InverterTable->findOneBySerialNumber(), a "magic" Doctrine method.

How can I fix my problem ? Do I need to write my own "findOneBySerialNumber" method, adding a call to "free()" ?

  • 写回答

1条回答 默认 最新

  • douren5898 2012-04-18 14:46
    关注

    It's such a common problem with doctrine. You have to use pcntl_fork.

    I always use this gist as an example.

    pcntl_fork doesn't work on Windows because it requires an OS that follows the POSIX standards.

    It might also be enought to just help doctrine free objects its objects, here's a great answer about that.

    If you got some The MySQL server has gone away:

    When using Doctrine and MySQL, it might be necessary to add the following of the child thread code:

    Doctrine_Manager::connection()->close();
    

    This will close the database connection, and Doctrine will automatically recreate it at the first query.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?