• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
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 #pragma once
18 
19 #include <string.h>
20 #include <sys/types.h>
21 #include <unistd.h>
22 
23 #include <string>
24 #include <vector>
25 
26 namespace android {
27 namespace meminfo {
28 
29 struct MemUsage {
30     uint64_t vss;
31     uint64_t rss;
32     uint64_t pss;
33     uint64_t uss;
34 
35     uint64_t swap;
36     uint64_t swap_pss;
37 
38     uint64_t private_clean;
39     uint64_t private_dirty;
40     uint64_t shared_clean;
41     uint64_t shared_dirty;
42 
MemUsageMemUsage43     MemUsage()
44         : vss(0),
45           rss(0),
46           pss(0),
47           uss(0),
48           swap(0),
49           swap_pss(0),
50           private_clean(0),
51           private_dirty(0),
52           shared_clean(0),
53           shared_dirty(0) {}
54 
55     ~MemUsage() = default;
56 
clearMemUsage57     void clear() {
58         vss = rss = pss = uss = swap = swap_pss = 0;
59         private_clean = private_dirty = shared_clean = shared_dirty = 0;
60     }
61 };
62 
63 struct Vma {
64     uint64_t start;
65     uint64_t end;
66     uint64_t offset;
67     uint16_t flags;
68     std::string name;
69 
VmaVma70     Vma() : start(0), end(0), offset(0), flags(0), name("") {}
VmaVma71     Vma(uint64_t s, uint64_t e, uint64_t off, uint16_t f, const char* n)
72         : start(s), end(e), offset(off), flags(f), name(n) {}
73     ~Vma() = default;
74 
clearVma75     void clear() { memset(&usage, 0, sizeof(usage)); }
76 
77     // Memory usage of this mapping.
78     MemUsage usage;
79 };
80 
81 }  // namespace meminfo
82 }  // namespace android
83