Open Startonix opened 5 months ago
memory_management.py
import tracemalloc
tracemalloc.start()
data = [i for i in range(1000000)]
snapshot = tracemalloc.take_snapshot() top_stats = snapshot.statistics('lineno') print(top_stats[0])
memory_management.py
import tracemalloc
Start memory profiling
tracemalloc.start()
Code that uses memory
data = [i for i in range(1000000)]
Stop memory profiling and display results
snapshot = tracemalloc.take_snapshot() top_stats = snapshot.statistics('lineno') print(top_stats[0])