I read a lot of articles about singles, but no one touches on my problem. I understand that Singletons should be used only when necessary, and in my game I use them for certain parts of the engine.
However, I initially had my singletones as pointers like this:
static MapReader* Instance()
{
if (instance == 0)
{
instance = new MapReader();
return instance;
}
return instance;
}
However, it always seemed to me that using too many pointers is bad for leaks, and I prefer not to use them if I can help (or smart pointers if I need to). So I changed all my singletones to these links:
static MapReader& Instance()
{
static MapReader instance;
return instance;
}
However, now I notice that my game lags behind at odd times and then speeds up like FPS is a little awkward.
, ; ? ? ?