Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4AllocatorList Class Reference

#include <G4AllocatorList.hh>

Public Member Functions

 ~G4AllocatorList ()
 
void Register (G4AllocatorBase *)
 
void Destroy (G4int nStat=0, G4int verboseLevel=0)
 
void Report (G4bool itemize=true) const
 
std::size_t Size () const
 

Static Public Member Functions

static G4AllocatorListGetAllocatorList ()
 
static G4AllocatorListGetAllocatorListIfExist ()
 

Detailed Description

Definition at line 43 of file G4AllocatorList.hh.

Constructor & Destructor Documentation

◆ ~G4AllocatorList()

G4AllocatorList::~G4AllocatorList ( )

Definition at line 56 of file G4AllocatorList.cc.

56{ fAllocatorList = nullptr; }

Member Function Documentation

◆ Destroy()

void G4AllocatorList::Destroy ( G4int nStat = 0,
G4int verboseLevel = 0 )

Definition at line 65 of file G4AllocatorList.cc.

66{
67 auto itr = fList.cbegin();
68 G4int i = 0, j = 0;
69 G4double mem = 0, tmem = 0;
70 if(verboseLevel > 0)
71 {
72 G4cout << "================== Deleting memory pools ==================="
73 << G4endl;
74 }
75 for(; itr != fList.cend(); ++itr)
76 {
77 mem = (*itr)->GetAllocatedSize();
78 if(i < nStat)
79 {
80 ++i;
81 tmem += mem;
82 (*itr)->ResetStorage();
83 continue;
84 }
85 ++j;
86 tmem += mem;
87 if(verboseLevel > 1)
88 {
89 G4cout << "Pool ID '" << (*itr)->GetPoolType()
90 << "', size : " << std::setprecision(3) << mem / 1048576
91 << std::setprecision(6) << " MB" << G4endl;
92 }
93 (*itr)->ResetStorage();
94 delete *itr;
95 }
96 if(verboseLevel > 0)
97 {
98 G4cout << "Number of memory pools allocated: " << Size()
99 << "; of which, static: " << i << G4endl;
100 G4cout << "Dynamic pools deleted: " << j
101 << " / Total memory freed: " << std::setprecision(2)
102 << tmem / 1048576 << std::setprecision(6) << " MB" << G4endl;
103 G4cout << "============================================================"
104 << G4endl;
105 }
106 fList.clear();
107}
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
std::size_t Size() const

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetAllocatorList()

G4AllocatorList * G4AllocatorList::GetAllocatorList ( )
static

Definition at line 40 of file G4AllocatorList.cc.

41{
42 if(fAllocatorList == nullptr)
43 {
44 fAllocatorList = new G4AllocatorList;
45 }
46 return fAllocatorList;
47}

Referenced by G4AllocatorBase::G4AllocatorBase().

◆ GetAllocatorListIfExist()

G4AllocatorList * G4AllocatorList::GetAllocatorListIfExist ( )
static

◆ Register()

void G4AllocatorList::Register ( G4AllocatorBase * alloc)

Definition at line 59 of file G4AllocatorList.cc.

60{
61 fList.push_back(alloc);
62}

Referenced by G4AllocatorBase::G4AllocatorBase().

◆ Report()

void G4AllocatorList::Report ( G4bool itemize = true) const

Definition at line 109 of file G4AllocatorList.cc.

110{
111 auto itr = fList.cbegin();
112 G4int j = 0;
113 G4double mem = 0, tmem = 0;
114 G4cout << "================== Current memory pools ==================="
115 << G4endl;
116 for(; itr != fList.cend(); ++itr)
117 {
118 mem = (*itr)->GetAllocatedSize();
119 ++j;
120 tmem += mem;
121 if(itemize)
122 {
123 G4cout << "Pool ID '" << (*itr)->GetPoolType()
124 << "', size : " << std::setprecision(3) << mem / 1048576
125 << std::setprecision(6) << " MB" << G4endl;
126 }
127 }
128 G4cout << "Number of memory pools allocated: " << Size() << G4endl;
129 G4cout << "Dynamic pools : " << j
130 << " / Total memory : " << std::setprecision(2)
131 << tmem / 1048576 << std::setprecision(6) << " MB" << G4endl;
132 G4cout << "============================================================"
133 << G4endl;
134}

◆ Size()

std::size_t G4AllocatorList::Size ( ) const
inline

Definition at line 64 of file G4AllocatorList.hh.

65{
66 return fList.size();
67}

Referenced by Destroy(), G4RunManagerKernel::G4RunManagerKernel(), and Report().


The documentation for this class was generated from the following files: