Memory Validator can be used with Visual Basic.
Visual Basic uses the SysAllocString API family to allocate and deallocate BSTR objects (these represent strings).
Visual Basic also uses the VARIANT datatype and SafeArrays to manage data.
In addition COM objects (often written in C/C++) can also be used by Visual Basic. The COM objects may leak, and their implementation may suffer from the standard range of C++ memory leak and handle leak errors discussed in the other tutorials.
There is a three stage process to setup your Visual Basic application and Memory Validator to work together.
Each step is easy to do and is described below.
When working with Memory Validator it is important that your Visual Basic application produces debugging information so that you can determine which in function allocations occur.To do this open the Project Properties dialog by selecting the Properties option on the Project menu.
The Project Properties dialog is displayed.
Choose the Compile tab then select the Create Symbolic Debug Info check box to ensure debugging information will be generated.
The next thing to do is to create a standalone executable of your Visual Basic application.You can do this by using the Make YourAppName.exe… option on the Visual Basic File menu.
When your file has been built you will find the executable (YourAppName.exe) and its debugging file (YourAppName.pdb) in the directory you specified.
The next thing to do is to configure Memory Validator to detect the types of object that Visual Basic uses. Using the Configure menu, choose User Interface Mode. The user interface dialog is displayed. Choose Expert and click OK.
Display the data collection settings dialog by clicking on the toolbar icon shown below.
On the memory tab display settings dialog, select the check boxes shown below to enable the display of CRT memory, heap memory, COM memory (CoTaskMemAlloc), BSTR and SafeArray memory (SysAllocString), other SafeArray memory (Misc Allocations), COM object reference counts and handles.
On the collect tab, select the check boxes shown below to enable the collection of CRT memory, heap memory, COM memory (CoTaskMemAlloc), BSTR and SafeArray memory (SysAllocString), other SafeArray memory (Misc Allocations), COM object reference counts and handles from many different Win32 APIs.
Click OK to accept the settings.
Select YourAppName.exe using the Browse… button. The example above shows the e:\om\VBLeaks\VB\VBLeaks.exe application has been selected for testing.
Click the Go button.