xdebug snippets

How to debug memory allocation problems in PHP with Xdebug

Tagged xdebug, php, memory, error, performance  Languages php

Xdebug is a good tool for finding the root cause of memory allocation problems such as the one shown here:

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate X bytes)

First install Xdebug by following the Xdebug installation instructions.

Next surround the code you suspect is causing the problem with the following function calls:

xdebug_start_trace('/tmp/mytrace');
...
Bad bad PHP code
...
xdebug_stop_trace();

Read this blog entry by splitbrain.org for more details