ok please bear with me on this one
For my game I've been building my own GUI library (mostly because I wanted to learn how and partly because the ones available for Allegro 5 were either overkill or not good enough)
I was lazy when I started this and used regular old raw pointers, but as my game itself has become more complex I started noticing memory leaks so I just went through the (painful) experiance of changing all my pointers to std::shared_ptrs
[Side-Note to self and to others do it right the first time, that was a pain]
Anyway the memory leak is gone now which is great, but my frame-rate dropped from the 60 FPS I was throttling too down to 10 FPS (sometimes dipping to 2 FPS)
Now I expected sharted pointers to be a bit slower, but thats crazy. I have to assume that it is me using them wrong.
As an example here is how I use this...
GUIElement is my superclass that all the widgets base themselves on and then I have a vector to hold them all...
std::vector<std::shared_ptr<GUIElement>> UIelements;
std::vector<std::shared_ptr<GUIElement>>::iterator UIiter;
When I want to put something on the screen I do something like this...
std::shared_ptr<GUIButton> button1(new GUIButton(g_width/2-125,g_height/2-125,0,250,100,"(L)oad Default Scenario",updatestate));
button1->SetShortCut(ALLEGRO_KEY_L);
button1->SetZOrder(1);
UIelements.push_back(button1);
Now I may do that 2000 times on a single screen for all the various elements on the map (which worked fine as "raw" pointers)
In my main game loop I have this...
///in the game logic update part of the loop....
for(UIiter=UIelements.begin();UIiter!=UIelements.end();++UIiter)
(*UIiter)->Update();
//in the render part of the game loop
for(UIiter=UIelements.begin();UIiter!=UIelements.end();++UIiter)
(*UIiter)->Render();
Anyway anything obvious that I"m doing wrong here, or some thoughts on what to look into?