Coforge interview question

How can you prevent memory leaks? Questions were based on concepts involving dbms,oop,resume based,basic data structures