Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Does anybody know a source that lists, succinctly, every possible cause of memory leaks?

So far I know this:

1. Call new without calling delete
2. Re-assign a new value to a pointer that already had a new obj
2. Have a base class without a virtual destructor
3. Have a cyclic reference with smart pointers

What else? Feel free to edit my wording and make this list better. Thanks.
Posted

1 solution

That's really about it. You leak when you 'lose' a reference to memory without cleaning it up. So, setting a pointer to null, without deleting the object, is a memory leak. Creating an object in the scope of the method and not cleaning it up, is a memory leak, because the value is lost when it goes out of scope. In all cases, you leak because you allocated memory and you lose the ability to clean it up when it is no longer needed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900