Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e13b1e

Browse files
committed
Py_Main(): When compiled by Insure (i.e. __INSURE__ is defined), call
the internal API function to release the interned strings as the very last thing before returning status. This aids in memory use debugging because it eliminates a huge source of noise from the reports. This is never called during normal (non-debugging) use because releasing the interned strings slows Python's shutdown and isn't necessary anyway because the system will always reclaim the memory.
1 parent a903ad9 commit 3e13b1e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Modules/main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,20 @@ Py_Main(int argc, char **argv)
301301
sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
302302

303303
Py_Finalize();
304+
305+
#ifdef __INSURE__
306+
/* Insure++ is a memory analysis tool that aids in discovering
307+
* memory leaks and other memory problems. On Python exit, the
308+
* interned string dictionary is flagged as being in use at exit
309+
* (which it is). Under normal circumstances, this is fine because
310+
* the memory will be automatically reclaimed by the system. Under
311+
* memory debugging, it's a huge source of useless noise, so we
312+
* trade off slower shutdown for less distraction in the memory
313+
* reports. -baw
314+
*/
315+
_Py_ReleaseInternedStrings();
316+
#endif /* __INSURE__ */
317+
304318
return sts;
305319
}
306320

0 commit comments

Comments
 (0)