i have written a script to collect menu paths from a menu in a silverlight application. The menus are shown\added on demand to the menu tree (when someone hovers or click the parent menu, only then sub menus are loading to the DOM tree), so i need to refresh the DOM tree at regular interval. One more thing to note that the size of DOM also getting increased as we going on opening new menus and their sub menus.
Below is the code i am using to collect the menu paths.
Its working fine for me when we have small menus (let say less then 500 menu paths under the main menu). But when we have larger menus (say more then 500 to 5000 menu paths under the main menu) ,
In that case in the start of the menu scraping it works fine, but as we progressing its performance getting worsts (as DOM tree size also increasing simultaneously) and at a certain point it throwing me : "OutOfMemoryException" in System.dll at line no - 41 (menuListItem.Refresh()).
I tried to copy the Visual Tree at the time of exception and found that the size of visual tree text is of 2.5MB file.
Note : I am runiing it on a dedicated automated system with 16GB of memory.so i have enough memory for this. This script is a part of our regression solution, so we have to run it over on any system whether large or small. i want to make it such that it can work on a large menu as well.
Please look into this ASAP.
Thanks & Regards