Dealing with OutOfMemoryException Errors

Problem

When working with very large Test Studio test projects (350+ tests) or very large result sets you may get out of memory errors. Test Studio does not have any built-in hard limits on project size or results size. Naturally the larger the project or the larger the result set the more memory it will require. Test Studio, being a 32-bit Windows application, has an address space limitation of 2GB put upon it by the OS, no matter how much physical memory you actually have.

When a Windows application asks the OS for a block of memory, Windows will attempt to satisfy that memory request with a contiguous block of memory. If you ask for a 40MB block of memory, it means a single 40MB block of memory (not a piece from here and a piece from there). If Windows cannot find a contiguous block of memory large enough to satisfy the request and make it fit within the 2GB address space for the application, i.e. fit along with all the other memory the application is already using, you will get an OutOfMemoryException error from the OS and the application usually will be terminated by the OS.

Solution

Option 1

The most obvious option is to break up your test project or your tests into multiple smaller pieces. This way the memory being used will not be as great. Our experience shows that you will start to get out of memory errors with projects larger than about 350 tests total or with tests that have over 800 steps in them.

Option 2

Another option that sometimes helps is to use a 64-bit version of Windows. This version of Windows can handle more physical memory which allows it to better manage the memory it has and may more easily be able to satisfy requests for large blocks of memory.

Option 3

This last option is more experimental, but has been shown to work in a few cases. There is a flag called "LARGEADDRESSAWARE" that can be turned on for 32-bit executables like Test Studio. When this flag is set Windows will let the application use 3GB of address space instead of 2GB of address space. This flag only works when you're using a 64-bit version of Windows. It also requires Visual Studio to be installed before you can set this flag. To turn on this flag follow these 3 steps:

1.  Open a Visual Studio command prompt (the standard command prompt won’t have the path set properly), with admin privileges

2.  Enter “cd C:\Program Files (x86)\Telerik\Test Studio\Bin

3.  Enter “editbin /LARGEADDRESSAWARE Telerik.TestStudio.Desktop.exe

That should be it. To double check that it worked, you can (in the same command prompt) run:

dumpbin /headers Telerik.TestStudio.Desktop.exe

You are looking for something ~12 lines down that says “Application can handle large (>2GB) addresses”

4.  If you do not have editbin exe in the bin folder you can use this small tool.