Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

NI Controls GDI resource problems

In our application we use Measurement Studio Controls such as: CWGraph, CWKnobe, etc.
They are created in design time on a dialog template. These dialogs in turn are created dynamically
from code. There can be several of such dialogs created in one process.

We have two observations (problems) that turned up while debugging our application.
The problem conserns the Win32 GDI resources.

We have used the following debugging tools provided by Microsoft:
http://msdn.microsoft.com/msdnmag/issues/03/01/GDILeaks/default.aspx

Windows XP Professional PL, Visual Studio C++ 6.0 (MFC)

1. We have noticed that when we create CWGraph control it allocates about 3-4 GDI fonts.
When we destroying the ActiveX control, the allocated fonts
remain.

This can be reproduced by using ActiveX Container application provided by Visual Studio 6.0
Open app. Create GDI "snapshot". Instantiate CWGraph. Measure GDI resources.
Delete CWGraph. Measure GDI resources. You will see that the fonts allocated remain.

Since it is reproduced on two independant applications, we have a reason to suspect that at
least CWGraph casues GDI resource leaks, unless there is some other reason that justifies it.

2. We have a requirement to have few handred of instances of various Measurement Studio Controls in one process.
We can observe that each control allocates its GDI resources (fonts, pens, brushes, etc.) on its own.
It turned out, although we have not found any Microsoft explicit statment on this, that there is a limit of 10000 GDI
resources all together for a WIN32 process above which the app would crash.

The controls allocate on average 5-10 GDI resources, wich are mostly the same among the contols.
It causes a serious li
mitation.
Is it possible to optimize this using some pool of resources that could be reusable by the controls?
0 Kudos
Message 1 of 5
(3,605 Views)
Hello jarpp,

What version of the CWUI.OCX ActiveX control do you have? And are you using Visual Studio 6.0 Service Pack 6 (released 3/29/2004)?

David Mc.
NI Applications Engineering
0 Kudos
Message 2 of 5
(3,605 Views)
cwui.ocx version 6.0.3.594
Visual Studio SP 5
Win2k SP4

On XP we have the same behaviour
Jarp
0 Kudos
Message 3 of 5
(3,605 Views)
jarpp,

I would recommend installing Visual Studio SP 6:

http://www.microsoft.com/downloads/details.aspx?FamilyID=a8494edb-2e89-4676-a16a-5c5477cb9713&DisplayLang=en

And the Measurement Studio 6.0 Updater, which you can find on our Drivers and Updates page:

http://digital.ni.com/softlib.nsf/954feaeea92d90918625674b00658b83/e906dfc1159f08fa86256d8800564f29?OpenDocument

Best Regards,

Matt P.
National Instruments
0 Kudos
Message 4 of 5
(3,605 Views)
Hello jarpp

I dont believe there is a limitation on the total number of gdi objects per process as this document states. Now ofcourse, you would hit a certain limitation as you start taxing the resources on your system. So you might need to increase the system RAM and see if that helps.

In terms of the behavior of the tool, its a very cool utility, but I noticed that it gave the same results if I used one of the Microsoft Common controls ( I tried the Treeview control) with the ActiveX container. I also checked the results with the Windows Task Manager and with TaskInfo and both indicated th
e same. This might be an effect of GDI objects being now in the kernel that the cleanup does not happen immediately.

The Graph control does use GDI heavily because of the functionality it offers, but nothing that would prevent it from using it for you application.

Let me know if I missed anything.I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 5 of 5
(3,605 Views)