Question

We're currently having issues with memory leaks when using unit tests with Symfony 1.x to the magnitude of a decent number of tests eating 512MB of memory.

Currently we've tried:

  • Using a phpunit plugin
  • Using lime
  • Restricting the tests to a few sfPropelData loads + functional tests repeated a few times
  • Switching to PHP 5.3.3 to handle circular references
  • Inspecting memory usage xdebug which didn't give much insight

Soon we'll be trying:

  • Only the functional tests
  • Replacing sfPropelData instead loading plain SQL files
  • Only functional tests without any ORM calls
  • Valgrind?

I'm thinking maybe the static variables within symfony aren't getting cleaned up or the PDO layer is itself leaking memory. Of course, the last option is to figure out a way to run a suite of tests in its own process.

We're progressing through the areas it could be in and I don't expect anyone to actually help us work out the details but I'm just throwing this question out there to see if anyone has experienced this and where they found the leak to be or what they did to get around this.

Also, any input on other tools that can assist, like valgrind?

Was it helpful?

Solution

Only functional tests without any ORM calls

That is one that I always try to prevent: Use Mock-Objects instead of accessing the database.

What you can try is the new PHPUnit-Version that has process isolation of the tests (activated via additional command line parameter). That should help you. It is slower but helps with the memory problem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top