Question: . Suppose we have a language using the reference model (ie all variables are references, there is no explicit dereference operator). Memory is freed by

 . Suppose we have a language using the reference model (ie

all variables are references, there is no explicit dereference operator). Memory is

. Suppose we have a language using the reference model (ie all variables are references, there is no explicit dereference operator). Memory is freed by a reference-counting garbage collector Consider the following program. State which stack and heap variables point to which objects after the execution of each line of the program and what the values of the reference counters of each object are (you can show only the information that changed during the execution of the line) Which objects can be garbage-collected after the execution of the last line? type C - ...; type D-record [c f; ...; c cl-new C; C c2 ; D di -new D; D d2-new D; % ol is allocated (and cl initialized to point to ol) % (e2 is initialized to null) % o2 is allocated % o3 is allocated (and d1 initialized to point to o2) % o4 is allocated d1.f . new C; d2.f ci; c1 - d1.f; c2 -cl d2 - d1; . Suppose we have a language using the reference model (ie all variables are references, there is no explicit dereference operator). Memory is freed by a reference-counting garbage collector Consider the following program. State which stack and heap variables point to which objects after the execution of each line of the program and what the values of the reference counters of each object are (you can show only the information that changed during the execution of the line) Which objects can be garbage-collected after the execution of the last line? type C - ...; type D-record [c f; ...; c cl-new C; C c2 ; D di -new D; D d2-new D; % ol is allocated (and cl initialized to point to ol) % (e2 is initialized to null) % o2 is allocated % o3 is allocated (and d1 initialized to point to o2) % o4 is allocated d1.f . new C; d2.f ci; c1 - d1.f; c2 -cl d2 - d1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!