nibi79 / synologysurveillancestation

Synology Surveillancestation Binding
45 stars 5 forks source link

too many HTTPClient Threads #27

Closed dmcwhinnie closed 6 years ago

dmcwhinnie commented 6 years ago

Now that all my other issues have been resolved, my last issue is running out of threads/ memory. Ever since I installed this binding, my openhab environment runs out of memory after a few days. I was hoping the issue would fix itslef when you fixed the escaping URI issue. Unfortunately I am still having the issue. I am able to confirm the issue only happens when this binding is enabled.

I am monitoring the threads in Karaf with this command: shell:threads | grep HttpClient Before installing the latest release of the binding I have 25 minutes later it jumps to 153 then 281. and then keeps growing. A couple hours later there are 537. Eventually I get out of memory errors.

Attached is the output from the above command.

threads.txt

There's not much to go on from the output, not sure if you can add some debug logging...

Pavion commented 6 years ago

The binding needs several Jetty connections to handle different requests (events, snapshots, URI and so on). That would be the number after @ in "HttpClient@2285182-321". Jetty seems to create 8 different threads for every connection. I don't know why and it might be worth a look.

Anyway in a normal case, all threads (64 in my case, that is much) should be kept alive, their id constant and low: HttpClient@618278092-321

Sadly I can't reproduce your issue yet. It seems, your connections are reestablished but old threads are kept alive. Have you any timeout issues perhaps? Any binding related messages in your openhab.log? What are your refresh rates? Slow/fast Syno DS? A guess would be timeouts/connection lost issues with threads not shutting down properly.

Please provide some more info if possible. I'll check the code asap.

Thanks for helping out :)

dmcwhinnie commented 6 years ago

I think your comments have pointed me in the right direction. While looking for timeout or network errors, I found both my wired and wireless interfaces were enabled. I thought the wireless was disabled, but when looking at it, it was still on. Once I fixed that things look a lot better. I'll monitor for the next day...

dmcwhinnie commented 6 years ago

Going to close this issue. once I fixed my network interfaces the thread count has been solid over night, and not growing. I hope you didn't spend too much time looking for nothing.

Thanks for all your work on a great binding.