Interviews2 answers
How Memory is allocated for objects on the Managed Heap?
2 Answers
It uses the pointer to the next available space on the heap to determine where to store your object
It advances the next available free space pointer, based on the size of your object
It zeroes out memory for the new object
It passes back a pointer to the new object, which is then stored in the reference-typed variable that refers to your object
The object’s constructor executes, to initialize data members within the object
Subhashkumar YadavPosted Jan 16, 2017, 2:08 AM EST
When your applications starts up, the Garbage Collector (GC) allocates some virtual memory to use as a managed heap It creates a pointer to the next available free space in the managed heap, which defaults to point to the beginning of the (empty) heap.
When you use the new operator to create a new reference-typed object, the Garbage Collector allocates space on the managed heap for your object as follows:
- It uses the pointer to the next available space on the heap to determine where to store your object
- It advances the next available free space pointer, based on the size of your object
- It zeroes out memory for the new object
- It passes back a pointer to the new object, which is then stored in the reference-typed variable that refers to your object
- The object's constructor executes, to initialize data members within the object
Santosh KumarPosted Oct 5, 2013, 8:23 AM EDT

