posted 13 years ago
Hi,
Can someone explain me what will happen when an Object is created or removed from memory at runtime?
Say for example, I just instantiated an Employee Object. Then what will happen in Memory?
Here I am putting my understanding on it.
First some memory will be reserved for the newly created Employee object in Heap memory, then initialize and store its defaults properties values, then a pointer to this memory location will be stored in Stack memory as a reference.
Suppose When an object is eligible for garbage collection and GC runs what is going to happen?
Will it remove the Object reference from Stack and clear the memory allocated on Heap?
If it cleans the Employee object from heap what exactly it will do on that memory location?
Can someone please explain whats really happening behind the scenes?
Thanks,
Siva