- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Tracking Memory Usage in PHP
The memory_get_usage function can be used to track the memory usage. The ‘malloc’ function is not used for every block required, instead a big chunk of system memory is allocated and the environment variable is changed and managed internally.
The two different types of memory usages are −
- The memory required by the engine from OS (the real usage)
- The amount of memory that was actually used by the application (internal usage)
The above mentioned memory usage can be tracked using memory_get_usage(). This function returns both real and actual memory used depending on our requirement.
For example: if we are looking at specific code snippets, internal memory might be relevant. On the other hand, if memory usage is being globally tracked, the real usage would be more relevant.
Advertisements