A memory leak is something new. Without delete, we can: the person who creates the dynamic object uses new to create the object, and the person who uses the object is responsible for freeing the memory block.
For example: I share a message queue with others, others put the message (new out of the object) in the message queue, he is not responsible for the release; I get a message from the message queue and once I get a message out of the message queue, there is no longer a message in the message queue, the control and the full power of the message are in my hands I should delete when I'm done with it. This ensures that the code is written in a simple way, only to be able to respect the week of the simple method to ensure that no memory leaks.
Another example: Ace, there is a ace_message_block, just see a variety of new, but did not see the delete, at that time to see the demonstration of the sample swelling is considered depressed, so he carefully delete, get the last few times repeatedly delete also put the program to hang up. Nima. It was just knowing that the tutorial was going to be released using the release method, and now the feeling should be understood. Because Ace_message_black uses the message count, it frees up memory with its own member method release method.
The above is just a sample of Message Queuing, and some scenarios are less typical. For example, it is possible for you to create your own use, release yourself, but just think about this principle, you can very easy from the business to find out when to release.
There's a Linux tool that can test your program for no memory leaks:Linux C + + memory leak Detection Tool and usage
Effective prevention methods for C + + memory leaks: Who uses, who deletes (1.2)