Memory Leak Testing
Posted by
JORRIT WIT on Sat, Jan 28, 2012 @ 08:15 AM
Memory Leak Testing
It can crash your application, can you afford to ignore it?
Written by Sunil Damle

Memory leak testing is an important aspect of a software testing process but often it is ignored during the various testing phases. A memory leak issue is difficult to debug or fix if identified in production.
Memory leak - Why it happens?
An ideal application program releases memory after use but if it cannot, it will result into a memory leak. Such a dynamically allocated memory could be not used by any other program or system and may result into issues like slowness in system performance or as critical as an application crash, with only remedy of rebooting the system. This is much critical issue in case of automotive applications or a business applications where it can not be easily restarted. So, it is important to plan and make sure that the application is free from such leakages.
How can Memory leaks be handled?
To detect a memory leak issue is very challenging. As such a defect is difficult to reproduce and isolate, it should be handled appropriately at different phases in the software development life cycle (SDLC). There can be different methodologies specific to an application.
Here is a suggested four step approach from QA's perspective:
1. Plan – A plan to minimize memory leak risks considering different factors
There are various factors to be considered for this issue but not limited to:
- Application Technology
- System Environment
- Programming practice
- Development approach
- Performance Testing
2. Design –Design test scripts and unit tests to detect memory issues, follow good design practices
3. Detect – Test for the presence of a memory leak in the system with functional and non-functional testing
4. Fix – Once detected, debug, isolate the issue and then fix the Memory leak. Once a Memory leak issue is fixed, the procedure to repeat steps 2 to 4
Memory Leak Detection Tools:
There are different tools available in market that can detect memory leaks mainly during unit testing. Examples: IBM Rational Purify, Compuware BoundsChecker; open Source tools like Valgrind.
Further, QA activities like static code analysis, following coding guidelines and thorough code reviews would help to minimize such issues.
Memory leak issues are often difficult to detect with just with functional testing, however specific performance testing helps to detect such issues.
Reference: http://msdn.microsoft.com/en-us/library/ms859415.aspx
The opinions expressed on this discussion room are writer's and don't necessarily represent NTT DATA Canada's positions, strategies or opinions.