MCPcopy Create free account
hub / github.com/pybind/pybind11 / gc

Method gc

tests/constructor_stats.h:113–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 static void gc() {
114 // Force garbage collection to ensure any pending destructors are invoked:
115#if defined(PYPY_VERSION)
116 PyObject *globals = PyEval_GetGlobals();
117 PyObject *result = PyRun_String("import gc\n"
118 "for i in range(2):\n"
119 " gc.collect()\n",
120 Py_file_input,
121 globals,
122 globals);
123 if (result == nullptr)
124 throw py::error_already_set();
125 Py_DECREF(result);
126#else
127 py::module_::import("gc").attr("collect")();
128#endif
129 }
130
131 int alive() {
132 gc();

Callers

nothing calls this directly

Calls 2

importFunction · 0.85
attrMethod · 0.80

Tested by

no test coverage detected