-1

Let's suppose that I want to know how much the variables on a program is using

s1 = "a long string"
s2 = "another long string"

I want to know if it possible to know the usage of RAM of both strings, is there a way?

Rodrigo
  • 135
  • 4
  • 45
  • 107
  • 1
    There are many answers out there if you search for, perhaps, _python memory usage_. Did you do any research? If so please outline in your question why your research led you to create a question here - what aspects of your question weren’t answered by the many resources out there? – DisappointedByUnaccountableMod Jun 14 '21 at 22:27

1 Answers1

0

I think sys.getsizeof will solve your problem. It will show size of your variable

from sys import getsizeof


data = "abcdefghij"
print(getsizeof(data))