Bug: Vault browser is leaking GDI objects...

Bug: Vault browser is leaking GDI objects...

LarsGaarde
Explorer Explorer
525 Views
1 Reply
Message 1 of 2

Bug: Vault browser is leaking GDI objects...

LarsGaarde
Explorer
Explorer

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.

0 Likes
526 Views
1 Reply
Reply (1)
Message 2 of 2

matt_jlt
Collaborator
Collaborator

This might explain why my addin that i wrote, also a custom batch processing and updating / printing etc. always crashes after opening approx 1000-2000 files as if its hitting some sort of limit.

Happens with my addin as well as the Inventor task manager check in tool seems like it has this aswell.

The files i open can be large (5-20k occurrences). But it seems like i always hit some kind of limit where it crashes.


I just have a progress tracker and resume after a crash.

0 Likes