Great library so far, but I noticed you use raw pointers a lot in various classes. almost all cone() functions create new pointers (which is okay if managed properly), but then almost every setter function calls clone() without freeing the previous pointer. so if we set_XXX() multiple times we will end up with many loose pointers AKA a memory leak.
try putting this in your main loop and watch the memory go:
for (int i = 0; i < 1000; i++)
{
scene.set_controller(controller);
}
Yes, we would never want to set the controller every frame, but if I wanted to switch between two controllers it would leak memory every time.
I'd suggest using shared pointers, deleting the old pointer before setting the new one, or not clone at all and instead use the passed in parameter.
Great library so far, but I noticed you use raw pointers a lot in various classes. almost all
cone()
functions create new pointers (which is okay if managed properly), but then almost every setter function callsclone()
without freeing the previous pointer. so if weset_XXX()
multiple times we will end up with many loose pointers AKA a memory leak.try putting this in your main loop and watch the memory go:
Yes, we would never want to set the controller every frame, but if I wanted to switch between two controllers it would leak memory every time.
I'd suggest using shared pointers, deleting the old pointer before setting the new one, or not clone at all and instead use the passed in parameter.