To trace the resource usage in your application, use AQTime’s Resource profiler. This profiler monitors the application’s execution and tracks how the entire application allocates and deallocates Windows resources (menus, bitmaps, pens, and so forth).
To see what resource instances exist in your application during its execution, obtain the profiling results during the profiler run. To see what resource instances still exist after the application run is over and find resource leaks, analyze the results obtained upon application termination.
Profiling results are organized into three categories: Classes Data, Objects and Errors. You can select the desired category in the Explorer panel.
Searching for Resource Leaks - Classes Data Category
-
Select the Classes Data category in the Explorer panel.
-
Examine the Report panel that lists all resource types whose instances were created during the application run. The resource type name is displayed in the Class Name column.
-
Examine the Live Count column that shows the number of resource instances that currently exist. If the value of this column is greater than zero, the given resource type has instances that had not been deallocated by the moment the results were generated.
-
Filter or sort results on the Live Count column to quickly find resource types whose instances were not deallocated.
-
View the Live Size column to learn the amount of memory occupied by these resource instances.
Searching for Resource Leaks - Objects Category
To find out which routine allocated a resource instance:
-
Select the Objects category in the Explorer panel.
-
Examine the Report panel that lists resource instances that were allocated and were not deallocated during the application run. Resource instance identifiers are displayed in the Object Name column.
-
Select the desired resource instance in the Report panel and switch to the Details panel (note that this page is empty if none of the stack areas is selected in the Collect Stack Information Pane).
-
The Creation Call Stack pane displays the stack of function calls that led to the resource instance creation. The topmost routine in the stack is the one that created the resource instance.
-
To view the source code of a routine, double-click the routine in the call stack. AQTime will bring up the Editor panel and position the cursor on the first line of the routine’s source code. Visual Studio will bring up the Code Editor’s page that contains the application’s source code and position the cursor on the first line of the routine’s source code. Embarcadero RAD Studio will bring up the Editor’s page that contains the application’s source code and position the cursor on the first line of the routine.
Note: If you profile a .NET application, in order for the Editor to show the application's source code, profile the application with debug information. See How AQTime Profilers Use Metadata and Debug Information
Analyzing Errors Occurring in Resource Management Functions
-
Select the Errors category in the Explorer panel.
-
Examine the Report panel that lists all the errors that occurred in the resource management functions, which the Resource profiler traces (see Resource Profiler - List of Checked Functions).
-
Examine the Description column to view the error description.
-
To view the MSDN topic about this routine, click the link in the Reference column.
-
To learn in which routine the given error occurred, take a look at the Name column.
See Also
Memory and Resource Allocation Profiling
Best Practices and How to Tutorials
Resource Profiler