def heapyprofile(): # pip install guppy # [works on python 2.7, AFAIK] from guppy import hpy import gc hp = hpy() ast = parse_file('/tmp/197.c') gc.collect() h = hp.heap() print(h)