Does anyone have code to clear memory?

My program dies after a while of usage, i need to clear the memory after each process.... hrm...