• Home
Name Date Size #Lines LOC

..--

figures/12-May-2024-

libdmabufheap/12-May-2024-546374

libmeminfo/12-May-2024-330236

libpurgeablemem/12-May-2024-5,2523,785

purgeable_builder/12-May-2024-330251

LICENSED12-May-20249.9 KiB178150

OAT.xmlD12-May-20241.1 KiB2810

README.mdD12-May-20243.9 KiB7953

README_ZH.mdD12-May-20244.2 KiB8761

bundle.jsonD12-May-20242.7 KiB9291

purgeable_mem_config.gniD12-May-2024643 1715

README.md

1# The Part of Memory Base Libraries
2
3-   [Introduction](#section_introduction)
4-   [Architecture](#section_architecture)
5-   [Directory Structure](#section_catalogue)
6-   [Memory Base Libraries](#section_libraries)
7    -   [libdmabufheap system library](#section_libdmabufheap)
8    -   [libmeminfo system library (planning)](#section_libmeminfo)
9    -   [libmemleak system library (planning)](#section_libmemleak)
10    -   [libpurgeable system library](#section_libpurgeable)
11    -   [libspeculative system library (planning)](#section_libspeculative)
12-   [Usage Guidelines](#section_usage)
13-   [Repositories Involved](#section_projects)
14
15## Introduction<a name="section_introduction"></a>
16
17The part of *Memory base libraries* belongs to the subsystem named *Utils Subsystem*. It provides the system library for upper-layer services to operate memory, ensuring the stability of upper-layer services.
18
19## Architecture<a name="section_architecture"></a>
20
21**Figure  1** Memory Base Libraries architecture
22
23![](figures/en-us_image_fwk.png)
24
25| Memory Base Libraries | User                  |
26| -------------- | -------------------------- |
27| libdmabufheap  | multimedia service      |
28| libmeminfo     | memory manager service         |
29| libmemleak     | memory manager service         |
30| libpurgeable   | graphic service  |
31| libspeculative | system service (planning) |
32
33## Directory Structure<a name="section_catalogue"></a>
34
35```
36/utils/memory
37├── libdmabufheap           # DMA (Direct Memory Access) memory allocation system library
38│   ├── include             # DMA memory allocation system library header directory
39│   ├── src                 # DMA memory allocation system library source directory
40│   └── test                # DMA memory allocation system library usecase directory
41├── libmeminfo              # Memory footprint management library
42├── libmemleak              # Memory leak detection library
43├── libpurgeable            # Purgeable memory management library
44└── libspeculative          # Speculative memory management library
45```
46
47## Memory Base Libraries<a name="section_libraries"></a>
48
49*Memory base libraries* is a component of the system library that integrates memory operations and manages them in a unified manner.
50
51### libdmabufheap system library<a name="section_libdmabufheap"></a>
52
53The memory system library provides interfaces for the multimedia service to allocate and share shared memory. By allocating and sharing memory between hardware devices and user space, zero-copy memory between devices and processes is implemented to improve execution efficiency.
54
55### libmeminfo system library (planning)<a name="section_libmeminfo"></a>
56
57It provides interfaces for memory usage queries. It is used for memory footprint query, low memory killing and other scenarios.
58
59### libmemleak system library (planning)<a name="section_libmemleak"></a>
60
61It cooperates with malloc_debug to detect memory leaks of native heap.
62
63### libpurgeable system library<a name="section_libpurgeable"></a>
64
65It provides a dedicated memory request interface for discardable type memory for multimedia related services. When the available memory of the system is insufficient, the purgeable memory is directly discarded by the system to achieve rapid memory recovery. When the application is used again, the purgeable memory that has been freed can be rebuilt.
66
67### libspeculative system library (planning)<a name="section_libspeculative"></a>
68
69It provides management interfaces for speculative-type memory. It is mainly used by system services for data pre-loading.
70
71## Usage Guidelines<a name="section_usage"></a>
72
73System developers can add or remove this part by configuring the product definition JSON file under **/productdefine/common/products** to enable or disable this part:
74
75` "commonlibrary:memory_utils":{} `
76
77## Repositories Involved<a name="section_projects"></a>
78
79[utils](https://gitee.com/openharmony/utils)

README_ZH.md

1# 内存基础库部件
2
3- [内存基础库部件](#内存基础库部件)
4  - [简介<a name="section_introduction"></a>](#简介)
5  - [部件架构<a name="section_architecture"></a>](#部件架构)
6  - [目录<a name="section_catalogue"></a>](#目录)
7  - [内存基础库<a name="section_libraries"></a>](#内存基础库)
8    - [libdmabufheap系统库<a name="section_libdmabufheap"></a>](#libdmabufheap系统库)
9    - [libmeminfo系统库(规划中)<a name="section_libmeminfo"></a>](#libmeminfo系统库规划中)
10    - [libmemleak系统库(规划中)<a name="section_libmemleak"></a>](#libmemleak系统库规划中)
11    - [libpurgeable系统库<a name="section_libpurgeable"></a>](#libpurgeable系统库)
12    - [libspeculative系统库(规划中)<a name="section_libspeculative"></a>](#libspeculative系统库规划中)
13  - [使用说明<a name="section_usage"></a>](#使用说明)
14  - [相关仓<a name="section_projects"></a>](#相关仓)
15
16## 简介<a name="section_introduction"></a>
17
18内存基础库部件位于公共基础库子系统中,为上层业务提供对应的操作内存的系统库,保证上层业务的稳定性。
19
20## 部件架构<a name="section_architecture"></a>
21
22**图1** 内存基础库部件架构图
23
24![](figures/zh-cn_image_fwk.png)
25
26| 内存基础库 | 使用者                  |
27| -------------- | -------------------------- |
28| libdmabufheap  | 多媒体相关服务      |
29| libmeminfo     | 内存管理服务         |
30| libmemleak     | 内存管理服务         |
31| libpurgeable   | 图形图像相关服务   |
32| libspeculative | 系统服务(规划中) |
33
34## 目录<a name="section_catalogue"></a>
35
36```
37/utils/memory
38├── libdmabufheap           # DMA (Direct Memory Access) 内存分配链接库
39│   ├── include             # DMA内存分配链接库头文件目录
40│   ├── src                 # DMA内存分配链接库源代码目录
41│   └── test                # DMA内存分配链接库自测用例目录
42├── libmeminfo              # 内存占用查询库
43├── libmemleak              # 内存泄漏检测库
44├── libpurgeable            # 可丢弃类型内存管理库
45│   ├── include             # purgeable类型内存分配链接库头文件目录
46|   │   ├── c               # purgeable类型内存分配的c接口目录
47|   │   ├── common          # purgeable类型内存分配的公共接口目录
48|   │   └── cpp             # purgeable类型内存分配的cpp接口目录
49│   ├── src                 # purgeable类型内存分配链接库源代码目录
50│   └── test                # purgeable类型内存分配链接库自测用例目录
51└── libspeculative          # 投机类型内存管理库
52```
53
54## 内存基础库<a name="section_libraries"></a>
55
56内存基础库是集成内存操作的系统库的部件,对内存操作的系统库进行统一管理。
57
58### libdmabufheap系统库<a name="section_libdmabufheap"></a>
59
60为多媒体相关服务提供分配共享内存的接口,通过在硬件设备和用户空间之间分配和共享内存,实现
61设备、进程间零拷贝内存,提升执行效率。
62
63### libmeminfo系统库(规划中)<a name="section_libmeminfo"></a>
64
65提供内存占用查询接口,用于内存占用信息查询、低内存查杀等场景。
66
67### libmemleak系统库(规划中)<a name="section_libmemleak"></a>
68
69配合malloc_debug做native heap内存泄漏检测。
70
71### libpurgeable系统库<a name="section_libpurgeable"></a>
72
73为多媒体相关服务提供可丢弃类型内存的专用内存申请接口。在系统可用内存不足时,purgeable内存被系统直接丢弃,实现内存快速回收。应用再次被使用时,已经被释放的purgeable内存能够进行重建。
74
75### libspeculative系统库(规划中)<a name="section_libspeculative"></a>
76
77提供投机类型内存管理接口,用于缓存预读。
78
79## 使用说明<a name="section_usage"></a>
80
81系统开发者可以通过配置productdefine/common/products下的产品定义json文件,增加或移除本部件,来启用或停用本部件。
82
83` "commonlibrary:memory_utils":{} `
84
85## 相关仓<a name="section_projects"></a>
86
87[公共基础库子系统](https://gitee.com/openharmony/utils)