WordPress variables and memory

Your installation might be … less than optimal.

Using my Mini Theme, no plugins and the following code on the front page right after the opening body tag …

print count( $GLOBALS ) . ' $GLOBALS<br>';
print @count( get_defined_vars(), 1 ) . ' variables<br>';
print count( get_defined_constants( TRUE )['user'] ) . ' constants';

… I get:

 158 $GLOBALS
9759 variables
  85 constants

Still too much for my taste. Keep in mind many plugin and theme developers forget to keep the global namespace clean. Depending on the quality of the addons you have installed your results might be much higher.

And yes, you need those rewrite rules. Some slugs are translated, and translation can change on each request. So they have to be always available.

Leave a Comment