User Object Cost Increase/Leak Within C1CommandHolder

Posted by: darren.patterson on 15 October 2019, 8:25 am EST

  • Posted 15 October 2019, 8:25 am EST

    Hi All,

    After an upgrade of the ComponeOne DLLs in our software we started to encounter issues with user object count limits being hit. Our software makes extensive use of C1 controls and after tracing the issue it was narrowed down to the CommandHolder class (a part of the C1.Win.C1Command.dll).

    Original C1.Win.C1Command.dll version: 4.0.20132.19568
    Upgraded C1.Win.C1Command.dll version: 4.0.20172.271

    In the original dll version the CommandHolder class created zero user objects when instantiated, where as in the Upgraded dll version 2 user objects were created per instance of the class. This would increase the cost of any C1 class that contained a commandHolder, C1ToolBar for example. A secondary issue was that these additional user objects are not released when the object is disposed which would result in the eventual windows user object limit exception.

    As a workaround we have downgraded the DLL but am inquiring if this has been resolved in future versions, since this short term fix prevents the use the designed for the commandHolder due to DLL mismatch.

    Thank you for your time,
  • Replied 15 October 2019, 7:58 pm EST

    Hello Darren,

    Whenever new object is instantiated, user objects has been created for that object.
    In the attached application I free resources of commands after use, in FormClosed event.

    Garbage Collector works async, I added call to GC collect methods in my sample on a button click . If you click on the "button 2" you see 33-34 objects in Task Manager and this value does not grow, only varies in the above range.

    Steps to run the sample:

    1 : Run the attached sample.
    2 : Open the Task Manager and go to the "Details" tab and search your application.
    Observe : Initial Object value is 22.
    3 : Click on the "button1" on Form2, this will open Form1 with Ribbon control and CommandHolder.
    4 : Close the Form1.
    Observe : Object value is 42/43
    5 : Click on "button2".
    Observe : Object value is 32/33.

    If you have any issue please modify the attached sample or provide your own stripped down sample replicating the issue.

    Prabhat Sharma.
  • Replied 17 October 2019, 7:15 am EST

    Hi Prabhat,

    Thank you very much for your time and response!

    I have done some testing with the application you provided and this illustrates the issue perfectly.

    Once the application is running each time you execute the following the user object count will be increased by 2 (which i believe is coming from the commandHolder):
    - Click on button1 (which will show form1)
    - Close Form1 (your close event is also calling garbage collection, but you can also click button2 as well)

    Perform the above over and over and each time it will increase by an addition 2 user objects which will eventually hit windows user object limit of 10k and crash. My company's software makes extensive use of component one toolBars and commandHolders so this grows very quickly.

    I have attached an updated version of your application that simple has 10 more commandHolders and if you repeat my above steps you can see the user objects grow by the additional 2 per additional commandHolder instance.

    Below is a screenshot of the user object count from repeating the above steps:

    I cannot add the modified project due to size, even compressed its over 5MB, but I have attached just the form1.cs file that I modified.

    As I also noted this does not occur with version 4.0.20132.19568 of the C1.Win.C1Command.dll

    Thanks again for your time,
  • Replied 17 October 2019, 4:22 pm EST


    As I said earlier whenever new object is instantiated, user objects has been created for that object.

    I updated my application as per your changes in Form1.cs file.

    I too can replicate the issue in the 4.0.20172.271 builds that user object is increasing continuously but on checking with latest builds 4.0.20192.375 that user object value remains between 32-33 in the attached application by following the previously given steps. Please see the attached GIF for reference.

    You can download the latest builds from the given link :

    Prabhat Sharma.

  • Replied 25 October 2019, 4:57 am EST

    Hi Prabhat,

    Thanks for the reply!

    Do you know if I can just upgrade the C1.Win.C1Command.dll to the latest version containing the fix or do I have to upgrade the whole suite? I am asking due to the significant overhead to a full C1 upgrade will have on the application.

  • Marked as Answer

    Replied 27 October 2019, 2:58 pm EST

    Hello Darren,

    Though you may manually replace the old C1.Win.C1Command.dll with its corresponding latest version in your project, it will not be recommended as it can cause issues (especially with the form designer)
    Many ComponentOne assemblies internally refer to other ComponentOne assemblies. Therefore, it is suggested to have the same version of ComponentOne dlls referred to in a project.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels