1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_MEMORY_MEMMGR_MEMORY_LEVEL_CONSTANTS_H
17 #define OHOS_MEMORY_MEMMGR_MEMORY_LEVEL_CONSTANTS_H
18 
19 #include <string>
20 #include <sys/types.h>
21 
22 namespace OHOS {
23 namespace Memory {
24 // default value of the purgeable memory level
25 constexpr unsigned int MEMORY_LEVEL_PURGEABLE_DEFAULT = 1024; /* 1024M */
26 // default value of the moderate memory level
27 constexpr unsigned int MEMORY_LEVEL_MODERATE_DEFAULT = 800; /* 800M */
28 // default value of the low memory level
29 constexpr unsigned int MEMORY_LEVEL_LOW_DEFAULT = 700; /* 700M */
30 // default value of the critical memory level
31 constexpr unsigned int MEMORY_LEVEL_CRITICAL_DEFAULT = 600; /* 600M */
32 
33 enum class SystemMemoryLevel {
34     UNKNOWN = 0,
35     MEMORY_LEVEL_PURGEABLE = 1,
36     MEMORY_LEVEL_MODERATE = 2,
37     MEMORY_LEVEL_LOW = 3,
38     MEMORY_LEVEL_CRITICAL = 4,
39 };
40 
41 enum class MemorySource {
42     UNKNOWN = 0,
43     PSI_MEMORY = 1,
44     KSWAPD = 2,
45     MANUAL_DUMP = 3,
46 };
47 
48 struct SystemMemoryInfo {
49     MemorySource source;
50     SystemMemoryLevel level;
51 };
52 
53 typedef struct SystemMemoryInfo SystemMemoryInfo;
54 } // namespace Memory
55 } // namespace OHOS
56 #endif // OHOS_MEMORY_MEMMGR_MEMORY_LEVEL_CONSTANTS_H
57