Why does my browser crash when I debug doctrine entities in Symfony2?

Using a var_dump of a doctrine object is a fast track to disaster in Symfony2. According to the Doctrine Website documentation:
Lazy load proxies always contain an instance of Doctrine’s EntityManager and all its dependencies. Therefore a var_dump() will possibly dump a very large recursive structure which is impossible to render and read. You have to use Doctrine\Common\Util\Debug::dump() to restrict the dumping to a human readable level. Additionally you should be aware that dumping the EntityManager to a Browser may take several minutes, and the Debug::dump() method just ignores any occurrences of it in Proxy instances.
src: http://www.doctrine-project.org/docs/orm/2.1/en/tutorials/getting-started-xml-edition.html

1 comment:

  1. Thought I was going insane... this crashed not only my browser but also my OS, for some reason allocating 3gb of memory over 15-ish seconds.

    Your answer was enormously helpful, thanks!