A class is composed normally of member variables & methods. When we create instance of a class, memory is allocated for member variables of a class. Does member methods also occupy memory? Where are these methods stored?
A class is composed normally of member variables & methods. When we create instance
Share
Say we have the following class:
The
SayName()function goes on theCall Stack, and thePerson pobject and it’s properties (Name) will stay in memory until theGarbage Collectioncomes in and cleans it up.In terms of memory, you should be more concerned with the instance fields (properties) of the object, the amount of objects you are dealing with, and if your object is some time of
ReaderorConnection. If your object is aReaderorConnectionyou need to consider ausingstatement.Pseudo-code: