static void Job47(Args _args)
{
str path,stx;
TreeNodeIterator iter;
TreeNode treeNode, treeNodeToRelease;
Map dictMenuDisplay;
FormName formName;
MenuItemName menuItemName;
container conMenu;
int i,n;
;
for (n=1;n<=100;n++)
{
info(strfmt("iter:%1",n));
path ="Menu Items\\Display";
dictMenuDisplay = new Map(Types::String,Types::Container);
treenode = Treenode::findNode(path);
iter = treenode.AOTiterator();
treenode = iter.next();
while (treenode)
{
formName = treenode.AOTgetProperty("Object");
menuItemName = treenode.AOTname();
if (dictMenuDisplay.exists(formName))
{
conMenu = dictMenuDisplay.lookup(formName);
conMenu = conIns(conMenu,conlen(conMenu)+1,menuItemName);
dictMenuDisplay.insert(formName,conMenu);
}
else
dictMenuDisplay.insert(formName,[menuItemName]);
// treenode = iter.next();
if(treeNodeToRelease && SysTreeNode::isApplObject(treeNode))
{
treeNodeToRelease.treeNodeRelease();
treeNodeToRelease=null;
}
if(SysTreeNode::isApplObject(treeNode))
{
treeNodeToRelease=treeNode;
}
treeNode=iter.next();
}
}
}
I get the error "overflow in internal run stack",the code runs till 86th iteration correctly, help...
The code:
should be replaced by:
The release of the object should not depend on the next object.
or maybe this is enough (supplanting Jay's solution):
The kernel doesn't immediately garbage collect TreeNode objects. Once you are done with a treenode for an application object and all it's children, you need to call
TreeNode.treeNodeRelease()
, followed bytreeNode=null;
to let the garbage collector clean up.Quote from the manual:
Also you have at least 85 references of the treeNodeToRelease (and treeNode!) floating around -> call treeNodeToRelease.treeNodeRelease() at the end of your outer loop.