MFS RAM footprint

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MFS RAM footprint

Jump to solution
835 Views
joey81
Contributor II

I have MQX 4.0.2 running on a K60 with 128KB RAM.   Memory device is a 256MB Samsung NAND Flash.

Upon boot-up, after calling _io_nandflash_wl_install(), I still have 89344 bytes free.  After calling mfs_nandflash_wl_open(), free RAM drops to 36636 bytes.


Is this the normal RAM footprint of MFS/FFS?  Seems too big.  How do I make it smaller?


Also, each time I list the directory contents (via shell "dir" command), I lose around 20-30 bytes of free RAM.  Anyone got an idea where the leak comes from? 


Thanks in advance!

Labels (1)
Tags (3)
1 Solution
470 Views
Martin_
NXP Employee
NXP Employee

Hi,

memory size adjustment:

https://community.freescale.com/message/323494#323494

there is one problem with FFS 4.0.2 that I found in my application, that caused a memory leake. The solution was to modify function media_buffer_allocate_internal() in the FFS source file "media_buffer_manager.cpp" as shown below. The difference is line 30 in the code snippet below (_mem_transfer), which changes the buffer ownership to system, so that free() can be called from any task.

static SECTOR_BUFFER * media_buffer_allocate_internal

(

    /* [IN] Buffer length */

    _mem_size length,

   

    /* [IN] Flag */

    uint32_t flags,

   

    /* [IN] Contigous flag */

    boolean physicallyContiguous

)

{ /* Body */

    SECTOR_BUFFER * resultBuffer;

   

    switch (flags & (kMediaBufferFlag_NCNB))

    {

        /* Only NCNB memory required. */

        case kMediaBufferFlag_NCNB:

            resultBuffer = (SECTOR_BUFFER *)_wl_mem_alloc_uncache(length);

            break;

           

        /* No special requirements for the memory type. */

        default:

            {

                resultBuffer = (SECTOR_BUFFER *)_wl_mem_alloc(length);

            }

            break;

    } /* Endswitch */

   

    _mem_transfer(resultBuffer,_task_get_id(), _mqx_get_system_task_id());

    return resultBuffer;

} /* Endbody */

View solution in original post

2 Replies
471 Views
Martin_
NXP Employee
NXP Employee

Hi,

memory size adjustment:

https://community.freescale.com/message/323494#323494

there is one problem with FFS 4.0.2 that I found in my application, that caused a memory leake. The solution was to modify function media_buffer_allocate_internal() in the FFS source file "media_buffer_manager.cpp" as shown below. The difference is line 30 in the code snippet below (_mem_transfer), which changes the buffer ownership to system, so that free() can be called from any task.

static SECTOR_BUFFER * media_buffer_allocate_internal

(

    /* [IN] Buffer length */

    _mem_size length,

   

    /* [IN] Flag */

    uint32_t flags,

   

    /* [IN] Contigous flag */

    boolean physicallyContiguous

)

{ /* Body */

    SECTOR_BUFFER * resultBuffer;

   

    switch (flags & (kMediaBufferFlag_NCNB))

    {

        /* Only NCNB memory required. */

        case kMediaBufferFlag_NCNB:

            resultBuffer = (SECTOR_BUFFER *)_wl_mem_alloc_uncache(length);

            break;

           

        /* No special requirements for the memory type. */

        default:

            {

                resultBuffer = (SECTOR_BUFFER *)_wl_mem_alloc(length);

            }

            break;

    } /* Endswitch */

   

    _mem_transfer(resultBuffer,_task_get_id(), _mqx_get_system_task_id());

    return resultBuffer;

} /* Endbody */

470 Views
joey81
Contributor II

Excellent!  Both problems are now fixed.

Thanks!

0 Kudos