Bug: Vault browser is leaking GDI objects...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is not necessarily API related, but we figured that this was the best place to post.
It seems that the Vault browser (the dockable window similar to the model browser) is causing the loss of a number of GDI objects everytime a document is opened/closed.
We develop somewhat large add-in that does a lot of batch processing of documents in Inventor, e.g. opening and printing all drawings in an assembly or opening all drawings in an assembly and creating a PDF file for each drawing.
That means that we open/close a lot of documents (the leak happens on all document types).
In Windows an application can, by default, have no more than 10.000 GDI objects. If that limit is breached, the application will crash with no warning (user is unable to save any documents).
So, this is a serious problem.
We have created two test scenarios:
First test scenario:
- Select an IPJ file that is connected to a Vault
- Make sure that you are logged into Vault
- Make sure that the Vault Browser is open
- Select a drawing file that is in that Vault and open/close it multiple times
- No changes are made to the drawing in the process
Second test scenario:
- Select an IPJ file that is NOT connected to a Vault
- Select a drawing file from the project's working folder and open/close it multiple times
- No changes are made to the drawing in the process
List of results:
First Scenario (Vault) (3 runs):
Run 1:
Initial GDI Objects count: 6820
Delta GDI Objects: -183
Run 2:
Initial GDI Objects count: 6992
Delta GDI Objects: -186
Run 3:
Initial GDI Objects count: 7167
Delta GDI Objects: -186
Second scenario (not Vault) (3 runs):
Run 1:
Initial GDI Objects count: 7601
Delta GDI Objects: -11
Run 2:
Initial GDI Objects count: 7603
Delta GDI Objects: -7
Run 3:
Initial GDI Objects count: 7604
Delta GDI Objects: -6
Please note that, at the time that we are reading the number of lost GDI objects, Inventor isn't quite done releasing all of them yet.
This means that the Delta values are a bit off.
Look at the first two runs in the second scenario:
The reported loss i 11, but the difference between the first runs initial value and the second runs inital value is only 2 (7603-7601), so some GDI objects are released after we read the value.
Nevertheless, the trend is very clear running with or without Vault:
- With Vault: 6820 -> 6992 -> 7167 a loss of roughly 185 GDI objects per run
- Without Vault: 7601 -> 7603 -> 7604 a loss of roughly 1.5 GDI objects per run
We have attached a sample script, that opens/closes the same drawing 25 times. This is the script that yields the results shown above.
The sample connects to Inventor via COM (running out-of-process).
If you want to test it, please start Inventor and open, then close, at least one document manually.
The reason for this is that Inventor uses/reserves a number of GDI objects when the first document is opened/closed.
If you don't do this, the results of the first run will be skewed!
Then run the provided sample.
We have used LinqPad to test it, but you can obviously also test it with Visual studio.
It makes no difference to the numbers if you run it externally via COM or internally via an add-in in Inventor.
We have tested this in different versions of Inventor and it seems to be present in Inventor 2021, 2022 and the RC1 of 2023.
We haven't tested any versions earlier than this.