<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MKW24x MyWirelessAppEndDevice Memory Leak in Wireless MCU</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490642#M973</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;MEM_WriteReadTest() should not be used! It was created to test the memory pools after MEM_Init()!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If you use this function and an error code is returned, then some or all memory buffers will remain allocated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;PhyPlmeTimmedRxRequest() function is called before an Rx sequence needs to be programmed, and&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; will allocate memory for the packet to be received. Once a packet is received, this buffer is sent to the MAC layer which is responsible for freeing the memory.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If no packet was received at the last Rx sequence, the memory will remain allocated, and the next time the &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;PhyPlmeTimmedRxRequest() function is called, the memory block will be reused.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If there are more than 1 memory buffers allocated by &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;PhyPlmeTimmedRxRequest()&lt;/SPAN&gt; after a Scan, then the issue is at the MAC/PHY layers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Also, it may be possible that the default configuration from MemManagerConfig.h is not enough for your scenario.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;You can try to increase the number of blocks in each memory pool and check if the problem persists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;George&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Mar 2016 15:34:09 GMT</pubDate>
    <dc:creator>georgecapraru</dc:creator>
    <dc:date>2016-03-08T15:34:09Z</dc:date>
    <item>
      <title>MKW24x MyWirelessAppEndDevice Memory Leak</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490640#M971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am beginning to think that there is a potential memory leak in the MyWirelessAppEndDevice demo for the MKW24x example application and potentially in the 802.15.4 v5.0.3 library.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been porting code from the BeeStack build to the KDS build.&lt;/P&gt;&lt;P&gt;I am developing on the twr-kw24D512.&lt;/P&gt;&lt;P&gt;I have MEM_TRACKING and MEM_DEBUG defined.&lt;/P&gt;&lt;P&gt;I have been hitting a panic() call on line 313 of MemManager.c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the app continuously sending beacon requests (scan requests). In the app, instead of setting gState = stateAssociate, I set gState = statScanActiveStart.&lt;/P&gt;&lt;P&gt;This way, each time it finishes a scan, it starts a new one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After less than 200 scans, the app will crash at MemManager.c::313::panic().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help. I can provide anyone with a dump of the memTrack[] structure if needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Andrew Fitzsimons&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 22:14:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490640#M971</guid>
      <dc:creator>andrewfitzsimon</dc:creator>
      <dc:date>2016-02-25T22:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: MKW24x MyWirelessAppEndDevice Memory Leak</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490641#M972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am now trying to debug this issue using the MEM_WriteReadTest().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do the following steps when performing a scan request:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Check MEM_WriteReadTest() == MEM_SUCCESS_c&lt;/P&gt;&lt;P&gt;2) mlmeMessage_t mlmeMessage = MEM_BufferAlloc(sizeof(mlmeMessage_t))&lt;/P&gt;&lt;P&gt;3) Setup mlmeMessage as a scan request&lt;/P&gt;&lt;P&gt;4) For every beacon indication I'm freeing the BufferRoot and message&lt;/P&gt;&lt;P&gt;5) When I receive the scan confirm I free each pan descriptor block and message&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At this point, MEM_WriteReadTest() fails with MEM_ALLOC_ERROR_c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I look through the memTrack[] array, every entry is allocated from MEM_WriteReadTest() EXCEPT one who is allocated at PhyPlmeData.c::PhyPlmeTimmedRxRequest()::ln.327&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone explain to me who is responsible for freeing the memory that this function allocates, and when it should be safe for me to call MEM_WriteReadTest()?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 20:00:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490641#M972</guid>
      <dc:creator>andrewfitzsimon</dc:creator>
      <dc:date>2016-03-07T20:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: MKW24x MyWirelessAppEndDevice Memory Leak</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490642#M973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;MEM_WriteReadTest() should not be used! It was created to test the memory pools after MEM_Init()!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If you use this function and an error code is returned, then some or all memory buffers will remain allocated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;PhyPlmeTimmedRxRequest() function is called before an Rx sequence needs to be programmed, and&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; will allocate memory for the packet to be received. Once a packet is received, this buffer is sent to the MAC layer which is responsible for freeing the memory.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If no packet was received at the last Rx sequence, the memory will remain allocated, and the next time the &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;PhyPlmeTimmedRxRequest() function is called, the memory block will be reused.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If there are more than 1 memory buffers allocated by &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;PhyPlmeTimmedRxRequest()&lt;/SPAN&gt; after a Scan, then the issue is at the MAC/PHY layers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Also, it may be possible that the default configuration from MemManagerConfig.h is not enough for your scenario.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;You can try to increase the number of blocks in each memory pool and check if the problem persists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;George&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2016 15:34:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490642#M973</guid>
      <dc:creator>georgecapraru</dc:creator>
      <dc:date>2016-03-08T15:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: MKW24x MyWirelessAppEndDevice Memory Leak</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490643#M974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi George,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the clarification on the WriteReadTest().&lt;/P&gt;&lt;P&gt;I will experiment with the number of blocks in the pools and get back to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--- EDIT ---&lt;/P&gt;&lt;P&gt;I have gone through and doubled the number of each block size in the MemManagerCfg.h&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My observations:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;My system does not hard fault&lt;/LI&gt;&lt;LI&gt;Eventually MSG_Alloc() will continue to return a null pointer&lt;/LI&gt;&lt;LI&gt;20 out of 20 of the 0x100 byte buffers in memTrack[] are marked as MEM_TRACKING_ALLOC&lt;/LI&gt;&lt;LI&gt;19 of the 20 0x100 byte blocks were allocated by PhyPlmeTimmedRxRequest()&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see that the new MCR20A MKW2xD connectivity middleware has been posted and is using a MAC/PHY v5.0.4. I will be upgrading my app to use this version and see if the problem is resolved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do believe there is a memory issue around PhyPlmeTimmedRxRequest() in the 5.0.3 version. I'm crossing my fingers it was addressed :smileywink:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2016 16:45:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/MKW24x-MyWirelessAppEndDevice-Memory-Leak/m-p/490643#M974</guid>
      <dc:creator>andrewfitzsimon</dc:creator>
      <dc:date>2016-03-08T16:45:12Z</dc:date>
    </item>
  </channel>
</rss>

