views:

248

answers:

2

I have a really simple PHP script here,which simply loads several libraries (6 or 7 small classes) and initialize some variables then generate a very small amount of html code. But seeing from the memory_get_usage() function, I see 1.21MB memory usage.

Is that normal or something is wrong?

+1  A: 

Depends on the libraries. All it takes is one snippet of code to load up your memory. Have you tried to run a code profiler?

Stephane Grenier
Any profiler can show the memory usage?
Shawn
Try Webgrind (or if you are on a linux machine try kcachegrind).
gaoshan88
+1  A: 

If you want to see what is actually loaded up when you execute PHP use this: get_defined_vars

The reason PHP is consuming memory may not be your script at all but rather your PHP configuration and other extensions being loaded when php executes.

Syntax