HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/exabgp/vendoring/gcdump.py
# http://teethgrinder.co.uk/perm.php?a=Python-memory-leak-detector
import gc
import inspect


def dump():
    # force collection
    print("\nCollecting GARBAGE:")
    gc.collect()
    # prove they have been collected
    print("\nCollecting GARBAGE:")
    gc.collect()

    print("\nGARBAGE OBJECTS:")
    for x in gc.garbage:
        s = str(x)
        if len(s) > 80:
            s = "%s..." % s[:80]

        print("::", s)
        print("		type:", type(x))
        print("   referrers:", len(gc.get_referrers(x)))
        try:
            print("	is class:", inspect.isclass(type(x)))
            print("	  module:", inspect.getmodule(x))

            lines, line_num = inspect.getsourcelines(type(x))
            print("	line num:", line_num)
            for l in lines:
                print("		line:", l.rstrip("\n"))
        except Exception:
            pass

        print()