How Memory Leaks Work with Memory Diagram CSCE 121
output identifier stack heap
output identifier stack heap int getANumber() { int* z = new int(15); return *z; } int main() { int* k = new int(3); k = new int (7); int w = getANumber(); w main k identifier stack heap
output identifier stack heap int getANumber() { int* z = new int(15); return *z; } int main() { int* k = new int(3); k = new int (7); int w = getANumber(); w main 3 k identifier stack heap
output identifier stack heap Memory Leak! int getANumber() { int* z = new int(15); return *z; } int main() { int* k = new int(3); k = new int (7); int w = getANumber(); 7 w main 3 Memory Leak! k identifier stack heap
output identifier stack heap Memory Leak! int getANumber() { int* z = new int(15); return *z; } int main() { int* k = new int(3); k = new int (7); int w = getANumber(); 15 getANumber z 7 w main 3 Memory Leak! k identifier stack heap
output identifier stack heap Memory Leak! Memory Leak! int getANumber() { int* z = new int(15); return *z; } int main() { int* k = new int(3); k = new int (7); int w = getANumber(); Memory Leak! 15 getANumber z 15 7 w 15 main 3 Memory Leak! k identifier stack heap