| | |
Memory Leaks
![]() |
>Is there any way , memory leaks can be clogged in c/c++ ...
Knowledge and discipline. If you're aware of how memory leaks can come about in your project and apply a disciplined approach to avoid them, that's all you need.
>Are there any good tutorials on how can we make our code Memory Leak free ??/
Probably, but I don't know of any off hand.
Knowledge and discipline. If you're aware of how memory leaks can come about in your project and apply a disciplined approach to avoid them, that's all you need.
>Are there any good tutorials on how can we make our code Memory Leak free ??/
Probably, but I don't know of any off hand.
In case you were wondering, yes, I do hate you.
•
•
Join Date: Sep 2004
Posts: 89
Reputation:
Solved Threads: 1
Wel after googling for some time I came across this link
http://www.linuxjournal.com/article/6556
It stats using some tools you can prevent memory leaks.
Here is a C++ Memory Management tutorial.
http://www.mycplus.com/cplus.asp?CID=42
http://www.linuxjournal.com/article/6556
It stats using some tools you can prevent memory leaks.
Here is a C++ Memory Management tutorial.
http://www.mycplus.com/cplus.asp?CID=42
A lot depends on the program you are writing. Two hints:
1. Using c++ std container classes instead of C-style dynamically allocated objects is the first place to start -- assuming your compiler supports those container classes, not all c++ compilers do.
2. If you are writing Microsoft Windows programs you have to be careful about the system-wide resources that your program allocates, make sure the program frees/releases the resources before terminating.
1. Using c++ std container classes instead of C-style dynamically allocated objects is the first place to start -- assuming your compiler supports those container classes, not all c++ compilers do.
2. If you are writing Microsoft Windows programs you have to be careful about the system-wide resources that your program allocates, make sure the program frees/releases the resources before terminating.
You can also use smart-pointer technique.
C++ Syntax (Toggle Plain Text)
template <class T> class auto_ptr { private: T* ptr; public: explicit auto_ptr(T* p = 0) : ptr(p) {} ~auto_ptr() {delete ptr;} T& operator*() {return *ptr;} T* operator->() {return ptr;} };
Last edited by invisal; Aug 3rd, 2009 at 2:43 pm.
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Behind every smile is a tear.
Visal .In
![]() |
Similar Threads
- The definiton of "Memory leaks" (C++)
- Another question regarding memory (C)
- Dynamic memory allocation homework (C++)
Other Threads in the C++ Forum
- Previous Thread: [GDI+] - Drawing sequence of string in a rectangle
- Next Thread: Searching Array with struct and enum
Views: 1457 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
algorithm array arrays assignment beginner binary c++ c++borland c/c++ calculator char class classes code command compile compiler console constructor conversion convert count delete dll dynamic encryption error file files form forms fstream function functions game givemetehcodez graph gui homework iamthwee ifstream input int integer lazy linker list loop loops math matrix member memory network newbie number object objects opengl output parameter pointer pointers problem program programming project qt random read recursion recursive reference return search simple sort spoonfeeding string strings struct student studio system template templates text time tree variable vc++ vector video visual void win32 window windows winsock wxwidgets






