Use the psutil util is a simple way to measure memory usage in Python scripts.
import os, psutil
def log_memory():
process = psutil.Process(os.getpid())
mem = process.memory_info().rss / (1024 * 1024)
print(f"Memory usage: {mem:.2f} MB")
Just invoke log_memory() where you need. rss is the "non swapped physical memory a process has used".
Split array into n chunk size
chunk_size = 2
arr = [1,2,3,4,5,6,7,8,9,10]
chunks = [arr[i:i + chunk_size] for i in range(0, len(arr), chunk_size)]
# [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]