Game works perfect but sometimes freezes without errors

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MadDevil57

Memory usage always rising a bit and at some point just crashes without error in godot(like if i just closed the game). Also sometimes it just crashes.
In profiler everything seems to be as usual.
It’s always happening right at the start of a new thread to calculate enemy ai that takes around 300 ms to calculate.
Also sometimes after that, game launches super slow. It takes arround 1-5 minutes.
I suppose it’s because of infinite loop, or because of poor optimization. Also it can be problem in my pc as well.
It would be great if i could at first understand where is the problem and how i can recreate it all the times. Right now it more luck based.