Olle Härstedt Olle Härstedt - 2 months ago 14
PHP Question

Stacktrace in TYPO3

I tried to get a stack-trace with

debug_backtrace()
from a controller in Extbase, TYPO3, but got memory overflow at 512M script limit. I could of course increase this limit, but why is so much memory required? And is there another way to get a stack-trace in TYPO3?

Answer

but why is so much memory required?

That depends on the logic of your controller. One thing that comes to my mind is the property mapper feature of Extbase.

/*
 * $var Model $model
 */
public function showAction(Model $model) {…}

In this case you most likely have the uid of that model given as a url param but Extbase will resolve the actual model. Depending on how many references your model has to other models, the property mapper needs a decent mount of cpu time and memory.

This however is just the most common issue I can now imagine. I bet there are many more reasons why your stacktrace could need so much memory.

And is there another way to get a stack-trace in TYPO3?

Well, that depends on when and how you need it. In general I recommend using xdebug for debugging php applications, thus you don't need the stacktrace in the form you get it from that mentioned function.

If you need to export the stacktrace, there's also the profiling function of xdebug, that will generate a cachegrind compatible file. This file can be used with KCacheGrind, QCacheGrind and even directly on PhpStorm. I guess there are more ways and programs to deal with stacktraces but these are the ones I regularly use and which have been proven to be rock solid and you avoid running out of memory.

Comments