Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following program (which is the original program cut-and-paste from the lect

ID: 3823231 • Letter: T

Question

The following program (which is the original program cut-and-paste from the lecture notes) has been presented and studied during the lectures. Let us assume that the program is running on a machine with a 32-bit CPU, running Ubuntu Linux 14.04. When the program is running, there are exactly 2GB of free memory left in the system. But, there is no swap space enabled. This program will eventually stop. But, why? Please explain. The last line of output is always: "Allocated 3055MB" (or a number which is close to 3055).

Explanation / Answer

the program will stop because the dynamic allocation of the varaible is occuring that variable is not available for the garbage collection and hence once the memory is full the program wll not run.

the condition of the while loop is lways true and the program will never terminate.