RAM problem (out of memory) with PicoCOMA9X - vb.net VS2015

  • Hi F&S,


    We have a problem with the sw (developed in vb.net for VS2015) on PicoCOMA9X.

    Sometimes my application shows an exception:


    OutOfMemoryException

    at SerialParser.ByteArrayToString (Byte [] byte_arr, Int32 bytes_len)

    at Port.m_read_func ()


    the problem is that this routine is not in my code!


    After a few cycles on all 12 devices, only one or two have the problem (the timing seems random), moreover every time on a different device!


    I used your utility "FSSBCProfiler2013_V104.exe" on 12 devices with the same sw. When the problem occurs, the utility shows that the RAM of the PicoCOMA9X is at 100%!


    Unfortunately in VS2015 debugging this problem does not occur to me.

    Do you have any more "precise" utilities to understand which process (or routine) uses ALL the RAM?


    I hope I explained myself,

    I look forward to your cordial reply.

    Available for any clarification.

  • Hello,


    .NET code should not cause memory leaks because of the garbage collector. Probably is "SerialParser.ByteArrayToString" only the trigger when it try to allocate some 100kB? Which kernel you are using so I can also check for Windows Embedded Compact updates may we have a bug inside .NET.


    Do you have any DLL imports included using native code? For example if you call several times "CreateFile( <deviceX>)" without any "CloseFile(<forhandledevicex)" you will loose some bytes each time! Embedded Compact allocates RAM in junks of 4kB. So if you loose each time 8 bytes for example you will recognize the effect after 512 times.


    In a first step I would include sections with DLL imports with "GlobalMemoryStatus" and print out the results on the debug line or screen.


    Hope this helps.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Good morning,

    thanks for the quick reply.

    The kernel is v.1.30 build Dec 18 2018.


    I agree that the error on serialparser.bytearraytostring is just the trigger that shows the problem.


    CreateFile routine: the only one we use is at SW startup to manage DIO port, it is used only 1 time at startup.

    Code
    1. DIO.IOport("DIO1:")


    I have implemented GlobalMemoryStatus, so it is easier to check the memory status.


    Last note, we have included this entry in the logs, because PicoCOM was restarting and F&S told us to disable this log:

    Code
    1. Reg open \ drivers \ builtin \ picocoma9x \ dvfc1
    2. Reg set value Flags dword 4
    3. Reg save


    Hope it helps, we look forward to some good news.

  • Hello,


    can you please test with V1.40 from 210723. Here all WEC updates up to March 2021 included.


    "CreateFile" was only meant as a sample, you should check all DLL imports for possible memory leaks!


    Assume to disable dvfc should not cause a memory leak.


    >> I have implemented GlobalMemoryStatus, so it is easier to check the memory status.

    << So maybe you can relate memory increase to specail code section?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    I found the problem!

    It wasn't tied to recursive DLL imports and wasn't tied to the kernel either.


    Fortunately, after days the problem presented itself in debugging in VS2015.

    It was a real problem trying to trace the problem without it happening in debug.

    But luckily it happened and we fixed it.


    The problem was related to an unexpected turn in the VB code that every 1 second initialized a new form object.

    Code
    1. 'every second
    2. myForm = new FormX


    This randomly caused an error in the initialization code and due to a try ... catch block it kept repeating every second.


    It is not yet clear why it happened completely randomly, but now the code has been fixed and the problem is solved.


    Thanks for the tips and support because they allowed me to "clean" the code from unnecessary imports anyway.

  • Hello,


    very good that you found the cause of the issue! And thanks for share the information.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.