Mantid
Loading...
Searching...
No Matches
Memory.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidKernel/DllConfig.h"
10
11#include <iosfwd>
12#include <mutex>
13#include <string>
14
15namespace Mantid {
16namespace Kernel {
17
20namespace MemoryOptions {
22MANTID_KERNEL_DLL void initAllocatorOptions();
23} // namespace MemoryOptions
24
28class MANTID_KERNEL_DLL MemoryStats {
29public:
31 void update();
32 void ignoreFields(const MemoryStatsIgnore);
33 std::string vmUsageStr() const;
34 std::string resUsageStr() const;
35 std::string totalMemStr() const;
36 std::string availMemStr() const;
37 std::size_t totalMem() const;
38 std::size_t availMem() const;
39 std::size_t residentMem() const;
40 std::size_t virtualMem() const;
41 std::size_t reservedMem() const;
42 std::size_t getCurrentRSS() const;
43 std::size_t getPeakRSS() const;
44 double getFreeRatio() const;
45
46private:
47 void process_mem_system(size_t &sys_avail, size_t &sys_total);
49 std::size_t vm_usage;
50 std::size_t res_usage;
51 std::size_t total_memory;
52 std::size_t avail_memory;
53 friend MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &out, const MemoryStats &stats);
55 static std::mutex mutexMemory;
56};
57
58MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &out, const MemoryStats &stats);
59
61template <typename TYPE> std::string memToString(const TYPE mem_in_kiB);
62
63} // namespace Kernel
64} // namespace Mantid
std::ostream & operator<<(std::ostream &out, const MantidQt::MantidWidgets::IndexType< i > &index)
Definition: IndexTypes.h:103
This class is responsible for memory statistics.
Definition: Memory.h:28
std::size_t avail_memory
Available memory of system in kiB.
Definition: Memory.h:52
static std::mutex mutexMemory
Mutex to avoid simultaneous access to memory resources.
Definition: Memory.h:55
std::size_t res_usage
Resident memory usage by process in kiB.
Definition: Memory.h:50
MemoryStatsIgnore ignore
What fields to ignore.
Definition: Memory.h:48
std::size_t vm_usage
Virtual memory usage by process in kiB.
Definition: Memory.h:49
std::size_t total_memory
Total physical memory of system in kiB.
Definition: Memory.h:51
MANTID_KERNEL_DLL void initAllocatorOptions()
Initialize platform-dependent options for memory management.
Definition: Memory.cpp:282
MANTID_KERNEL_DLL std::ostream & operator<<(std::ostream &, CPUTimer &)
Convenience function to provide for easier debug printing.
Definition: CPUTimer.cpp:86
MemoryStatsIgnore
Enmuerate the ignored memory fields.
Definition: Memory.h:19
@ MEMORY_STATS_IGNORE_NONE
Definition: Memory.h:19
@ MEMORY_STATS_IGNORE_SYSTEM
Definition: Memory.h:19
@ MEMORY_STATS_IGNORE_PROCESS
Definition: Memory.h:19
std::string memToString(const TYPE mem_in_kiB)
Convert a (number) for memory in kiB to a string with proper units.
Definition: Memory.cpp:42
Helper class which provides the Collimation Length for SANS instruments.