One of the problems with developing embedded systems is the detection of memory errors; like
- Memory leaks
- Memory corruption
- Allocation / de-allocation API mismatches
- Inconsistent memory API usage etc.
These memory errors degrade performance of any embedded systems. Designing and programming an embedded application requires great care. The application must be robust enough to handle every possible error that can occur; care should be taken to anticipate these errors and handle them accordingly—especially in the area of memory.
In this article we have described how to use Intel® System Studio to find dynamic memory issues in any embedded application.
Intel® System Studio 2015
Intel® System Studio a new comprehensive integrated tool suite provides developers with advanced system tools and technologies that help accelerate the delivery of the next generation power efficient, high performance, and reliable embedded and mobile devices.
To get more information about Intel® System Studio – http://software.intel.com/en-us/intel-system-studio
Dynamic Memory Analysis
Dynamic memory analysis is the testing and evaluation of an embedded application for any memory errors during runtime.
Advantage of dynamic memory analysis: Dynamic memory analysis is the analysis of an application that is performed by executing application. For dynamic memory analysis to be effective, the target program must be executed with sufficient test inputs to analyze entire program.
Intel® Inspector for Systems
Intel® Inspector for Systems helps developers identify and resolve memory and threading correctness issues in their unmanaged C, C++ and Fortran programs as well as in the unmanaged portion of mixed managed and unmanaged programs. Additionally the tool identifies threading correctness issues in managed .NET C# programs.
Intel® Inspector for Systems will currently identifies following type of dynamic memory problems.
Incorrect memcpy call
When an application calls the memcpy function with two pointers that overlap within the range to be copied.
When an application calls a deallocation function with an address that does not correspond to dynamically allocated memory.
Invalid memory access
When a read or write instruction references memory that is logically or physically invalid.
Invalid partial memory access
When a read or write instruction references a block (2-bytes or more) of memory where part of the block is logically invalid.
When a block of memory is allocated but not deallocated within a specific time segment during application execution.
When a block of memory is allocated, never deallocated, and not reachable at application exit (there is no pointer available to deallocate the block).
Memory not deallocated
When a block of memory is allocated, never deallocated, but still reachable at application exit (there is a pointer available to deallocate the block).
When a deallocation is attempted with a function that is not the logical reflection of the allocator used.
When an invalid pointer is passed to a deallocation function. The invalid address may point to a previously released heap block.
Uninitialized memory access
When a read of an uninitialized memory location is reported.
Uninitialized partial memory access
When a read instruction references a block (2-bytes or more) of memory where part of the block is uninitialized.
Cross-thread stack access
When a thread accesses a different thread's stack
Conclusion: Intel® System Studio provides you dynamic memory analysis feature to build robust embedded application.