armi.bookkeeping.memoryProfiler module
Interface to help diagnose memory issues during debugging/development.
There are many approaches to memory profiling.
1. You can ask psutil for the memory used by the process from an OS perspective. This is great for top-down analysis. This module provides printouts that show info from every process running. This is very fast.
2. You can use gc.get_objects()
to list all objects that the garbage collector is tracking. If you want, you
can filter it down and get the counts and sizes of objects of interest (e.g. all armi objects).
This module has tools to do all of this. It should help you out.
NOTE: Psutil and sys.getsizeof will certainly report slightly different results.
NOTE: In Windows, it seems that even if your garbage is collected, Windows does not de-allocate all the memory. So if you are a worker and you just got a 2GB reactor but then deleted it, Windows will keep you at 2GB for a while.
See also
https
//pythonhosted.org/psutil/
https
//docs.python.org/3/library/gc.html#gc.garbage
- armi.bookkeeping.memoryProfiler.describeInterfaces(cs)[source]
Function for exposing interface(s) to other code.
- armi.bookkeeping.memoryProfiler.getTotalJobMemory(nTasks, cpusPerTask)[source]
Function to calculate the total memory of a job. This is a constant during a simulation.
- armi.bookkeeping.memoryProfiler.getCurrentMemoryUsage()[source]
This scavenges the memory profiler in ARMI to get the current memory usage.
- class armi.bookkeeping.memoryProfiler.MemoryProfiler(r, cs)[source]
Bases:
Interface
- name: Optional[str] = 'memoryProfiler'
The name of the interface. This is undefined for the base class, and must be overridden by any concrete class that extends this one.
- displayMemoryUsage(timeDescription)[source]
Print out some information to stdout about the memory usage of ARMI.
Useful when the debugMem setting is set to True.
Turn these on as appropriate to find all your problems.
- class armi.bookkeeping.memoryProfiler.KlassCounter(reportSize)[source]
Bases:
object
Helper class, to allow us to count instances of various classes in the Python standard library garbage collector (gc).
Counting can be done simply, or by memory footprint.
- class armi.bookkeeping.memoryProfiler.ProfileMemoryUsageAction(timeDescription)[source]
Bases:
MpiAction