18 #if defined(__APPLE__)    19 #include <mach/task.h>    20 #include <mach/clock.h>    21 #include <mach/mach.h>    22 #include <mach/vm_page_size.h>    23 #include <sys/types.h>    24 #include <sys/sysctl.h>    25 #include <sys/vmmeter.h>    26 #elif defined(__WIN32__)    29 #include <processthreadsapi.h>    30 #include <sysinfoapi.h>    32 #include <sys/sysinfo.h>    41 #ifdef LIBMESH_HAVE_MPI    43   char mpi_name[MPI_MAX_PROCESSOR_NAME];
    44   MPI_Get_processor_name(mpi_name, &mpi_namelen);
    54   return MooseEnum(
"bytes kibibytes mebibytes gibibytes kilobytes megabytes gigabytes",
    61 #if defined(__APPLE__)    63   size_t length = 
sizeof(hwmem_size);
    64   if (0 <= sysctlbyname(
"hw.memsize", &hwmem_size, &length, NULL, 0))
    66 #elif defined(__WIN32__)    68   if (GetPhysicallyInstalledSystemMemory(&mem_kb))
    71   struct sysinfo si_data;
    72   if (!sysinfo(&si_data))
    73     return si_data.totalram * si_data.mem_unit;
    85     index_page_faults = 8,
    86     index_virtual_size = 19,
    87     index_resident_size = 20,
    92   std::ifstream stat_stream(
"/proc/self/stat", std::ios_base::in);
    93   std::array<std::size_t, 21> val;
    99     std::string pid, comm, state;
   100     stat_stream >> pid >> comm >> state;
   104     while (!stat_stream.eof() && i < val.size())
   106       stat_stream >> val[i];
   119     val[index_resident_size] *= sysconf(_SC_PAGE_SIZE);
   125     auto pid = GetCurrentProcessId();
   126     auto hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
   128     PROCESS_MEMORY_COUNTERS pmc;
   129     if (NULL == hProcess || !GetProcessMemoryInfo(hProcess, &pmc, 
sizeof(pmc)))
   134       val[index_page_faults] = pmc.PageFaultCount;
   135       val[index_virtual_size] = pmc.WorkingSetSize + pmc.PagefileUsage;
   136       val[index_resident_size] = pmc.WorkingSetSize;
   144 #if defined(__APPLE__)   145     struct task_basic_info t_info;
   146     mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
   147     if (KERN_SUCCESS == task_info(mach_task_self(),
   149                                   reinterpret_cast<task_info_t>(&t_info),
   153       val[index_virtual_size] = t_info.virtual_size;   
   154       val[index_resident_size] = t_info.resident_size; 
   157       mooseDoOnce(::
mooseWarning(
"task_info call failed, memory usage numbers will be incorrect"));
   179   unsigned int nunit = 
static_cast<unsigned int>(unit);
   183     return bytes >> (nunit * 10);
 
std::string getMPIProcessorName()
get the MPI hostname 
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
std::size_t _physical_memory
std::size_t _virtual_memory
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args. 
MooseEnum getMemUnitsEnum()
get the moose enum for the mem_unit_prefix parameter 
std::size_t getTotalRAM()
get the total amount of physical RAM available 
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix