I have yet to find an elegant solution for this. I have a class with a method I want to track the memory usage of without modifying the function:
class Example {
You should use a php memory tool.
There is a nice one to be found in this SO thread: Tools to visually analyze memory usage of a PHP app
this other question holds some further answers regarding your question