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)