I'm trying to learn multiprocessing and keep the memory usage low, so I'd like to check the size of my objects now and then.
I'm using a mp.managers.DictProxy to store results from multiple mp.Process() 'workers'(?) that put their results in an output mp.Queue().
I tried to see what size the dictionary got, but it kept returning 56 when tried to test it.
EDIT: after testing it in python 3.9.7 (same device) the output now magically is 48.
import sys
import multiprocessing as mp
if __name__ == '__main__': # needed if running on windows
manager = mp.Manager()
result_storage = manager.dict({k:k for k in range(100000)})
print(sys.getsizeof(result_storage))
# print USED to be 56 for me when i created this question
# print is now 48 consistently. same device. I didn't record the previous python version
# current python version is 3.9.7
print(sys.getsizeof(result_storage.copy()))
# prints 5242968
I've tried to print(sys.getsizeof(result_storage.copy())). That returned 52429765242968 Can I reliably use this to check the size or is there a better way? I've never used .copy() and I don't know what the impact is. The docs are beyond me.