<div dir="ltr"><div dir="ltr">On Mon, Apr 15, 2019 at 4:06 PM Nathaniel Smith <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 15, 2019, 15:27 Michael Sullivan <<a href="mailto:sully@msully.net" rel="noreferrer" target="_blank">sully@msully.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">> The main question is if anyone ever used Py_TRACE_REFS? Does someone<br><div>> use sys.getobjects() or PYTHONDUMPREFS environment variable?</div><div><br></div><div>I used sys.getobjects() today to track down a memory leak in the mypyc-compiled version of mypy. <br></div><div><br></div><div>We were leaking memory badly but no sign of the leak was showing up in mypy's gc.get_objects() based profiler. Using a debug build and switching to sys.getobjects() showed that we were badly leaking int objects. A quick inspection of the values in question (large and random looking) suggested we were leaking hash values, and that quickly pointed me to <a href="https://github.com/mypyc/mypyc/pull/562" rel="noreferrer noreferrer" target="_blank">https://github.com/mypyc/mypyc/pull/562</a>.</div><div><br></div><div>I don't have any strong feelings about whether to keep it in the "default" debug build, though. I was using a debug build that I built myself with every debug feature that seemed potentially useful.</div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">This is mostly to satisfy my curiosity, so feel free to ignore: did you try using address sanitizer or valgrind?</div><div dir="auto"><br></div></div></blockquote><div><div class="gmail_quote">I didn't, mostly because I assume that valgrind wouldn't play well with cpython. (I've never used address sanitizer.)</div><div class="gmail_quote"><br></div><div class="gmail_quote">I was curious, so I went back and tried it out.<br></div><div class="gmail_quote">It
 turned out to not seem to need that much fiddling to get to work. It 
slows things down a *lot* and produced 17,000 "loss records", though, so
 maybe I don't have it working right. At a glance the records did not 
shed any light.</div><div class="gmail_quote"><br></div><div class="gmail_quote">I'd
 definitely believe that valgrind is up to the task of debugging this, 
but my initial take with it shed much less light than my 
sys.getobjects() approach. (Though note that my sys.getobjects() 
approach was slotting it into an existing python memory profiler we had 
hacked up, so...)</div><div class="gmail_quote"><br></div><div class="gmail_quote">-sully</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"></div><div dir="auto">-n</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
</blockquote></div></div></div>
</blockquote></div></div>