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

Thread Starter

bandaru_sivakrishna

Joined Sep 12, 2011
2
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.
 

debjit625

Joined Apr 17, 2010
790
Is their any specific tools are their?.
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
 

t06afre

Joined May 11, 2009
5,934
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?
 

MrChips

Joined Oct 2, 2009
19,391
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.
 

ErnieM

Joined Apr 24, 2011
8,006
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?
 

Thread Starter

bandaru_sivakrishna

Joined Sep 12, 2011
2
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.
 

MrChips

Joined Oct 2, 2009
19,391
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.
 

t06afre

Joined May 11, 2009
5,934
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
 
Top