Advertisement
kopyl

Untitled

Apr 10th, 2021
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import os, psutil
  2.  
  3. def get_allocated_megabytes_per_app():
  4.     pid_of_app = os.getpid()
  5.     app_process = psutil.Process(pid_of_app)
  6.     allocated_bytes = app_process.memory_info().rss
  7.     allocated_megabytes = allocated_bytes / 1_000_000
  8.     allocated_megabytes = round(allocated_megabytes, 3)
  9.     return allocated_megabytes
  10.  
  11.  
  12. class Test:
  13.  
  14.     @staticmethod
  15.     def static():
  16.         lst_2 = ["Hello world"*10000 for x in range(10000)]
  17.  
  18.  
  19. Test.static()
  20.  
  21. print(get_allocated_megabytes_per_app())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement