A memory leak is the effect of running out of memory.
A memory leak is what happens when you forget to free a block of memory allocated with the new operator or when you make it impossible to so.
The measures you can take are :
Delete before reallocating a memory
Be sure you have a pointer to each dynamic variable so that you do not lose a location that you need to free.
Avoid these combinations : malloc() - delete and new - free()
Avoid these combinations : new - delete [] and new [] - delete.
Delete before reallocating a memory
Be sure you have a pointer to each dynamic variable so that you do not lose a location that you need to free.
Avoid these combinations : malloc() - delete and new - free()
Avoid these combinations : new - delete [] and new [] - delete.

0 Comments:
Post a Comment