Atelier des rouesLab FR
Objects/Documentation

allocations32.py

Separating retained allocations · allocations32.py

Download ↓
"""Live retained traced allocations by source line, in fresh processes at each read."""
import json,platform,subprocess,sys,tracemalloc
from pathlib import Path
from collecte24 import measure

def snapshot(cap,mode,read):
    p=Path(__file__).with_name('collecte24.py').resolve()
    lines=p.read_text(encoding='utf8').splitlines()
    groups={}
    def observe(i):
        if i!=read:return
        snap=tracemalloc.take_snapshot()
        for st in snap.statistics('lineno'):
            frame=st.traceback[0];label='other'
            if Path(frame.filename)==p:
                line=lines[frame.lineno-1].strip()

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.