Find cause of freezing Apps

In a really big project, developed on OS X Yosemite and remote debugging on Windows 7 (Parallels 10 VM), i have now the issue that my App is freezing and the Windows OS is terminating it because of this none responsive state, how can i find the cause of the issue?

This project is performing many tasks in Threads, Timers and so in the “background”. There are 2 areas in which the app sometimes (not always) freezes. These areas are within the Main Window, made of containers, listboxes, buttons, threads, …
I have checks for errors wherever i “think” an error could occur. I also have a routine for unhandled exceptions in the App object, which worked fine whenever i needed it. But this unhandled exception routine was not needed since months now…

How can i track down the location in my code where the app freezes if the debugger is not catching it?

That can be a nightmare to debug. Maybe set various system.debug code in all threads etc… ?

perhaps the profiler can help … find where it is spending “infinite” time…
perhaps not, if the loop negates the profiler from updating the output of course.

Thank you @Christoph De Vocht & @Dave S
I will try both approaches.

I also expect a “Bughunting Nightmare”, but these are the times that make coding even more fun. (As long as the Bugs are found and fixed.) :wink:

Had this issue. Fixed it by adding Sleeps in the thread inside loops.

Thank you @Ashot Khachatryan i will keep this in mind! :slight_smile:

Threads CAN yield at loop boundaries, but that doesn’t mean that they WILL. It is possible for a thread to monopolize the cpu and cause the app to appear to be hung. That behavior may differ on each OS.