MeVisLab Toolbox Reference
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:
31 MLCurrentlyUsedMemoryTracker() : _memoryProfile(nullptr) { }
33 virtual size_t getCurrentlyUsedMemory() const = 0;
34
35private:
36 MLMemoryProfile* _memoryProfile;
37
38 friend class MLMemoryProfile;
39};
40
41
43{
44public:
45 MLMemoryProfile(MLCurrentlyUsedMemoryTracker* tracker, const std::string& shortDescription);
54 void reset();
55
56 const std::string& shortDescription() const { return _shortDescription; }
57
58 const std::string& description() const { return _description; }
59 void setDescription(const std::string& description_) { _description = description_; }
60
61private:
62 void removeCurrentlyUsedMemoryTracker() { _currentlyUsedMemoryTracker = nullptr; }
63
64private:
66 MLCurrentlyUsedMemoryTracker* _currentlyUsedMemoryTracker;
67 std::string _description;
68 std::string _shortDescription;
69
71};
72
73
74#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.