Get the App
SLTechnology News&Howtos  ›  Development  › 

How does python check memory footprint

Shulou Source: shulou.com Published: 2022-06-01 04:01:10 10月01日 Update

This article mainly introduces how to check the memory footprint of python, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Check memory footprint

In Python, we can use the built-in module sys to check the memory consumed by each variable. As you can see from the following code, strings of different lengths consume different amounts of memory.

Import sysa, b, Love d = "I", "Love", "Python", 2020print (sys.getsizeof (a)) # 50print (sys.getsizeof (b)) # 53print (sys.getsizeof (c)) # 55print (sys.getsizeof (d)) # 28 Thank you for reading this article carefully. I hope the article "python how to check memory footprint" shared by the editor will be helpful to you. At the same time, I hope you will support me and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Memory check article different code value interest variable at the same time character string more friends module knowledge ribbon industry information information channel length Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Microsoft Shulou Technology vpn