Form with Chart2D crashes program when trying to load second time

Posted by: SatishMatani on 30 March 2019, 1:20 pm EST

    • Post Options:
    • Link

    Posted 30 March 2019, 1:20 pm EST

    I have a program where I open another form with Chart. It loads fine the first time. However after closing it and trying to load the form the second time, program crashes with following error:

    The program ‘[17384] WindowsApp12.exe’ has exited with code -1073740940 (0xc0000374)

    I am able to repeat the error in small separate sample I created. I am attaching the file. Click on Button1, close the new form with chart, click on the Button1. It will crash with above error.

    Any help will be appreciated.WindowsApp12.zip

  • Posted 31 March 2019, 8:03 pm EST

    Hi Satish,

    I could not replicate the issue using the sample you shared. On closing the Form containing Chart and clicking on the Button again, does not cause any error. Can you please try using the following version of Chart 8.0 and see if that makes any difference:

    http://prerelease.componentone.com/activex/c1chart/2017-t3/C1Chart_8.0.20173.103.zip

    http://prerelease.componentone.com/activex/c1chart/2017-t3/C1Chart_8.0.20173.103_x64.zip

    Thanks,

    Pragati

  • Posted 1 April 2019, 4:02 am EST

    Hi Pragati,

    Will you please give me more instruction to how I install these versions?

    As a side note, I don’t remember having this problem before. Something that has come up recently and occurs every time.

  • Posted 1 April 2019, 9:03 pm EST

    Hi Satish,

    Since the problem could not be replicated at my end, I cannot comment on its cause. What did you change in recent times? The problem seems specific to your environment.

    In order to install the above mentioned version:

    1. Download the 32 and 64 bit ocx files from the links I shared.
    2. In order to register the ocx files, follow the instructions given in the below mentioned blog article:

      https://www.grapecity.com/en/blogs/registration-of-64-bit-activex-controls

    Thanks,

    Pragati

  • Posted 3 April 2019, 2:51 pm EST

    Hi Pragati,

    I tried out this on different computer with fresh VS and ComponentOne install. I am getting the same error. I also tried on both computers with new versions of control you provided. Having the same problem.

    Thanks

  • Posted 8 April 2019, 8:27 pm EST

    Satish,

    I could not replicate this issue on different machines at my end. Can you please share your environment details (OS, architecture and VS version) so that I can investigate the issue further?

    ~Pragati

  • Posted 15 April 2019, 12:22 am EST

    Machine 1:

    OS: Windows 10 Pro

    Version: 0.017134 Build 17134

    Architecture: AMD 64

    VS Version: 2017 (also tired using 2019)

    Machine 2:

    Windows 10 Pro

    Version: 0.017134 Build 17134

    Architecture: AMD 64

    VS Version: 2017

  • Posted 23 April 2019, 4:55 pm EST

    Hi Satish,

    I could replicate the issue on a Windows 10 machine at my end. I have escalated it to the developers (Internal Tracking ID: 376154) and will let you know once there is any information from them.

    Thanks,

    Pragati

  • Posted 20 May 2019, 1:43 pm EST

    Pragati,

    Just wondering if there is any update on this issue.

    Thanks,

  • Posted 20 May 2019, 4:07 pm EST

    Hi Satish,

    I am getting in touch with the developers regarding the status. Will get back to you once there is anything from them.

    Thanks,

    Pragati

  • Posted 23 June 2019, 6:25 pm EST

    Hi Satish,

    There are two issues with the sample program that made the problem go away. The indexing was odd and the x() and y() arrays were variants. Note that the built in interop for SafeArrays of variants does not work well in WinForms, so the arrays should be typed explicitly.

    GetData without ReDim for each point, and correct indexing.

    ```
    

    Sub GetData()

    Ls = -5

    Le = 15

    r = 0

        For i = Ls To Le Step 0.01
            r = r + 1
        Next
    
        ReDim Preserve x(r - 1)
        ReDim Preserve y(r - 1)
    
        r = 0
        For i = Ls To Le Step 0.01
            x(r) = i
            y(r) = i ^ 2 * 15
            r = r + 1
        Next
    End Sub
    
    
    GlobalVariables Module.
    
    

    Module GlobalVeriables

    Public r As Integer

    Public Ls As Double

    Public Le As Double

    Public x() As Double

    Public y() As Double

    End Module

    
    Making the above changes will solve the problems for you.
    
    ~Pragati
  • Posted 20 October 2019, 3:09 am EST

    Pargati,

    It eventually crashes. It happens randomly. File attached. Keep clicking on Button1. It may not happen right away. Some time it crashes after three or four clicks and sometime it takes longer or sometime it does not. But after restarting and trying again it will crash. Note the example attached is a short version of the actual program that I am working on. So this is a big issue for me.WindowsApp12 (2).zip

  • Posted 20 October 2019, 10:26 pm EST

    Thanks, Satish.

    I could observe the issue. Let me ask the developers for the same. Will get back to you once there is anything from them.

    ~Pragati

  • Posted 4 December 2019, 8:03 am EST

    Any update on this?

  • Posted 5 December 2019, 7:58 pm EST

    Satish,

    I am asking the developers for the same. Will get back to you soon.

    Thanks.

  • Posted 8 December 2019, 4:47 pm EST - Updated 29 September 2022, 2:51 am EST

    Hi Satish,

    The developer further investigated on the issue. As per him, the issue is not related to Chart8 or the Windows version, but instead the memory state of the machine running the application, the .NET mechanism of hosting an ActiveX control and the timing of the .NET garbage collection. He concluded this by automating the open and close process of Form in the sample with a pair of timers. When running the original automated sample at his end, the exception occurred with as few as 12 iterations and as many as 99 iterations - it just depended upon how the program was loaded and the state of the .NET heap. It appears that .NET form cleanup operations (which interact with the chart) were occurring after the chart had been released from memory which results in a heap-memory access violation (i.e. - attempting to use memory that had already been deallocated).

    By forcing a garbage collect upon form closure, it is possible to avoid the issue. The attached image shows that we were able to run a final modification of the sample with a forced garbage collect with over 6800 iterations before stopping the program. At the bottom of the image is code showing a simple override of the Form.OnClose method for Form2 that forces a garbage collect.

    The newly attached sample, WindowsApp12-Mod.zip has changes which automate the test and the force garbage collect. Pressing the AutoRun button toggles the automation. Pressing the original “Button 1” button, allows manual open/close operations.

    Hope that helps.

    Thanks,

    Pragati

    WindowsApp12-Mod.zip

Need extra support?

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

Learn More

Forum Channels