Forum Discussion

jr348's avatar
jr348
Contributor
4 years ago
Solved

Memory/Performance leak around JS scripts (OCR) - Does not happen with a code snippet

I have a suite of keyword tests with a small number of JS scripts to access object methods not available otherwise.

 

These is OCR.Recognize and DetectTable were incorporated into a script as a one-line function.

 

When the script was called within keyword tests it was noticed test execution visibly slowed until they ground to a halt. 

 

Performance counters were added to allow monitoring of memory and CPU% at every test step but nothing unusual was noted.

 

When the script was converted to a code snippet and the issue was "solved".

 

This page seems to highlight something similar.

https://community.smartbear.com/t5/TestComplete-General-Discussions/Memory-cleanup-in-scripts/m-p/46485

 

However TestComplete should look after garbage collection once the script is closed.  I do not think that's happening.

 

This is the script:

 

function Get_Table_Cell_script(Row_param, Col_param)
{
	
	var Text = OCR.Recognize(Aliases.Reflection_app.MCS_UAT_form.MCS_Display).DetectTable(spNone, false).Cell(Row_param, Col_param).Text;
					
	return(Text);
}

 

 

The above was initially written with intermediate objects that were "nullified" before exiting.

 

The equivalent code snippet is:

 

OCR.Recognize(Aliases.Reflection_app.MCS_UAT_form.MCS_Display).DetectTable(spNone, false).Cell(KeywordTests.Get_Table_Cell.Variables.Row_local, KeywordTests.Get_Table_Cell.Variables.Col_local).Text

 

 

We do not want to use code snippets because they are messy and difficult to maintain and can only be used for the basics.

 

We have a lot other TC test suites that use scripts and have not seen this issue.

 

Is it related to the OCR objects?