scalene
scalene copied to clipboard
SharedMemory leak
Profiling any program with multiprocessing.shared_memory.SharedMemory
results in
/usr/lib/python3.9/multiprocessing/resource_tracker.py:96: UserWarning: resource_tracker: process died unexpectedly, relaunching. Some resources might leak.
warnings.warn('resource_tracker: process died unexpectedly, '
To Reproduce
The following snippet produces the behaviour (with scalene snippet.py
)
from multiprocessing.shared_memory import SharedMemory
import time
try:
size = 2**20
shm = SharedMemory(create=True, size=size*8)
time.sleep(5)
finally:
shm.close()
shm.unlink()
In the actual application, shm
gets unassigned and results in an error somewhere down the line. But I don't quite know how to reproduce this.
UnboundLocalError: local variable 'shm' referenced before assignment
Environment:
- OS: Linux 5.10.13-arch1-1
- scalene==1.3.8
- Python 3.9.5