One strength of the C programming language is its ability to give the developer low level control to optimize code. Because the C language provides direct access to application memory and hardware-specific function calls, developers often have a greater ability to control program size and execution speed.
But with the power and flexibility of C, comes the additional complexity of memory management as shown by the many academic books discussing the topic. One book mentioned that:
The overwhelming majority of "bugs" and crashes stem from problems of memory access, allocation, or deallocation. Such memory related errors are notoriously difficult to resolve … Most professional programmers learn about it entirely through actual experience of the problems it causes.
Instead of developers identifying memory leaks once their applications are deployed, LabWindows/CVI 9.0 now provide a tool, the Resource Tracking Window, to allow developers to identify and fix memory leaks earlier in the development process.
For over a decade, LabWindows/CVI has provided automatic array bounds checking to catch memory errors that can cause unexpected behavior. Building upon the history of delivering advanced user protection features not commonly available in C. LabWindows/CVI now includes an integrated tool to locate potential resource leaks that can decrease system performance over time.
The new Resource Tracking Window (available in LabWindows/CVI Full Development System and Developer Suite) records and tracks all resources allocated at runtime including dynamic memory, file handles, panels, GPIB/TCP handles, and thread pools. The tool also allows you to easily go to source code, view memory, break on deallocation and log tracked resources to disk for later review.
Select Extended in the Debugging Options section of the Build Options dialog box to enable interactive resource tracking. You also can enable and disable resource tracking programmatically using the GetEnableResourceTracking and SetEnableResourceTracking functions located in the Utility Library.
The Resources column of the Resource Tracking window displays both allocated and deallocated resources that you allocate in your program. LabWindows/CVI displays newly allocated resources in red text, existing allocated resources in black text, and recently released resources in grey text. The resources are also grouped in categories according to type; for example, memory, toolbox, user interface resources, and so on. Double-click a resource in the Resources column to go directly to the location in the source code where the resource was allocated. The Stack Trace section of the Resource Tracking window shows the call stack of functions when the resource was allocated, displaying the most recently called function at the top of the list and the initial function at the bottom of the list.
Resource tracking is available at both the extended and standard debugging levels. Selecting Extended in the Debugging Options section of the Build Options dialog box enables resource tracking by default. If you select Standard, you must use the SetEnableResourceTracking function to enable resource tracking.
To view the Resource Tracking window, select Window»Resource Tracking in the active LabWindows/CVI window. Right-clicking in the Resources column of the Resource Tracking window displays the context menu with the following options:
Right-clicking in the Stack Trace section of the Resource Tracking window displays the context menu with the following options:
Right-clicking on the tab of the Resource Tracking window displays the context menu with the following options:
Because tracking resources creates additional overhead, enabling resource tracking affects the performance of your program.
The mark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the United States and other countries.