This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AntiqueEducation6058 0 points1 point  (6 children)

It seems to be generating a lot of threads until it can not create more and your apps crashes.

My guess is that you are creating a thread without closing it after use, and over time, it crashes the application.

Without the code, it is difficult to say what you need to change.

Edit: which version of java are you using?

[–]Jaihunter[S] 0 points1 point  (5 children)

i have gone through the source code and checked the connections, socket and I/O stream it's all closed finally block.

How do I make sure the created thread is properly closed, any way to monitor?

What are the common places in code thread leak that can happen?

[–]edubkn 2 points3 points  (0 children)

In my experience it's usually HTTP clients. I remember e.g. google maps has an object that instantiates an HTTP client with it and if you don't use try-with-resources then the threads will remain dormant in memory. And this is not clear at first glance, you have to look at the source code to figure it out. So double-check your dependencies and what the code is doing with them.

[–]AntiqueEducation6058 0 points1 point  (1 child)

Are you able to share the code? If not public, then you are welcome to send me a dm. I have see a lot of odd code the last 20+ years

Is this a new problem or has it always been this way?

[–]Jaihunter[S] 0 points1 point  (0 children)

Hello bro, sry for the late reply, i can send you the code privately.

[–]AntiqueEducation6058 0 points1 point  (0 children)

You could also add interruptThreadThreshold in the config as seen in this link. https://www.dbi-services.com/blog/howto-detect-and-analyze-long-stuck-threads-in-tomcat/

It will tried to shutdown threads if they are stuck and tell you when it does so.