Kurosu a écrit :
> Kurosu a écrit :
>> 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 a side note, forcing object destruction underlined some code errors,
> for instance in the Font destructor, which probably (not yet confirmed)
> caused problems such as bug #10866.
> 
> Because the process memory will be released anyway and destructor calls
> on end of game mostly take time for nothing, maybe we should put such
> calls behing a #ifdef DEBUG.

There's another way : a master object takes ownership of the singletons.

Basically :

int
main (...)
{
  Master master;

  master.assume_ownership_of (new singleton1);
  ...
  master.assume_ownership_of (new singletonN);

  return 0; // getting out releases the master, hence all singletons
}

Snark

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

Répondre à