Open-Systems-Pharmacology / PK-Sim

PK-Sim® is a comprehensive software tool for whole-body physiologically based pharmacokinetic modeling
Other
106 stars 50 forks source link

Too many handles #1713

Open Yuri05 opened 3 years ago

Yuri05 commented 3 years ago

Sometimes it happens that PK-Sim (or MoBi) exceeds default windows limits. E.g. with a project (which I cannot attach in public): when opening a PI (which refers to 19 Simulations and 320 observed data sets), PK-Sim crashes without any error message (just disappears after some time). In the task manager you can see that the user object handles reaches 10000 (Windows default for the user objects quota). After that PK-Sim stops working. In windows error reporting you can find the info that handle cannot be created:

Application: PKSim.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ComponentModel.Win32Exception
   at System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams)
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Control.CreateGraphicsInternal()
   at System.Windows.Forms.ThreadExceptionDialog..ctor(System.Exception)
   at System.Windows.Forms.Application+ThreadContext.OnThreadException(System.Exception)
   at System.Windows.Forms.Control.WndProcException(System.Exception)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)

The solution for this is: increase max. number of Windows handles

After that it was possible to open the PI (which used almost 14000 User Handles then) grafik

Two question I have: 1) (How) can we investigate and maybe reduce the number of used handles? 2) More important: how can we provide an information for the user that application is going to crash due to reaching the maximum of ... ? At the moment the user has absolutely no clue what happens (and I was only able to understand what happens because the project was available)

Yuri05 commented 3 years ago

@msevestre @abdelr @georgeDaskalakis @TWendl FYI

Yuri05 commented 3 years ago

One possibility would be to set the handle quotas to maximum with the OSP Suite Setup. However this would then always require computer restart. Also not sure if such an action would not be recognized as "suspicios" by e.g. virus scanners or other protection software...

PavelBal commented 3 years ago

This must be related to https://github.com/Open-Systems-Pharmacology/MoBi/issues/469

Yuri05 commented 2 years ago

Maybe we could also somehow use "Resource-Exhaustion-Detector" on Windows? Recently we had a crash, and in the event logs we found messages like below (during PI MoBi consumed both physical and virtual memory to the very limit - almost 80GB). In Windows Error logs we found some messages like below, which were written shortly before the crash. grafik

msevestre commented 2 years ago

80BG....what are we doing wrong

Yuri05 commented 2 years ago

what are we doing wrong

Maybe nothing... it was a multisimulation (9 simulations) multiple start values (80 start values) optimization on 15 or 16 cores. So 5 GB per core with 9 running simulations. MAybe we have some memory leaks indeed, but hard to say.