| | |
The definiton of "Memory leaks"
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
A memory leak is simply allocating memory and failing to release it when you're done. Technically, the following illustrates a memory leak:
In practice, the operating system will typically reclaim all memory allocated to a process when the process terminates, but that's not required by the language definition. However, long running programs can consume all fast memory and grind the program to a near halt, or crash the system if virtual memory is also exhausted. So any call to new must be paired with a call to delete:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { int *p = new int; *p = 10; cout<< *p << endl; }
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { int *p = new int; *p = 10; cout<< *p << endl; delete p; }
I'm here to prove you wrong.
![]() |
Similar Threads
- Windows 2000 "memory has changed" error at start up (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Is there an array[x][y][z] in C++ (i.e TRIPLE ARRAY)???
- Next Thread: OOp memory leak error
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






