Currently I'm using singleton pattern for certain global objects in my application (Qt application for Symbian environment). However, because of some problems ([C++ checking singleton pointers](https://stackoverflow.com/questions/3147375/c-checking-singleton-pointers/3147806#3147806)) it looks like that I have to change the logic.

I have 3 classes (logger, settings and container for some temp data) that I need to access via multiple different objects. Currently they are all created using singleton pattern. The logger basically is just one public method Log() with some internal logic when the settings and container have multiple get/set methods with some additional logic (e.g. QFileSystemWatcher). In addition, logger and settings have some cross-reference (e.g. logger needs some settings and settings logs errors).

Currently everything is "working fine", but there is still some problems that should be taken care of and it seems like they are not easy to implement for the singletons (possible memory leaks/null pointers). Now I have two different ways to handle this:

1. Create global objects (e.g. extern Logger log;) and initialize them on application startup.
2. Create objects in my main object and pass them to the children as a reference.

How I have few questions related to these:

**Case 1.** 

* Is it better to use stack or heap?
* I'm going to declare those objects in some globals.h header using extern keyword. Is it ok?
* I think in this case I have to remove that 2-way reference (settings needs logger and vice versa.)?

**Case 2.**

* Should the objects be created in stack or heap in my main object (e.g. Logger \*log = new Logger() vs Logger log;)
* Long reference chains do not look nice (e.g. if i have to pass the object over multiple childrens).
* What about in children? 

	1. If I pass a pointer to the children like this (I don't want to copy it, just use the "reference"): Children(Logger \*log) : m\_Log(log) what happens when the children is deleted? Should I set the local pointer m\_Log to NULL or?
	2. If I use stack I'll send reference to the child (Children(Logger &log) : m\_Log(log)) where m\_Log is a reference variable (Logger& m\_Log;) right?
* What should I note in terms of Qt memory management in this case?

**Case 3.** 
Continue with singleton and initialize singleton objects during the startup (that would solve the null pointers). Then the only problem would possible memory leaks. My implementation follows [this](http://www.yolinux.com/TUTORIALS/C++Singleton.html) example. Is there a possible memory leak when I'm accessing the class using. What about singleton destruction?
 #define LOG Logger::Instance()->Log

Thanks for reading.