Dynamic massive

Feb 14, 2015 at 7:30pm
What if after this
int *p=new int[7];
I forget to write delete[] p;
Will it harm my computer after a while, or will it delete itself after a while?

Feb 14, 2015 at 7:32pm
It causes memory leaks, which, to my understanding are released after the program ends, but it is very bad as it causes unnecessary stress on the computer program execution as it is holding onto variables you don't even need anymore.
Feb 14, 2015 at 7:34pm
It's similar to handing a stranger your new born baby, and telling him you'll be right back to pick it up, but you run away and never look back.
Feb 14, 2015 at 7:41pm
i.e. computer has to make an effort to remove that memory?
Feb 14, 2015 at 7:43pm
At the end of your program, all that memory will be released, so yes the computer WILL take care of it, but if you have a very long program, and a lot of memory leaks, you are essentially making it do extra work for nothing.
Feb 14, 2015 at 7:45pm
Thank you
Topic archived. No new replies allowed.