GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
memory_info.hpp
1 /**
2  * Copyright (c) 2009 Carnegie Mellon University.
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an "AS
13  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14  * express or implied. See the License for the specific language
15  * governing permissions and limitations under the License.
16  *
17  * For more about this software visit:
18  *
19  * http://www.graphlab.ml.cmu.edu
20  *
21  */
22 
23 #ifndef GRAPHLAB_MEMORY_INFO_HPP
24 #define GRAPHLAB_MEMORY_INFO_HPP
25 
26 namespace graphlab {
27  /**
28  * \internal \brief Memory info namespace contains functions used to
29  * compute memory usage.
30  *
31  * The memory info functions require TCMalloc to actually compute
32  * memory usage values. If TCMalloc is not present then calls to
33  * memory info will generate warnings and return the default value.
34  */
35  namespace memory_info {
36 
37  /**
38  * \interanl
39  *
40  * \brief Returns whether memory info reporting is
41  * available on this system (if memory_info was built with TCMalloc)
42  *
43  * @return if memory info is available on this system.
44  */
45  bool available();
46 
47  /**
48  * \internal
49  *
50  * \brief Estimates the total current size of the memory heap in
51  * bytes. If memory info is not available then 0 is returned.
52  *
53  * @return size of heap in bytes
54  */
55  size_t heap_bytes();
56 
57  /**
58  * \internal
59  *
60  * \brief Determines the total number of allocated bytes. If
61  * memory info is not available then 0 is returned.
62  *
63  * @return the total bytes allocated
64  */
65  size_t allocated_bytes();
66 
67  /**
68  * \internal
69  *
70  * \brief Print a memory usage summary prefixed by the string
71  * argument.
72  *
73  * @param [in] label the string to print before the memory usage summary.
74  */
75  void print_usage(const std::string& label = "");
76 
77  /**
78  * \internal
79  *
80  * \brief Log a memory usage summary prefixed by the string
81  * argument.
82  *
83  * @param [in] label the string to print before the memory usage summary.
84  */
85  void log_usage(const std::string& label = "");
86  } // end of namespace memory info
87 };
88 
89 #endif
90 
91