Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MemoryInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MemoryInfo.h (C) 2000-2015 */
9/* */
10/* Collecteur d'informations sur l'usage mémoire. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_MEMORYINFO_H
13#define ARCANE_UTILS_MEMORYINFO_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/IMemoryInfo.h"
18#include "arcane/utils/TraceInfo.h"
19
20#include <map>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25ARCANE_BEGIN_NAMESPACE
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
33class ARCANE_UTILS_EXPORT MemoryInfo
34: public IMemoryInfo
35{
36 public:
37 class MemoryInfoSorter;
38 class TracePrinter;
39 public:
40
41 MemoryInfo();
42 virtual ~MemoryInfo();
43
44 public:
45
46 virtual void createOwner(const void* owner,const TraceInfo& trace_info);
47
48 virtual void setOwner(const void* owner,const TraceInfo& new_info);
49
50 virtual void removeOwner(const void* owner);
51
52 public:
53
54 virtual void addInfo(const void* owner,const void* ptr,Int64 size);
55
56 virtual void addInfo(const void* owner,const void* ptr,Int64 size,const void* old_ptr);
57
58 virtual void removeInfo(const void* owner,const void* ptr,bool can_fail);
59
60 virtual void changeOwner(const void* new_owner,const void* ptr);
61
62 virtual void printInfos(std::ostream& ostr);
63
64 virtual void setIteration(Integer iteration)
65 { m_iteration = iteration; }
66 virtual void printAllocatedMemory(std::ostream& ostr,Integer iteration);
67 virtual void setTraceMng(ITraceMng* trace);
68
69 public:
70
71 virtual void beginCollect();
72 virtual void endCollect();
73 virtual bool isCollecting() const;
74
75 public:
76
77 virtual void setKeepStackTrace(bool is_active) { m_is_stack_trace_active = is_active; }
78 virtual bool keepStackTrace() const { return m_is_stack_trace_active; }
79
80 virtual void setStackTraceMinAllocSize(Int64 alloc_size) { m_info_big_alloc = alloc_size; }
81 virtual Int64 stackTraceMinAllocSize() const { return m_info_big_alloc; }
82
84
85 virtual Int64 nbAllocation() const { return m_alloc_id; }
86
87 public:
88
89 void checkMemory(const void* owner,Int64 size);
90
91 private:
92
93 typedef std::map<const void*,MemoryInfoChunk> MemoryInfoMap;
94 typedef std::map<const void*,TraceInfo> MemoryTraceInfoMap;
95
96 MemoryInfoMap m_infos;
97 MemoryTraceInfoMap m_owner_infos;
98
99 Int64 m_alloc_id;
100 Int64 m_max_allocated;
101 Int64 m_current_allocated;
102 Int64 m_biggest_allocated;
103 Int64 m_info_big_alloc;
104 Int64 m_info_biggest_minimal;
105 Int64 m_info_peak_minimal;
106 Integer m_iteration;
107 ITraceMng* m_trace;
108 bool m_display_max_alloc;
109 bool m_in_display;
110 bool m_is_first_collect;
111 bool m_is_stack_trace_active;
112
113 private:
114
115 void _removeOwner(const void* owner);
116 void _addMemory(const void* owner,Int64 size,const String& stack_value);
117 void _removeMemory(const void* owner,Int64 size);
118 TraceInfo* _getTraceInfo(const void* owner);
119 void _printInfos(std::ostream& ostr);
120};
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125extern "C++" ARCANE_UTILS_EXPORT MemoryInfo*
126arcaneGlobalTrueMemoryInfo();
127extern "C++" ARCANE_UTILS_EXPORT void
128arcaneInitCheckMemory();
129extern "C++" ARCANE_UTILS_EXPORT void
130arcaneExitCheckMemory();
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
135ARCANE_END_NAMESPACE
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140#endif
141
Interface d'un collecteur d'informations sur l'usage mémoire.
Definition IMemoryInfo.h:60
virtual void removeOwner(const void *owner)=0
Supprime la référence sur owner.
virtual void createOwner(const void *owner, const TraceInfo &trace_info)=0
Crée une référence sur owner avec les infos de trace trace_info.
virtual void setTraceMng(ITraceMng *msg)=0
Positionne le ITraceMng pour les messages.
virtual void visitAllocatedBlocks(IFunctorWithArgumentT< const MemoryInfoChunk & > *functor) const =0
Visiteur sur l'ensemble des blocs alloués.
virtual void setOwner(const void *owner, const TraceInfo &new_info)=0
Modifie les infos de la référence owner.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Collecteur d'informations sur l'usage mémoire.
Definition MemoryInfo.h:35
virtual Int64 stackTraceMinAllocSize() const
Taille minimale des allocations dont on trace la pile d'appel.
Definition MemoryInfo.h:81
virtual bool keepStackTrace() const
Indique si la sauvegarde de la pile d'appel est activée.
Definition MemoryInfo.h:78
virtual void setStackTraceMinAllocSize(Int64 alloc_size)
Positionne la taille minimale des allocations dont on trace la pile d'appel.
Definition MemoryInfo.h:80
virtual void setIteration(Integer iteration)
Positionne le numéro de l'itération courante.
Definition MemoryInfo.h:64
virtual void setKeepStackTrace(bool is_active)
Indique si on active la sauvegarde de la pile d'appel.
Definition MemoryInfo.h:77
Interface du gestionnaire de traces.