BitOne / php-meminfo

PHP extension to get insight about memory usage
MIT License
1.08k stars 78 forks source link

Add static local variables to the dump #118

Open JonathanGawrych opened 3 years ago

JonathanGawrych commented 3 years ago

Hello! I have been using php-meminfo to find how my projects tests exhausting memory, and it's been great. Thank you!

However, I found that meminfo misses something: static local variables. Using https://github.com/johannes/php-staticvardumper as a resource (but is 8 years old and worked only on php 5, so I had to do some updates), I augmented php-meminfo to find and add static local variables to the dump. Please see the two test for examples.

I had to make a choice for the frame_label. I chose <STATIC_VARIABLE(ClassName::MethodName)>, and in the case that the function wasn't a method, but global, I chose <GLOBAL_FUNCTION> for the classname (resulting in <STATIC_VARIABLE(<GLOBAL_FUNCTION>::MethodName)>). A little wordy, but I think it conveys the meaning pretty well. These are easily changeable though if you prefer something else :)

Thanks again for the tool and let me know if you'd like anything changed.