See what this course is all about. You start off by seeing the demo application that we will be profiling and optimizing. This application called BlendBitmaps is executed and multiple images are blended together with a single train station image. You will see how the images overlap so that a train station is always in the background. After seeing the app in action, you are shown glimpses of what it looks like inside WPA (The WIndows Performance Analyzer) and then you are shown the new and improved version which does not crash. You are shown the inner workings and the dramatic difference in memory usage. Here you get an idea of the course from beginning to end by previeing snap shots of course material.
- [Narrator] To illustrate a memory leak, we'll use an application that wants to read all of the pictures in a single Windows directory, but before it reaches the last picture, it crashes. We will look at an OpenCV Application. OpenCV is an open-source computer vision library created by Intel. The library allows for powerful image analysis and manipulation using advanced algorithms. Even though the demo application will we focus is written using OpenCV, the techniques you will learn here can be applied to any application. So, how can we determine if an application is crashing due to memory leaks? Well, the Windows Performance Tool Kit contains two tools that work hand in hand to provide the full picture of how an application is allocating memory, and how it manages memory in general.
The first tool we will look at is the Windows Performance Recorder. This tool captures system events which is basically the interaction of programs and hardware. It generates trace files that we can then inspect using the Windows Performance Analyzer. The Windows Performance Analyzer presents the raw system events into organized, useful tables that can be visualized with graphs. This tool will show us how an application manages it's memory resources, how it allocates memory, and how it releases memory. We'll look at the source code of the OpenCV application that takes two bitmap images at a time and blends them together.
It does this repeatedly for hundreds of images until the machine crashes due to no more memory being available. Having access to the source code for this application will make it easier for certain connections to be made when we perform memory analysis of the app in the Windows Performance Analyzer. We will see how the OpenCV application allocates memory using the Windows Performance Analyzer, and how the memory the application is using continues to grow. We will then make a connection of what we see in the graphs to what functions the application is calling by performing a technique called Callstack walking and Black Boxing.
Using these techniques, we can find the root cause of where the application is failing to release memory that is no longer being used. As it is right now, the application continuously allocates memory. By the end, will we see the improvements in memory resource management after we optimize the OpenCV application to properly release memory that is no longer being used whereas before, the memory usage was continuously growing, but now it remains around a constant value. That's a lot of free memory that can be used elsewhere, but more importantly, the application will no longer unexpectedly crash.
- Setting up the application
- Looking at the source code
- Gathering memory leak evidence
- Optimizing the application