Question:
Restarting fixes memory Leak?
2010-01-26 17:48:12 UTC
I am making simple programs in Microsoft Express 2008 C++, just for a Computer class. I am using 'new' a lot and just in case I do make a memory leak, what can I do to get rid of it. Will restarting my computer fix the problem or should I use Windows memory fixer or some other program?
Three answers:
tbshmkr
2010-01-26 18:02:23 UTC
Use 'delete'

=

http://www.cplusplus.com/doc/tutorial/dynamic/

-

The necessity of dynamic memory is usually limited to specific moments within a program, once it is no longer needed it should be freed so that the memory becomes available again for other requests of dynamic memory.

-

delete pointer; == used to delete memory allocated for a single element

delete [] pointer; == used to delete memory allocated for arrays of elements.
2016-05-26 19:22:52 UTC
When the computer restarts you USUALLY get the memory back. But for example as an artist I will sometimes spend forty hours + working on a project. I can't spare the memory for forty-plus hours, which is why i don't use Windows -- a leaky OS.
?
2010-01-26 17:58:05 UTC
delete whatever you allocate :). Clean your own mess or Windows will clean it up once your process is killed a restart is not required.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...