Skip to content

Commit

Permalink
utils: Add log_memory_usage
Browse files Browse the repository at this point in the history
The function can be used for debugging memory usage by placing it
around suspicious piece of code.
  • Loading branch information
mkasenberg committed Jan 31, 2025
1 parent 55d9932 commit 7ce8e07
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions autopts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ def exit_if_admin():
sys.exit("Administrator rights are not required to run this script!")


def log_memory_usage():
process = psutil.Process(os.getpid())
mem_info = process.memory_info()

mem_usage = mem_info.rss / (1024 ** 2)
logging.debug(f"Memory usage: {mem_usage:.2f} MB")


def main():
"""Main."""

Expand Down

0 comments on commit 7ce8e07

Please sign in to comment.