-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmemwatch.h
62 lines (40 loc) · 1.18 KB
/
memwatch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* \file
*
* \brief Total program memory watcher
* \author Benjamin Pritchard ([email protected])
*/
#ifndef PULSAR_GUARD_MEMWATCH__MEMWATCH_H_
#define PULSAR_GUARD_MEMWATCH__MEMWATCH_H_
#include <stddef.h> /* for size_t */
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Pointer to a callback that gets called when we are over the limit
*
* Arguments given to the callback (in order): Currently allocated, new allocation, memory limit
*/
typedef void (*mallocfailptr)(size_t, size_t, size_t);
/*! \brief Get how memory is currently used (in bytes)
*/
size_t memwatch_query_allocated_memory(void);
/*! \brief Set the maximum amount of memory (in bytes)
*
* If an allocation will go above this limit, the callback
* (set via memwatch_set_malloc_fail_hook) will be called.
*
* \return The previous limit
*/
size_t memwatch_set_max_memory(size_t max);
/*! \brief Get the current maximum memory to be used (in bytes)
*/
size_t memwatch_get_max_memory(void);
/*! \brief Set the callback function
*/
void memwatch_set_malloc_fail_hook(mallocfailptr mhook);
/* \brief See if memwatch was loaded and is running
*/
int memwatch_running(void);
#ifdef __cplusplus
}
#endif
#endif