Free The Memory That You Use

This tip submitted by Udhaya Kumar.D on 2005-09-07 02:09:27. It has been viewed 52031 times.
Rating of 6.2 with 217 votes

Clean up memory spaces that are no longer used.

function_t(int val)
char *msg = new char[30];

if(val == VALID)
//do processing....
//don't just return.clean the memory that was alloted.
delete [] msg;
return false;

More tips

Help your fellow programmers! Add a tip!