Make use of Visual C++ runtime memory leak tracing

These changes ask Visual C++ runtime to track all memory allocations and then dump all memory leaks when the program is exiting. The changes are conditionally compiled only when the compilation is being done with Visual C++ and the current configuration is "debug".