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.
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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...
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.