Spy heap refers to the memory allocated to DevOps Test UI (formerly Rational Functional Tester, RFT) within an enabled browser. Test execution with DevOps Test UI (DTUI) is a java process that allocates and consumes heap on the machine on which the test is run. One of the things a test can do is open a browser. If properly enabled, the browser is loaded with some DTUI libraries. This is what allows DTUI to recognize objects on a browser page. Sometimes, the resource needs of the libraries outstrip the resources available to the browser.
Most commonly, this manifests in stack trace entries like this:
- rational.test.ft.sys.InvalidSpyMemReference: Invalid Spy Memory reference
- rational.test.ft.sys.Mutex$TimeoutException: Spy Heap is locked
at com.rational.test.ft.sys.SpyMemory.lock(Native Method)
at com.rational.test.ft.sys.SpyMemory.lockEx(Unknown Source)
at com.rational.test.ft.sys.TestContext$ShutdownHook.run(Unknown Source)
Spy heap issues are notoriously difficult to debug. Over the years several potential solutions have shown themselves to be beneficial. Bear in mind that sometimes your solution may be a combination of solutions.
Simple Things to Check
Turn Off Simplified Scripting
This recalls older releases of the product when Simplified Scripting was more in vogue. It is rarely used with recent releases and the default setting is no longer ON.
- Open DevOps Test UI.
- Navigate to the Window > Preferences > Functional Test > Simplified Scripting.
- On that panel, there is a single checkbox. If it is checked, uncheck it.
- Click Apply and Close button.
Extraneous Java Processes
When a workbench session or, more often, a playback session, ends it does not always clean up after itself. Lingering instances of java.exe or javaw.exe consume system resources.
- Close DevOps Test UI.
- Use Windows Task Manager’s Details tab to make sure that there are no extraneous java processes related to the functional test tool currently running.
- Search for java.exe or javaw.exe and, if you find any entries, right-click to select Properties.
- If the Location value shown in the pop up contains your installation directory, kill that process.
Helpful Modifications
This section covers two settings adjustments you can make that are often very helpful. The thing to note here is that, even if these adjustments do not address the issue as you see it, there is no need to reverse your actions. Each is beneficial in the long run.
Increase Spy Heap Memory
This action may require administrative privileges.
- Close DevOps Test UI.
- Open the Windows Registry Editor (regedit).
- Navigate to [HKEY_LOCAL_MACHINE\SOFTWARE\IBM\DevOps Test UI]. *
- Create a new DWORD value named SpyHeapSize and set its value data to 2097152 (or 200000 hexadecimal)
- Close the registry editor.
The key can also be added by creating a .reg file with this content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\IBM\DevOps Test UI]
"SpyHeapSize"=dword:00200000
* If using Rational Functional Tester, your registry key is [HKEY_LOCAL_MACHINE\SOFTWARE\Rational Software\Rational Test\8].
Increase JVM Heap Size
Heap size allocated for the Rational Functional Tester workbench is controlled by settings within the eclipse.ini file. By default the file is found at C:\Program Files\IBM\SDP\.
- Use a text editor to open the eclipse.ini file.
- Locate the setting -XmxNNNNm, where NNNN is numeric value representing mb to be allocated for workbench heap.
- Increase NNNN but do so with the following caveats:
- For 32-bit installations of DTUI, the value is limited by the architecture. The value should not exceed -Xmx1400m.
- For 64-bit installations of DTUI, the upper limit is more fluid. At the very high end, it is gated by the amount of RAM on your system. Remember the operating system needs to have some heap to do its thing; just because you have 16B RAM does not mean you can set -Xmx16g. You have to make allowances for the OS (about 3GB but don’t be greedy) and any other processes you might have running concurrently on the machine. A best practice is to upgrade the value incrementally – maybe 2g or 2048m at a time – until you find a value that alleviates the memory errors.
- If the value is set too high – exceeding your available heap, the JVM will crash as soon as you try to open the workbench.
Note: Beginning with DTUI 11.0.2, 32-bit installation is no longer an option.
Add Switch: -clean
- Start Programs > DevOps Test > DevOps Test UI-Eclipse Integration.
- Right-click on DevOps Test UI-Eclipse Integration to select More > Open file location.
- Right-click onDevOps Test UI-Eclipse Integration to select Properties.
- Modify the Target value to append -clean as shown below:
"C:\Program Files\IBM\DevOpsTest\eclipse.exe" -clean -product com.ibm.rational.rft.product.ide
The -clean option rebuilds workspace metadata and will make your workbench startup a bit slower as it does so but keeping workspaces as clean as possible is a benefit in the long run.
Manual Cleanup
This section is last because it involves removing things from your environment. If this sort of thing makes you uneasy, please remember to take backups for recovery should anything go wrong.
Clean Temp
- Navigate to the Run box.
- Type %temp%.
- Delete all the files in this directory.
Clean Metadata
- Using Windows File Explorer, navigate to your workspace directory.
- Delete the .metadata folder.
Unregister Allocated Objects
Bound references remain in memory until playback ends. That means if you are allocating objects within a test automation framework using APIs like find(), you should include code to unregister these objects. The simplest way to accomplish this is through using unregisterAll() at strategic points in your scripts. Further details can be found in the formal product documentation by searching for “Unregistering references to test objects”.
#RationalFunctionalTester