« HOME

Hint to avoid memory exhausted error (symfony + doctrine1.2)

By Nacho Martín on 01 September 2010

It is usual to have tasks that load a lot of objects from the database and do something with them. It can be generating a sitemap, generating thumbnails, etc.

When you do that, it is very likely that you find memory exhaustion problems like:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /blablabla/lib/vendor/symfony/lib/log/sfVarLogger.class.php on line 170

How to overcome this? Luckily I found this thread on the symfony group. If I had discovered that thread earlier it would have saved a lot of time, so I’m replicating the solution here :)

The problem is that the doctrine profiler is enabled for sfBaseTask, as sf_debug is set to true.

To disable the profiler, you have to create a new environment in config/databases.yml:

task:
  symfony:
      param:
        profiler: false

all:
  symfony:
    class: sfDoctrineDatabase
      param:
        dsn:   ....
        username:   ...
        password:   ...

And then run the task with the option --env=task

Written by @nacmartin

blog comments powered by Disqus

» ALL POSTS