# Who use PYTHONDUMPREFS env var and combinerefs.py script?

**URL:** <https://discuss.python.org/t/who-use-pythondumprefs-env-var-and-combinerefs-py-script/19920>\
**Category:** Core Development\
**Created:** [October 12, 2022, 4:20pm UTC](https://discuss.python.org/t/who-use-pythondumprefs-env-var-and-combinerefs-py-script/19920 "2022-10-12T16:20:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [October 12, 2022, 4:20pm UTC](https://discuss.python.org/t/who-use-pythondumprefs-env-var-and-combinerefs-py-script/19920/1 "2022-10-12T16:20:43Z")

</div>

Hi,

I’m working on [removing outdated example scripts in Tools/scripts/](https://github.com/python/cpython/issues/97669) and I found a `combinerefs.py` script in `Tools/scripts/`. I used PYTHONDUMPREFS a few days, but I wasn’t aware of this script (!) and I was never able to extract anything useful from this very verbose output. Usually, I found my issues with bisection, reading source code and tools others than “trace refs”.

Since Python 3.8, Python built in debug mode no longer defines the `Py_TRACE_REFS` macro which adds the double linked list to `PyObject`. It’s now a configure option (`./configure --with-trace-refs`).

I’m now curious if someone still uses the PYTHONDUMPREFS env var and can get anything useful from this output? In this case, please tell me, it may help me 🙂

At least, `sys.getobjects()` (also enabled by `Py_TRACE_REFS` macro) still looks interesting to debug, since it contains Python objects not tracked by the GC (not listed by `gc.get_objects()`).

For me, the main question is: would you be ok with removing `Tools/scripts/combinerefs.py`?

Should we even deprecate and/or remove PYTHONDUMPREFS env var? I’m fine with keeping it if someone finds it useful.

The “Trace refs” debug feature is currently documented at: [3. Configure Python — Python 3.12.0a0 documentation](https://docs.python.org/dev/using/configure.html#cmdoption-with-trace-refs) (yep, the doc is very short…). There is a “Trace Refs” buildbot making sure that it’s still possible to build Python with this debug option 😉

Victor

---

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/guido/32/21_2.png) [@guido](https://discuss.python.org/u/guido)\
**Post date:** [October 12, 2022, 7:06pm UTC](https://discuss.python.org/t/who-use-pythondumprefs-env-var-and-combinerefs-py-script/19920/2 "2022-10-12T19:06:08Z")

</div>

You’d have to ask Tim Peters, who wrote the script. 🙂 But I’m sure he’s okay with letting go of it, he’s moved on to other topics.

I’m also okay, plus the script is already preserved in my old-demos repo.

---

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [October 12, 2022, 9:06pm UTC](https://discuss.python.org/t/who-use-pythondumprefs-env-var-and-combinerefs-py-script/19920/3 "2022-10-12T21:06:39Z")

</div>

cc @tim.one

---

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [October 17, 2022, 10:17am UTC](https://discuss.python.org/t/who-use-pythondumprefs-env-var-and-combinerefs-py-script/19920/4 "2022-10-17T10:17:33Z")

</div>

Maybe PYTHONDUMPREFS and PYTHONDUMPREFSFILE environment variables should just be removed if no one is using them. There are now plently of ways to detect memory leaks in Python, and Python 3.12 is now way better to release memory at exit: [Mailman 3 Python no longer leaks memory at exit - Python-Dev - python.org](https://mail.python.org/archives/list/python-dev@python.org/thread/E4C6TDNVDPDNNP73HTGHN5W42LGAE22F/)
