Hi,

we have a number of singletons (the most basic design pattern I guess)
around the code, and for most, memory is or was not released at game
exit. This shouldn't matter, for the libc will free the process memory
itself, but it's troublesome to seek particular leaks when there are all
of those.

I've been introducing a CleanUp() static method in those I found, so as
to delete the singleton of the considered class. This has so far removed
about 1MB of leaks on program exit, but a big number of them remains.

As you can guess, it's been a bit bothersome, and I'm wondering whether
we would not better use instead a base Singleton class to automate this.

This one seems rather nice (at least it confirms my belief it should be
a template):
http://www.gamedev.net/reference/programming/features/enginuity2/page5.asp

However, there are a number of problems or still bothersome things:
1) we would still have to call the CleanUp method manually
2) a static method can't be virtual and I still can't fathom all the
consequences of overriding GetInstance in case of particular behavior
(for instance Network or Game)

For 1), I think there should maybe be a factory or whatever, holding a
list of all the created instances, and providing some method to destroy
all instances. I'm hitting here my limited practice of pattern designs
(and I'm still not ready to be publicly shamed on comp.lang.c++ :)

For 2), I guess the simplest would be to always let the derived class
implement it if there's a real problem here.

Any idea?

Best regards,
-- 
Kurosu

_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à