1 #ifndef __ECS_MEM_USAGE_H__
2 #define __ECS_MEM_USAGE_H__
3 
4 /*============================================================================
5  * Base memory usage information (System and Library dependent)
6  *============================================================================*/
7 
8 /*
9   This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11   Copyright (C) 1998-2021 EDF S.A.
12 
13   This program is free software; you can redistribute it and/or modify it under
14   the terms of the GNU General Public License as published by the Free Software
15   Foundation; either version 2 of the License, or (at your option) any later
16   version.
17 
18   This program is distributed in the hope that it will be useful, but WITHOUT
19   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
21   details.
22 
23   You should have received a copy of the GNU General Public License along with
24   this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25   Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 #include "ecs_def.h"
31 
32 BEGIN_C_DECLS
33 
34 /*============================================================================
35  * Public types
36  *============================================================================*/
37 
38 /*============================================================================
39  * Public function prototypes
40  *============================================================================*/
41 
42 /*
43  * Initialize memory usage count depending on system.
44  *
45  * This functions checks if it has already been called, so
46  * it is safe to call more than once (though it is not
47  * thread-safe). Only the first call is effective.
48  */
49 
50 void
51 ecs_mem_usage_init(void);
52 
53 /*
54  * End memory usage count depending on system.
55  */
56 
57 void
58 ecs_mem_usage_end(void);
59 
60 /*
61  * Indicates if ecs_mem_usage_...() functions are initialized.
62  *
63  * returns:
64  *   1 if ecs_mem_usage_init has been called, 0 otherwise.
65  */
66 
67 int
68 ecs_mem_usage_initialized(void);
69 
70 /*
71  * Return current process memory use (in kB) depending on OS.
72  */
73 
74 size_t
75 ecs_mem_usage_pr_size(void);
76 
77 /*
78  * Return maximum process memory use (in kB) depending on OS.
79  *
80  * The returned value is the maximum returned by ecs_mem_usage_pr_size()
81  * during the program's lifetime. With memory allocations which return
82  * memory to the system (such as the GNU glibc on Linux systems),
83  * this value will be correct only if allocation is tracked. This should
84  * be the case if malloc hooks are used with the glibc allocation
85  * functions (ECS library's default configuration/installation option),
86  * but may give results lower than the true maximum in other cases.
87  */
88 
89 size_t
90 ecs_mem_usage_max_pr_size(void);
91 
92 /*----------------------------------------------------------------------------*/
93 
94 END_C_DECLS
95 
96 #endif /* __ECS_MEM_USAGE_H__ */
97