@@ -79,20 +79,35 @@ extern (C)
7979
8080 void gc_term ()
8181 {
82- // NOTE: There may be daemons threads still running when this routine is
83- // called. If so, cleaning memory out from under then is a good
84- // way to make them crash horribly. This probably doesn't matter
85- // much since the app is supposed to be shutting down anyway, but
86- // I'm disabling cleanup for now until I can think about it some
87- // more.
88- //
89- // NOTE: Due to popular demand, this has been re-enabled. It still has
90- // the problems mentioned above though, so I guess we'll see.
91-
9282 if (isInstanceInit)
9383 {
94- instance.collectNoStack(); // not really a 'collect all' -- still scans
95- // static data area, roots, and ranges.
84+ switch (config.cleanup)
85+ {
86+ default :
87+ import core.stdc.stdio : fprintf, stderr;
88+ fprintf(stderr, " Unknown GC cleanup method, please recheck ('%.*s').\n " ,
89+ cast (int )config.cleanup.length, config.cleanup.ptr);
90+ break ;
91+ case " none" :
92+ break ;
93+ case " collect" :
94+ // NOTE: There may be daemons threads still running when this routine is
95+ // called. If so, cleaning memory out from under then is a good
96+ // way to make them crash horribly. This probably doesn't matter
97+ // much since the app is supposed to be shutting down anyway, but
98+ // I'm disabling cleanup for now until I can think about it some
99+ // more.
100+ //
101+ // NOTE: Due to popular demand, this has been re-enabled. It still has
102+ // the problems mentioned above though, so I guess we'll see.
103+
104+ instance.collectNoStack(); // not really a 'collect all' -- still scans
105+ // static data area, roots, and ranges.
106+ break ;
107+ case " finalize" :
108+ instance.runFinalizers((cast (ubyte * )null )[0 .. size_t .max]);
109+ break ;
110+ }
96111
97112 ManualGC.finalize(instance);
98113 ConservativeGC.finalize(instance);
0 commit comments