Explicit Call to spdlog::shutdown Required? #2685
-
Hi, I'm not currently explicitly calling Our application is large, with a horrendous mass of threads! We've always had problems closing and have long suspected we've got deadlocks, or some such, when trying to terminate all the threads. Recently I've got the feeling that it has got worse and that feeling coincides with my attempts to introduce spdlog. I've created spdlogger instances with async sinks and configured timed log flush, which I believe means I'm asking spdlog to create yet more threads. I looked at our main and considered adding Should I add We use spdlog as a shared library. The application runs on Windows and Linux. Clearly I could, and should, investigated what's preventing our app closing correctly but it isn't consistent and doesn't cause our customers much pain hence there are always more important things to do. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Yes. And However, I will tell you that it is important to properly clean up all threads of your application. Even if you don't call |
Beta Was this translation helpful? Give feedback.
-
U can try |
Beta Was this translation helpful? Give feedback.
Yes.
spdlog creates a thread pool for the async logger.
It is recommended to call
spdlog::shutdown()
as it destroys the thread pool.And
spdlog::shutdown()
calls sink's flush operation. This operation is important on Windows because Windows discards the data remaining in the I/O buffer aftermain()
.However, I will tell you that it is important to properly clean up all threads of your application.
This is because
std::thread
callsstd::thread::terminate()
in the destructor unlessstd::thread::join()
orstd::thread::detach()
is cal…