Electronic Design

Thanks For The Memory

The program runs! Break out the champagne. It's time to ship. Or is it?

Diagnostic tools such as debuggers and trace applications are invaluable in tracking down bugs. However, an often overlooked or unavailable tool is the memory-management tool. Any debugger can catch an errant pointer, but a subtle growth in the amount of memory used can come back to haunt a developer. Unlike many PC-based applications, embedded applications run forever, making it harder to discover memory leaks and other problems.

Programming languages like C, C++, and assembler are prone to memory-related problems not limited to memory leaks. Allocation speed, fragmentation, and even memory corruption issues can arise when dealing with dynamic memory management. Tools such as IBM's Rational Purify (www.ibm.com) provide more advanced memory error-detection hooks into the program's dynamic memory-allocation system. Compuware's (www.compuware.com) DevPartner Studio and Metrowerks' CodeTest can deliver a real-time graph of memory usage as well as detailed views of multiple heaps.

Moving to higher-level programming languages like Java and C++ with their use of garbage collection only eliminates dangling pointer problems. Most other memory-related problems remain, so good tools are just as important for projects using these languages. One is prone to problems with libraries like Java's collection classes and the C++ standard template library (STL). These can easily utilize much more memory than originally intended by a programmer.

Some memory-related issues are often related to the hardware employed. For example, Texas Instruments (www.ti.com) is working to develop tools that will assist in data placement to optimize cache performance on DSPs. Although improved performance is a laudable goal, the desired effect is often to reduce power consumption. Spend less time fetching information or allocating memory and more time crunching numbers. Caching policies such as write-through versus write-back can even affect performance. Cache size is another issue that crops up with custom designs. Knowing an application's memory utilization can potentially enhance system design and performance.

Most embedded developers are well aware that memory is a limited commodity, so minimizing program and data memory is desirable. Unfortunately, the tools available for gauging system requirements and diagnosing problems often are minimal at best. As a result, developers are forced to guess or create their own tools.

I have found memory-management diagnostic tools to be very handy when utilized on a regular basis. Let me know what kinds of tools you find most useful.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish