none
Graphics.cs DrawLine freezes RRS feed

  • Question

  • Hello,

    I have problem in Graphics class. I use component one report to generate pdf files. Sometimes application freezes. I tried to find place where it freezes and I set up Visual Studio to debug .NET Framework. When application freezed I paused Visual Studio debugger to find area where it freezed. It stopped in Graphics.cs at line 1208 - CheckErrorStatus(status). But I cannot continue to end of method or step into CheckErrorStatus. It looks like there is problem with GDI? 

    What can cause this behavior? When it freezed application use CPU as you can see. Application runs on Windows Server 2016 but I can simulate it on Windows 10 Professional (17134.407). Version of .NET Framework is 4.6.1. 

    Wednesday, February 6, 2019 12:11 PM

All replies

  • Hi Petr B,

    Thank you for posting here.

    For your question, please provide the code sample which could reproduce the freezes and the steps which you used to debug for us to test.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 7, 2019 2:24 AM
    Moderator
  • Thank you for you reply. I will be impossible because I use component one (C1 components) to generate pdf reports. C1 works with System.Drawing library. So I cannot access to code. I tried to investigate what is happening when application freezes. I think there is problem with GDI handlers releases because when application is freezed I see there are 4000 GDI handlers in task manager. 

    This application ran on Windows Server 2012 before some time. With this system we had error GDI+ Initialization sometimes. There was one solution - machine restart. It makes sense because when there are not free GDI handlers restart is solution. But there is not any error when application runs on Windows Server 2016. Maybe there can be some changes in GDI between Windows Server 2012 and Windows Server 2016?

    Because this problem is caused by C1 Component probably, is there any chance to get all GDI handlers by my process to release them? I can get count of GDI handlers but is there any chance to release them when application ends?

    Thursday, February 7, 2019 6:00 AM
  • Hi Petr B,

    >>I think there is problem with GDI handlers releases because when application is freezed I see there are 4000 GDI handlers in task manager. 

    How do you count the 4000 GDI handlers? According to your description, you use  System.Drawing library. If it is GDI objects, you could use Dispose method to release some of them. Or use using statement to release.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 12, 2019 5:59 AM
    Moderator
  • Thank you for you answer. I know I have to call dispose method to release GDI object. Problem is that code which works with System.Drawing library is third party code. It seams third party code doesn't use dispose in some places so there are memory leaks and GDI handler leaks. 

    Problem is that we have application in Windows Server 2012 and Windows Server 2016. With 2012 version we get error message GDI+ exception and application doesn't start. But in 2016 version application freezes and there is not any error message. 

    When we have error message we know we need to restart server to solve problem. But when application freezes it is worst because we don't know anything. On older Windows Server version (2012 and 2008) we have application which try to allocate and release GDI handlers to check if there is more than 5000 free GDI handlers. When application cannot allocate 5000 handlers we get alert message and we have time to plan time window to server restart. 

    I tried to allocate GDI handlers on my machine (Windows 10) and one application can get 10000 handlers only. It is as documentation says. But when application used 10000 handlers and I want to allocate next handlers there was not any error message. Then I tried to have application beside to try allocate all GDI handlers in system (64k handlers). But I could have more than 10 application instances, so it means all applications used more than 100 000 handlers. I don't know how it is possible.

    Tuesday, February 12, 2019 3:00 PM
  • Hi Petr B,

    Sorry for that. As I know, the way we could use to release GDI objects is to use Dispose method and use using statement. We do not know how does your third party product release GDI objects. You could contact your third party produce to get some support.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 14, 2019 8:00 AM
    Moderator