An NVIDIA interviewer asked a candidate to reason through the following C program without running it.
#include <stdio.h>
#include <stdlib.h>
int main() {
while (1) {
char *m = malloc(100);
if (m == NULL) {
printf("Unable to allocate memory
");
}
}
return 0;
}
Walk through what this program actually does: what (if anything) it prints, when it stops, what memory gets allocated as it runs, and how malloc is actually servicing each of these requests under the hood, distinguishing virtual memory from physical memory.
Implement analyze_malloc_loop(source), returning a structured explanation of the program's behavior. The input is the C source as a string, and the output is a dictionary with six required string fields.
source is a string containing the C program shown in the prompt.def analyze_malloc_loop(source):