471,056 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,056 software developers and data experts.

atexit() in a DLL

I am trying to get the PhoenixSingleton pattern example found in
"Modern C++ Design" to run. I am using the Singleton in a DLL.
I don't deliver any references of the Singleton to outside-DLL callers
so that's not my problem. The singleton works perfectly, the only
problem is.. after reviving the singleton, it doesn't get destroyed,
meaning the destructor is not called.
I checked that by using the DLL in a simple test application and
sending messages to std::cout in every member function.
Every single function is called in the correct order as soon as the DLL
is unloaded, the Singleton gets destroyed for the first time, it gets
revived.. but the destructor doesn't get called a second time.
Somehow I suspect atexit() doesn't work here.

I am using Visual Studio 2005 and I already tried using _onexit() but
that thing doesn't seem to accept member function pointers at least
I always get conversion errors there.

Any ideas or insights on how to get this to work?
The object that I put into the singleton is just a simple logging class
that I use in my application to write simple statements to a textfile
and that holds only a fstream object, so when the application is
terminated there shouldn't be any ressource leaks even if the destructor
isn't called but being the perfectionist I am I'd like this to work as
it is supposed to.

Thanks in advance

A. Schmitt
Apr 5 '07 #1
0 1127

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Serve Laurijssen | last post: by
8 posts views Thread by JKop | last post: by
2 posts views Thread by Steve Lambert | last post: by
7 posts views Thread by David Rushby | last post: by
1 post views Thread by Parapura Rajkumar | last post: by
16 posts views Thread by Laurent Deniau | last post: by
2 posts views Thread by Christopher Pisz | last post: by
18 posts views Thread by lak | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.