Skip to content

Get being used memory size of an object

You can find the script to get which object how much memory resources use below.

import sys

#get size of a list
myList=["evrim","python","basic","scripts"]
print("Memory size of my list is ", sys.getsizeof(myList), " bytes")

#get size of a boolean 
myBoolean=True
print("Memory size of my list is ", sys.getsizeof(myBoolean), " bytes")

#get size of a dictionary
myDictionary={"key1":"1","key2":"2"}
print("Memory size of my list is ", sys.getsizeof(myDictionary), " bytes")
Published inPython

Be First to Comment

Leave a Reply

%d bloggers like this: