Not sure if this applies to your specific situation but
In your program if you are using multithreading/executors which don't terminate or hang or tasks, you can end up with orphaned threads. You could check if you are using these and enforce a limit on how many can be created, forcing older inactive threads to be closed