473,695 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

atexit() in a DLL

I am trying to get the PhoenixSingleto n 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 1220

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6014
by: Serve Laurijssen | last post by:
Does the C++ standard say whether destructors are called before or after "atexit" functions are called. Or is nothing said about that?
8
2831
by: JKop | last post by:
Let's say that when your program ends (no matter how) that you want a certain block of code to be executed at the end. Here's the code: std::cout << "The program will now end.\n"; std::system("PAUSE"); I've looked up "exit", "atexit" and "abort". Up until this point I simply would've done:
2
2072
by: Steve Lambert | last post by:
Hi, Is it possible for the functions registered with atexit() to have access to parameter to exit i.e EXIT_SUCCESS or EXIT_FAILURE? I'd like to register a set of routines to be executed on exit(EXIT_FAILURE) and a different set of routines on exit(EXIT_SUCCESS). Any way of doing this?
7
6068
by: David Rushby | last post by:
Consider the following program (underscores are used to force indentation): ------------------------------------------------ import atexit, threading, time def atExitFunc(): ____print 'atExitFunc called.' atexit.register(atExitFunc)
5
1886
by: prouleau001 | last post by:
Hi all! Since that the decorator syntax is upon us, I think it would be good if atexit.register() was returning the function passed as argument. This simple change to the library would solve a problem with the use of atexit.register as a decorator (and I can't think of any use case where this change would break any code). I describe the problem in the following text.
1
1973
by: Parapura Rajkumar | last post by:
hey all I was wondering if there a way to override atexit in my own module. The problem I was facing is that the VS2005 seems to ignore functions registered with atexit once it starts processing atexit registered functions. ( Mainly static object destructors ) What I would like to achieve is have my custom atexit that calls the standard atexit. But when dlls are being unloaded and VS2005 is processing registered atexit functions, I...
20
6010
by: Aek | last post by:
We recently moved our large codebase over from VS7 to 8 and found that we now get access violations in atexit calls at shutdown when debugging the application in VS2005. This occurs in static members / singletons (especially meyer type singletons) which use locally declared static variables. These variables are normally cleaned up automatically at shutdown of the application by registering with the atexit. I break point the destructor on...
16
3608
by: Laurent Deniau | last post by:
I would like to know if the use of the pointer ref in the function cleanup() below is valid or if something in the norm prevents this kind of cross-reference during exit(). I haven't seen anything in the norm against this, I mean an as-if rule saying "atexit registered functions are executed as-if they were called from main", making val out of scope at this point. a+, ld. #include <stdio.h>
2
4753
by: Christopher Pisz | last post by:
I am attempting to write a "Phoenix Singleton" using the book "Modern C++ Design" by Alexandrescu I do not understand his use of... #ifndef ATEXIT_FIXED std::atexit(Kill); #endif ....in the source below. I understand the problem, but not how a preprocessor directive will fix it. He says the standard is unclear about the situation
18
2721
by: lak | last post by:
I am studying the Advanced programming in the unix environment. There they says that we can register upto 32 functions with atexit(). Why that is limited to 32 functions? can any one tell the answer?
0
8565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9113
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8977
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5837
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4339
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2997
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.