![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Getting size in memory of an object in PHP?
The memory_get_usage() function can be caked before and after allocating memory to the class created.
class MyBigClass { var $allocatedSize; var $allMyOtherStuff; } function AllocateMyBigClass() { $before = memory_get_usage(); $ret = new MyBigClass; $after = memory_get_usage(); $ret->allocatedSize = ($after - $before); return $ret; }
Output will be the memory of object with respect to the environment setup.
Advertisements