How to trace Runtime error?

Hello Everyone,

I need some help about Runtime Error shown in attached picture.

It is happening from time to time, sometimes 2 times at day, sometimes once in 4-5 days. How can I trace where this problem is exactly appearing?
For few reasons, I am still using XOJO 2017R3. This problem is happening in 3 applications, but I cannot find where it is starting.

Thank you very much

Xojo fails to create a new thread for some reason. e.g. you create hundreds of them and eventually the OS will deny you create another one.

In one of the applications I have 4 threads on UI, where 3 of them are regular XOJO threads, and 4th one is instance of the Task class, which has implemented UpdateUI event. I downloaded that Task class from one of the threads here few years ago.
Can you tell me how to avoid creating threads, since I am using only 4 from UI?

Well, I just guessed the thread creation failed.

e.g. CreateThread may fail.

So are you sure you only create 4 of them?
Or is your app running out of memory?

Well, I do not have any code which is creating additional threads. All threads are added to Window by Drag&Drop. I am a little bit suspicious about this Task class, if there could be some kind of problem.

I was monitoring memory usage, and there was not problem about it. But, I got insane number of Page faults and Handles at the time of crash. Bellow is screenshot of Task manager.

Added Runtime code to see where are all these handles coming from, and most of them are Delegate.