Hi,
I have a windows application(UI) and a windows service.This windows application continuously calls methods in the windows service and the service does its work accordingly.The communication between UI and service is achieved by .Net remoting.
As per my application requirement, the UI should call service methods in different durations(for ex. every 1 minute) and this process should continue for 3 days(may be greater than this).
But UI is able to call methods of service for ~10-12 hrs and then UI hangs up. After I coming to office in next morning "client not working" message box is displayed with "Debug" and "Close" buttons .Once I clicked on debug which is just displaying "StackOverflowException" and no other details.
Then I started removing unnecessary objects in my code and disposing objects.Then also no use.
Please give your valuable suggestions.
Added below sample code part on 17-Nov-2014:
Adding my hunch for this problem below, please review and update my guess is correct or not.
public void XXX()
{
try
{
TreeList selectedTreeList = (TreeList)oTabPage.Controls[0];
foreach (TreeListNode scenarioNode in selectedTreeList.Nodes)
{
if(special condition)
{
XXX();
break;
}
Thread.Sleep(60000);
}
}
catch(Exception ex)
{
}
}
Here is my suspicion:
In main method XXX(), we are calling XXX(). Like that we call XXX() in another XXX() and it goes on.This process is infinite.So each time when we call XXX(),
new variables are created and some space is allotted to them in RAM.
Note:In each XXX() method, it will take 5 minutes to enter into special condition and then calls XXX().(Assume that after 5 iterations in
foreach it enters into special condition)
Shortly, I can say this whole thing as
never ending recursion.
So scope of each XXX() method never ends.Hence garbage collector will not try to clear memory.So that total RAM will be filled and get StackOverflowException and then hang.
Please give your inputs.
Thanks and Regards,
Anil