Hi,
do it as shoorik wrote.
If the problem still exists after code revision, you can use a Profiler like the one from AMD (Code Analyst) to search the bottle neck.
For memory leak detection you can use several libraries, search the web or ...
Visual Leak DetectorLeakfinderGreetz
Greenhorn