[PATCH V2] contrib: add a tool to detect cyclic references

Jun Wu quark at fb.com
Sun May 28 15:44:14 EDT 2017


Excerpts from Gregory Szorc's message of 2017-05-28 11:45:04 -0700:
> This seems reasonable. However, the tool as it stands isn't very usable
> because you must include it in sys.path and import it. I'd favor adding
> this as mercurial/leaks.py (or possibly adding to mercurial/profiling.py)
> so it is trivial to import and use the context manager. That, or refactor
> it as an extension and have the extension stash a reference to the context
> manager under mercurial.util.leakdetect (or similar) - again so it is easy
> to use.

I like the profiling.py idea. It's convenient to users. The only downside is
the detection scope is narrowed down so cycles in the ui object may be
missed. (in fact, OrderedDict was detected to create cycles). That said, I
think our main focus is repo and related complex objects so the
"maybeprofile" scope looks reasonable.

I'll move the code to profiling.py if there is no objection.

> [...] 
> Wouldn't this be semantically better if it restored the original settings
> stashed away from a gc.get_debug()?

Yes. This part could be cleaned up a bit.

> [...]


More information about the Mercurial-devel mailing list