Архив метки: non-functional testing

Memory leaks in software — What is and how to reveal them using build-in Windows tools

Recently it became known two sites that are hung your browser and operating system. The first one crushes all once you visited it via Google Chrome and the second one in case if it is loaded via Safari (iOS).

Basically, both sites has used the same mechanism to do so — Memory overloading via embedded java-script:

<!-- CrashChrome -->
<!-- CrashSafari -->
<script>
 var total = "";
  for( var i = 0; i < 100000; i++ ) {
   total = total + i.toString();
   history.pushState(0,0, total );
  }
</script>

Whilst these sites are deliberate destructive they show us how sensitive software and even OS could be to memory leaks.

In fact, memory leaks may occur accidentally if the source code contain inefficient use of memory. And yes, memory leaks is a kind of software bugs tester must reveal before it go to production.

There is numerous of software in modern world that designed to work 24/7 (e.g., all websites, POS and embedded systems), thus if we testing it, we should bear in mind:

  • Dedicate a server where your software will run all the time, without reboot of system.
  • Periodically collect performance metrics from the application on this server — memory, processor and disk usage would be enough

Windows already contain some tools to measure resource usage, so you don’t have to buy anything else. Just start Task Manager (taskmgr.exe in command line or from Ctrl+Alt+Del window) and switch to Processes tab. Sort list by eithther Image Name (if you’re looking for a specific process) or Memory (Private Working Set) and it’ll show you which processes are the most voracious. Look at the picture below, Lync (which is currently known as Skype for Business) uses twice more memory than the Skype (usual one)!

memory-leaks_task-manager

Now switch to Performance tab. Run Resource Monitor from there (another way is to call resmon from command line). This tool provides detailed info regarding your system resources consumption, including charts and diagrams that would help to analyze metrics over the time:

memory-leaks_resource-monitor-580px

You could leave these tools running on your systems and collect memory/processor/disk consumption of your application time to time, to be able to detect memory leaks (and another unexpected behaviour of your application).