Re: C++ static destructor guaranteed to be called?



Paul J. Lucas wrote:
	If I'm writing some native code using the C++ JNI API and my
	C++ code has a static object with a destructor, is it
	guaranteed that said destructor will be called before the
	process terminates (as it would be if this were plain C++)?

	I would think the answer would be "yes" since this is outside
	the purview of the JVM.

This behaviour is mandated by the C++ standard. The only platform I am aware of where it doesn't happen according to specification is Novell Netware when you have a C++ NLM that terminates abnormally, and that information is some years old.
.




Relevant Pages

  • Re: C++ static destructor guaranteed to be called?
    ... E.J. Pitt wrote: ... C++ code has a static object with a destructor, is it guaranteed that said destructor will be called before the ... the purview of the JVM. ...
    (comp.lang.java.programmer)
  • static object destructor not getting called
    ... I have a static object in a file. ... For some reasons its destructor is not getting called, ... this object is supposed to free up the memory, ...
    (microsoft.public.vc.mfc)
  • Re: Single instance issue
    ...     CSingleton ... So that Visual C++ 6.0 compilation error is correct ... If it were a static object, the destructor must be called! ...
    (microsoft.public.vc.language)