1

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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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?

1 Comment

Try Webgrind (or if you are on a linux machine try kcachegrind).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.