Skip to content

Commit

Permalink
add get_memory_usage_objects
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Sep 11, 2024
1 parent eac58ef commit ab09e4b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mirgecom/simutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,19 @@ def configurate(config_key, config_object=None, default_value=None):
return default_value


def get_memory_usage_objects() -> Dict[str, int]:
"""Return the memory usage of all Python objects, in bytes, sorted by descending size."""
import sys
v = globals().copy() | locals().copy()
d = {}
for k, v in v.items():
d[k] = sys.getsizeof(v)
res = {}
for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True):
res[k] = v
return res


def compare_files_vtu(
first_file: str,
second_file: str,
Expand Down

0 comments on commit ab09e4b

Please sign in to comment.