How to find memory leak and how to resolve it on embedded systems

Discussion in 'Embedded Systems and Microcontrollers' started by bandaru_sivakrishna, Sep 12, 2011.

  1. bandaru_sivakrishna

    Thread Starter New Member

    Sep 12, 2011
    2
    0
    Dear All,

    How to find a memory leak and how to resolve memory leak on emebedded systems.

    Is their any specific tools are their?.
    can you any body please explain in detail regarding this.

    Thanks & Regards
    SivaKrishna.
     
  2. debjit625

    Well-Known Member

    Apr 17, 2010
    790
    186
    A good debugger will do it. You have to be more specific about your system i.e.. about your processor or mcu and the language you are using...

    Normally in small systems (like system running under mcu) memory leak is not much concern as it could be find out quickly ,but in big system it is a concern,but again you have to tell us more about your system.

    Good Luck
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Memory leaks are more a problem in systems like windows. An application reserve some memory from the memory manager. But then not needed any more the memory manager is not noted about this. And hence the memory will be lost to the system. In a MCU system this is not likely to happened.
    As said before I think we need more info about your system. Are you sure your problem is memory leak?
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,441
    3,361
    Memory leaks on a small embedded MCU are more likely to occur when you have many hardware interrupt calls, and many nested subroutine calls, along with large data arrays. The result is that memory space needed to handle interrupt and subroutine calls grow until they collide with the data area.

    The simplest solution is for the programmer to understand the memory map, tally how much memory is required to handle both subroutine calls and data and to ensure that never the twain shall meet.
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    SivaKrishna: as soon as you start using a memory heap you can have leaks, no matter if it's windows or some embedded system. It is usually more serious in an embedded system as you just have fewer resources to loose track of.

    I've seen several threads on this in the Microchip boards concerning their Malloc() and Free() implementations on some cores (PIC32's I believe) where the default code doesn't actually free the memory, it just releases the pointer so the resource cannot be reused. This information is old, over a year since I looked into it, but just to note bad things can happen to good programs <grin>

    What type of embedded system are you working on? We would need to know your tool chain before giving any specific advice. What chip, compiler, programmer/debugger are you using?
     
  6. bandaru_sivakrishna

    Thread Starter New Member

    Sep 12, 2011
    2
    0
    Erneim: thanks for giving good information

    Embedded : working in automotive domain in infotainment system on MFD (display system)
    Micro: freescale micro MC9S12XHZ512
    compiler: cosmic
    Debugger: Jtag,Trace32
    can you please give me some information regarding memory leak tools to test complete s/w is thier any memory leaks are their or not.
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,441
    3,361
    Create a variable or block of variables at the end of your variable space. Write some known values into the variables and see if the values are being destroyed by stack overflows.
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    For this kind of debugging. I think you will need a in circuit emulator/debugger. And then set some breakpoint trigged on write to one or more specific memory addresses
     
Loading...