Skip to content

Commit c091033

Browse files
authored
Ensure end-of-application object lifecycle is clean (#82)
1 parent dc2c5ad commit c091033

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • {{ cookiecutter.format }}/{{ cookiecutter.class_name }}

{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,14 @@ int main(int argc, char *argv[]) {
303303
ret = -7;
304304
}
305305
@finally {
306-
Py_Finalize();
306+
// Force a full GC pass while the interpreter is alive and a pool is
307+
// in place, so Python drops any ObjC references and anything
308+
// autoreleased lands in this pool.
309+
PyGC_Collect();
307310
}
308311
}
312+
// Autorelease pool is drained; any Python -dealloc has run against a live interpreter.
313+
Py_Finalize();
309314

310315
exit(ret);
311316
return ret;

0 commit comments

Comments
 (0)