DEV Community

Discussion on: Memory management techniques to reduce memory consumption and improve performance.

Collapse
 
linehammer profile image
linehammer

A class without an object requires no space allocated to it. The memory allocation takes place only when you create objects because the objects is what implements the contents of the class. So to an object of an empty class, 1 byte is allocated by compiler, for it's unique address identification. If a class have multiple objects they can have different unique memory location. When you create new class, it will call an allocation function . This function can have different implementations. This depends on the object oriented programming language, the language version, libraries, and configuration.

net-informations.com/faq/oops/oops...

Collapse
 
pratheek87 profile image
pratheek87

Thanks @linehammer for your comment. The above post focuses more on how to optimize performance when you need to allocate memory for lots of objects over the entire time of the application usage.