]> git.proxmox.com Git - mirror_ovs.git/blame - lib/memory.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / memory.h
CommitLineData
0d085684
BP
1/*
2 * Copyright (c) 2012 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef MEMORY_H
18#define MEMORY_H 1
19
20/* Memory usage monitor.
21 *
22 * This is intended to be called as part of a daemon's main loop. After some
23 * time to allow the daemon to allocate an initial memory usage, it logs some
24 * memory usage information (most of which must actually be provided by the
25 * client). At intervals, if the daemon's memory usage has grown
26 * significantly, it again logs information.
27 *
28 * The monitor also has a unixctl interface.
29 *
30 * Intended usage in the program's main loop is like this:
31 *
32 * for (;;) {
33 * memory_run();
34 * if (memory_should_report()) {
35 * struct simap usage;
36 *
37 * simap_init(&usage);
38 * ...fill in 'usage' with meaningful statistics...
39 * memory_report(&usage);
40 * simap_destroy(&usage);
41 * }
42 *
43 * ...
44 *
45 * memory_wait();
46 * poll_block();
47 * }
48 */
49
50#include <stdbool.h>
51
52struct simap;
53
54void memory_run(void);
55void memory_wait(void);
56
57bool memory_should_report(void);
58void memory_report(const struct simap *usage);
59
60#endif /* memory.h */