For my CompSci exam, I am required to identify and fix errors when using Dynamic Memory. Specifically I need to know understand Memory Leaks, Dangling References, and Aliasing.
Since I'm taking a make-up, all the course material has been taken off our course management system, and I'm just using the internet as my only source.
From what I understand, a memory leak occurs when you dynamically allocate memory, but you can't delete and re-allocate the memory.
1 2 3 4 5
|
void someFunction(){
int x = 5;
int *ptr = new int;
ptr = &x;
}
|
In this case nothing is pointing to the dynamically memory and a memory leak occurs, right?
I'm not sure what the other two terms are, I have a feeling that they are specific types of memory leaks? I need to be able to identify them, and fix them .
Any help on this would be greatly appreciated.
Thanks!
EDIT: Also, any links to tutorials on linked lists would be extremely helpful.