1. Method to identify big page
var childNum = doc.ChildCount;
if (childNum > 13000 || childNum == 0) {
Log.Warning("Can not handle too large page!");
return null;
}
2. Release no use memory for browser and TestComplete
Based on information at,
minimize then maximize window could force process to release the no used memory, code for IE is as below:
// to release memory of browser
var browerWindow = windowPage.Parent;
while (! BuiltIn.IsSupported(browerWindow, "Minimize")) {
browerWindow = browerWindow.Parent;
}
browerWindow.Minimize();
browerWindow.Restore();
// to release memory of TC
Sys.Process("TestComplete").Window("TfrmTCMainForm", "*", 1).Activate();
Sys.Process("TestComplete").Window("TfrmTCMainForm", "*", 1).Minimize();
Sys.Process("TestComplete").Window("TfrmTCMainForm", "*", 1).Maximize();
you could do above at your threshold by checking Sys.Process("TestComplete").MemUsage
But for FireFox, to release the memory, we are not lucky. We have to use task manager to minimize and maximize it. In addition, we also have to turn on MSAA and hard code like below,
function _releaseFFMemory()
{
var p1;
var w1;
var w2;
p1 = Sys.Process("Explorer");
p1.Window("Shell_TrayWnd").Window("Button", "start").btn_Start.Click();
p1.Window("DV2ControlHost", "Start Menu").Window("DesktopSFTBarHost", "", 2).Window("SysListView32").mi_Run.Click();
p1.Window("#32770", "Run").Window("ComboBox").Window("Edit").Keys("taskmgr[Enter]");
p1 = Sys.Process("taskmgr");
w1 = p1.Window("#32770", "Windows Task Manager");
w2 = w1.Window("SysTabControl32", "Tab1");
w2.ClickTab("Applications");
w2 = w1.Window("#32770", "", 1).Window("SysListView32", "Tasks").list_item_Bookie_Home_Page_Mozilla_Firefox;
w2.ClickR();
p1.Window("#32768").mi_Minimize.Click();
w2.ClickR();
p1.Window("#32768").mi_Maximize.Click();
w1.title_bar.btn_Close.Click();
}
3. Use as little memory as possible
Tips from the same message board and my experiences,
1) Log message only when needed;
2) Turn on auto-save log: Options | Engines | Log and set the auto-save interval. This will flush the log to disk every x number of minutes. (better performance, not sure if help reduce memory usage)
3) Store screenshots in PNG format instead of BMP format.
4) Call the Log.LockEvents method to prevent TestComplete from posting event messages; And call Log.UnlockEvents when you need it. If you never care event messages even when you got warning or error, use Log.LockEvents(0).
No comments:
Post a Comment