| | |
Memory Leaks
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
>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.
New members chased away this month: 5
•
•
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 3: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: 1360 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






