MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlMemoryProfile.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13// Class for collecting memory profiling information.
14
15#ifndef ML_MEMORY_PROFILE_H
16#define ML_MEMORY_PROFILE_H
17
19#include <string>
20
21
22typedef size_t MLProfilingMemoryType;
23
24
25class MLMemoryProfile;
26
27
29{
30public:
32 : _memoryProfile(nullptr)
33 {}
35 virtual size_t getCurrentlyUsedMemory() const = 0;
36
37private:
38 MLMemoryProfile* _memoryProfile;
39
40 friend class MLMemoryProfile;
41};
42
43
45{
46public:
47 MLMemoryProfile(MLCurrentlyUsedMemoryTracker* tracker, const std::string& shortDescription);
56 void reset();
57
58 const std::string& shortDescription() const
59 {
60 return _shortDescription;
61 }
62
63 const std::string& description() const
64 {
65 return _description;
66 }
67 void setDescription(const std::string& description_)
68 {
69 _description = description_;
70 }
71
72private:
73 void removeCurrentlyUsedMemoryTracker()
74 {
75 _currentlyUsedMemoryTracker = nullptr;
76 }
77
78private:
80 MLCurrentlyUsedMemoryTracker* _currentlyUsedMemoryTracker;
81 std::string _description;
82 std::string _shortDescription;
83
85};
86
87
88#endif // _ML_MEMORY_PROFILE_H_
virtual size_t getCurrentlyUsedMemory() const =0
const std::string & description() const
MLProfilingMemoryType getMemory() const
Returns the used memory since instantiation/last reset.
void addMemory(MLProfilingMemoryType memory)
Adds allocated memory.
void setDescription(const std::string &description_)
void reset()
Resets the profile.
MLProfilingMemoryType getCurrentlyUsedMemory() const
Returns the currently used memory in bytes.
MLMemoryProfile(MLCurrentlyUsedMemoryTracker *tracker, const std::string &shortDescription)
const std::string & shortDescription() const
size_t MLProfilingMemoryType
#define MLPROFILINGMANAGER_EXPORT
Target mlrange_cast(Source arg)
Generic version of checked ML casts.