Answer the question
In order to leave comments, you need to log in
Why is it better not to use static constructors?
I heard that it is better to do without static constructors and destructors in the code. Especially if the project is big. What is the reason for this and is the advice correct?
Thanks
Answer the question
In order to leave comments, you need to log in
Static constructs (eg " static const Foo & F = * new Foo ( ) ; " ) can leak memory. If LLVM is built as a dynamic link library, it can be reloaded an unlimited number of times, and one instance of 'Foo' will be created in each iteration of the load.
Also, if LLVM is built on Windows MSVC 2013 (which supports LLVM), then the static layer creation function is thread-unsafe (safe since MSVC 2015). Some variants of LTO will create a thread for each object.
Well, here they also write about the speed of launching the application
llvm.org/docs/CodingStandards.html#do-not-use-stat...
In short, the user will wait a long time before the windows appear and the buttons can be pressed. It is better to create singletons in the background while the interface pretends that the application is fully loaded and ready to go.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question