Memory management method, electronic equipment and related medium

By providing a variety of memory page forms in electronic devices, dynamically adjusting the type and number of memory pages according to the amount of memory application, the problem of memory resource waste caused by the large page mechanism is solved, and the efficiency of memory application and user experience is improved.

CN119248465APending Publication Date: 2025-01-03HONOR DEVICE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410276291.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-08
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In the prior art, using a large page mechanism to apply for memory is likely to lead to waste of memory resources, resulting in unstable operation of electronic devices and affecting user experience.

Method used

By providing multiple memory page forms (first compound page, second compound page and basic memory page) in the preset memory space, determining the appropriate memory page type and quantity based on the memory application amount, optimizing the memory application process, and reducing memory resources Waste and improve data reading efficiency.

Benefits of technology

It effectively avoids the waste of memory resources caused by large page alignment, improves memory application efficiency and user experience, and ensures the normal operation of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248465A_ABST
    Figure CN119248465A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a memory management method, electronic equipment and a related medium, the method is applied to the electronic equipment, a preset memory space exists in the electronic equipment, and the preset memory space is a physical memory space; the method comprises the following steps: receiving a memory application message; determining a memory application amount corresponding to the memory application message; the type and the number of to-be-applied memory pages are determined based on the memory application amount, a target memory page is applied in a preset memory space based on the type and the number, the type of the memory page comprises at least one of a first composite page, a second composite page and a basic memory page, and the type of the target memory page comprises at least one of the first composite page, the second composite page and the basic memory page; physical memory addresses among the first composite page, the second composite page and the basic memory page are discontinuous. By implementing the method provided by the invention, a memory allocation mechanism can be optimized, so that memory resource waste caused by a large page alignment process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a memory management method, electronic equipment, and related media. Background Art

[0002] With the continuous development of computer science and communication technology, the application software functions in electronic devices are becoming more and more powerful, but this also leads to an increasing demand for memory space for various applications. In order to improve the efficiency of memory application, the existing technology adopts a hugepage mechanism to apply for memory, that is, 2MB is used as an application unit, which can quickly apply for memory from the memory space, but this can easily lead to the application of memory often being larger than the actual amount of memory required for the data to be stored, resulting in a waste of memory resources, which is not conducive to the normal operation of electronic devices. Summary of the invention

[0003] In a first aspect, the present application provides a memory management method, an electronic device, and related media. The method is in an electronic device, where there is a preset memory space in the electronic device, and the preset memory space is a physical memory space. The method may include:

[0004] Receive memory request message;

[0005] Determine the memory request amount corresponding to the memory request message;

[0006] Based on the memory application amount, the type and quantity of memory pages to be applied for are determined, and based on the type and quantity, target memory pages are applied for in a preset memory space, wherein the types of memory pages include a first compound page, a second compound page, and a basic memory page, the memory space corresponding to the first compound page is larger than the memory space corresponding to the second compound page, the memory space corresponding to the second compound page is larger than the memory space corresponding to the basic memory page, and the physical memory addresses of the first compound page, the second compound page, and the basic memory page are not continuous.

[0007] By implementing the method provided in the first aspect, the electronic device can receive memory application messages of various applications in operation in the electronic device, and can determine the corresponding memory application amount based on the memory application message. More importantly, the electronic device can apply for target memory in the preset memory space in the form of a first composite page, a second composite page or a basic memory page based on the memory application amount. The prior art uses a large page mechanism to apply for memory from the preset memory space, which helps to improve the efficiency of memory application, but will cause a large amount of memory resource waste. The embodiment of the present application can apply for memory from the preset memory space by providing a plurality of memory page forms with different corresponding memory space sizes. While ensuring the memory application efficiency, it also helps to reduce the difference between the memory size of the target memory page (which can be understood as the memory space size finally allocated to the application corresponding to the memory application message) and the memory application amount, thereby reducing the waste of memory resources caused by large page alignment.

[0008] In some embodiments of the method provided in the first aspect, determining the type and quantity of memory pages to be applied for based on the memory application amount, and applying for target memory pages in a preset memory space based on the type and quantity may include:

[0009] In response to the memory application amount being greater than or equal to a first preset value, determining that the type of the memory page to be applied is a first composite page, the first composite page being used to store data whose memory size is the first preset value;

[0010] Determining a first quantity of first composite pages based on a quantitative relationship between a memory application amount and a first preset value;

[0011] A target memory page is applied for in a preset memory space based on the first quantity, and a memory application amount is updated based on the first preset value and the first quantity, wherein the updated memory application amount is smaller than the memory application amount corresponding to the memory application message.

[0012] By implementing the method provided in the above embodiment, when the memory application amount is greater than or equal to the first preset value, the electronic device will apply for a first composite page in the preset memory space to store data of the first preset value size, and subtract the first preset value from the memory application amount, so as to achieve the purpose of updating the memory application amount. If the updated memory application amount is still greater than or equal to the first preset value, the electronic device will continue to apply for a first composite page in the preset memory space to store data of the first preset value size, and continue to update the memory application amount until the memory application amount is less than the first preset value. It can be seen that by implementing the embodiment of the present application, the memory space corresponding to the first composite page applied by the electronic device will always be in a fully loaded state (that is, all memory pages in the first composite page will store data), thereby effectively avoiding the waste of memory resources caused by large page alignment, helping to ensure the normal operation of the electronic device, and further improving the user experience.

[0013] Implementing the method provided in the first aspect, in some embodiments, the method may further include:

[0014] In response to the memory application amount being less than a first preset value and greater than or equal to a second preset value, determining that the type of the memory page to be applied is a second composite page, the second composite page is used to store data with a memory size of a second preset value, and the second preset value is less than the first preset value;

[0015] Determining a second quantity of second composite pages based on a quantitative relationship between the memory application amount and a second preset value;

[0016] A target memory page is applied for in a preset memory space based on the second quantity, and a memory application amount is updated based on the second preset value and the second quantity.

[0017] By implementing the method provided in the above embodiment, when the memory application amount is less than the first preset value and greater than or equal to the second preset value, the electronic device will apply for a second composite page in the preset memory space to store data of the second preset value size, and subtract the second preset value from the memory application amount, so as to achieve the purpose of updating the memory application amount. If the updated memory application amount is still less than the first preset value and greater than or equal to the second preset value, the electronic device will continue to apply for a second composite page in the preset memory space to store data of the second preset value size, and continue to update the memory application amount until the memory application amount is less than the second preset value. It can be seen that by implementing the embodiment of the present application, the memory space corresponding to the second composite page applied by the electronic device will always be in a fully loaded state (that is, all memory pages in the second composite page will store data), and because the composite page has physical memory address continuity, it is helpful to avoid the waste of memory resources caused by large page alignment while reducing the complexity of subsequent electronic devices reading data from the preset memory space, thereby achieving the purpose of optimizing the electronic device for data reading, and can further improve the user experience.

[0018] Implementing the method provided in the first aspect, in some embodiments, the method may further include:

[0019] In response to the memory application amount being less than the second preset value, determining that the type of the memory page to be applied is a basic memory page, the basic memory page being used to store data whose memory size is a third preset value, the third preset value being less than the second preset value;

[0020] Determining a third number of basic memory pages based on a quantitative relationship between the memory application amount and a third preset value;

[0021] A target memory page is allocated in a preset memory space based on the third quantity.

[0022] By implementing the method provided in the above embodiment, when the memory application amount is less than the second preset value, the electronic device can directly apply for at least one basic memory page with discontinuous physical memory address to store data, and each basic memory page can be used to store data of a third preset value size. It can be seen that the embodiment of the present application utilizes three memory page forms with different corresponding memory space sizes to meet the memory requirements of various applications in the electronic device, which helps to reduce the waste of memory resources caused by large page alignment operations in the prior art, and also helps to improve the speed of subsequent data reading by the electronic device, thereby optimizing the operating performance of the electronic device and further improving the user experience.

[0023] In some embodiments of the method provided in the first aspect, determining the third number of basic memory pages based on the quantitative relationship between the memory application amount and the third preset value may include:

[0024] In response to the memory application amount being N times the third preset value, determining the third quantity to be N, where N is a positive integer;

[0025] In response to the memory application amount being less than N times the third preset value and greater than N-1 times the third preset value, determining the third amount to be N;

[0026] In response to the memory application amount being equal to 0, it is determined that the memory application operation corresponding to the memory application message is completed.

[0027] By implementing the method provided in the above embodiment, the electronic device can allow the basic memory page not to be filled with data. Since the first preset value and the second preset value are much larger than the third preset value, the situation where there are free memory resources in the basic memory page can minimize the degree of memory resource waste compared to the situation where there are free memory resources in the first composite page and the second composite page.

[0028] In some embodiments of the method provided in the first aspect, after applying for a target memory page in a preset memory space based on the type and quantity, the method may further include:

[0029] Based on the mapping process corresponding to the type of the memory page to be applied for, a mapping relationship between the target memory page and the virtual memory is established;

[0030] The association relationship between each memory page in the first composite page and / or the second composite page is released.

[0031] By implementing the method provided in the above embodiment, the electronic device can use different mapping processes to establish a mapping relationship between the physical memory (ie, the above target memory page) and the virtual memory.

[0032] In some embodiments of implementing the method provided in the first aspect, the method may further include: receiving a memory release message to release memory from a preset memory space.

[0033] By implementing the method provided in the above embodiment, the electronic device can also release memory in the preset memory space based on the memory release instructions of each application, thereby achieving sustainable utilization of memory resources and helping to prevent abnormal occupation of memory resources.

[0034] In some embodiments of the method provided in the first aspect, applying for a target memory page in a preset memory space based on the type and quantity may include: calling a vmalloc function to apply for a target memory page from the preset memory space.

[0035] By implementing the method provided in the above embodiment, the electronic device can use the vmalloc function to apply for the first composite page, the second composite page and the basic memory page with discontinuous physical memory addresses in the preset memory space, which helps to improve the memory resource utilization of the physical memory space. It should be noted that the discontinuous physical memory address means that the physical memory addresses between the first composite page and the second composite page, the first composite page and the basic memory page, and the second composite page and the basic memory page are discontinuous, and the physical memory addresses between the memory pages within the composite page are continuous.

[0036] In some embodiments of implementing the method provided in the first aspect, receiving a memory release message and releasing memory from a preset memory space may include: calling a vfree function to release memory from the preset memory space.

[0037] By implementing the method provided in the above embodiment, the electronic device can use the vfree function to release the corresponding memory from the preset memory space, thereby achieving sustainable utilization of memory resources and helping to prevent abnormal occupation of memory resources.

[0038] In a second aspect, an embodiment of the present application provides a memory processing device, comprising a unit for executing the method in the first aspect or any possible implementation of the first aspect.

[0039] In a third aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the method described in the first aspect and any possible implementation method of the first aspect is executed.

[0040] In a fourth aspect, an embodiment of the present application provides a chip, comprising a logic circuit and an interface, wherein the logic circuit and the interface are coupled; the interface is used to input and / or output code instructions, and the logic circuit is used to execute the code instructions so that the method in the first aspect or any possible implementation of the first aspect is executed.

[0041] In a fifth aspect, the present application provides a computer-readable storage medium comprising instructions, which, when executed on a target terminal, execute the method described in the first aspect and any possible implementation of the first aspect.

[0042] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible implementation of the first aspect.

[0043] It can be understood that the memory processing device provided in the second aspect, the electronic device provided in the third aspect, the chip provided in the fourth aspect, the computer-readable storage medium provided in the fifth aspect, and the computer program product provided in the sixth aspect are all related to the memory management method provided in the first aspect, and can be used to execute the method provided in the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects of the memory management method in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 It is a schematic diagram of a mapping relationship between a virtual memory address and a physical memory address provided in an embodiment of the present application;

[0046] Figure 2 It is a schematic diagram of a memory partition provided in an embodiment of the present application;

[0047] Figure 3 is a structural diagram of an electronic device 100 provided in an embodiment of the present application;

[0048] Figure 4 It is a software structure diagram provided by an embodiment of the present application;

[0049] Figure 5 It is a flowchart of a memory application method provided by the prior art;

[0050] Figure 6 It is a flowchart of a memory management method provided by an embodiment of the present application;

[0051] Figure 7 This is a schematic diagram of a process for determining a mapping type provided in an embodiment of the present application;

[0052] Figure 8 is a schematic diagram of a scenario of accessing memory provided by an embodiment of the present application;

[0053] Fig. 9 It is a schematic diagram of a memory management process in a video playback scenario provided by an embodiment of the present application. DETAILED DESCRIPTION

[0054] The technical solutions in the embodiments of the present application will be described clearly and in detail below in conjunction with the accompanying drawings. The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear contrary indication in the context. It should also be understood that in the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a kind of association relationship describing the associated objects, indicating that there can be three relationships, for example, A and / or B, can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" refers to two or more than two.

[0055] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0056] The term "user interface (UI)" in the following embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device, and finally presented as content that can be recognized by the user. The commonly used form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operation displayed in a graphical manner. It can be a visual interface element such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. displayed on the display screen of an electronic device.

[0057] In order to make the description of the following embodiments clear and concise, a brief introduction to the related technology is first given:

[0058] In an operating system, the storage devices that the central processing unit (CPU) can directly access include the memory of the electronic device and the registers in the CPU. For example, program instructions can use memory addresses as parameters, but not disk addresses. Therefore, the execution instructions and the data used by the instructions must be on a storage device that the CPU can directly access. If the data is not in the memory, then the CPU must move the data to the memory before using it.

[0059] 1. User space and kernel space

[0060] In the operating system of the electronic device, the memory space may include a user space and a kernel space, wherein the user space may be understood as a memory space for running user processes, and the kernel space may be understood as a memory space for running operating system kernel programs.

[0061] Taking a CPU with a 32-bit address bus as an example, the total memory capacity of the user space is 3GB, and its address range is from 0x00000000 to 0xBFFFFFFF; the total memory capacity of the kernel space is 1GB, and its address range is from 0xC0000000 to 0xFFFFFFFF. Therefore, it can be understood that the address space of 0-3GB in the memory is the user space, and the address space of 3GB-4GB is the kernel space.

[0062] 2. Virtual memory address and physical memory address

[0063] The physical memory address can be understood as the address in the physical memory bar, and the virtual memory address can be understood as the address obtained by converting the physical memory address. The mapping relationship between the physical memory address and the virtual memory address can be maintained by the memory management unit (MMU). For example, the mapping relationship can be stored through mapping. Then, when the virtual memory address is known, the corresponding physical memory address can be determined through the mapping table, thereby accessing the corresponding physical memory space.

[0064] Optionally, the virtual memory address may also be referred to as a linear address, which is not limited in this application.

[0065] Virtual memory addresses are continuous addresses, but the physical memory addresses mapped by virtual memory addresses can be continuous or non-continuous. For ease of understanding, please refer to Figure 1 , Figure 1It is a schematic diagram of a mapping relationship between a virtual memory address and a physical memory address provided in an embodiment of the present application.

[0066] like Figure 1 As shown in the figure, the virtual memory address of the memory space allocated to process A is 0x30-0x36. After the conversion of the mapping relationship in the MMU, the physical memory address corresponding to the virtual memory address 0x30-0x36 is 0x80-0x0D. It is easy to understand that the virtual memory address of the memory space allocated to process A is continuous, and the physical memory address mapped by the virtual memory address is also continuous.

[0067] The virtual memory address of the memory space allocated to process B is 0x50-0x60. After the conversion of the mapping relationship in the MMU, the physical memory addresses corresponding to the virtual memory addresses 0x50-0x60 are 0x38-0x40 and 0x70-0x78. It is easy to understand that the virtual memory address of the memory space allocated to process B is continuous, but the physical memory address mapped by the virtual memory address is non-continuous.

[0068] Therefore, it can be understood that although the virtual memory addresses are continuous, Figure 1 The memory allocated to process A shown in the figure is continuous physical memory, while the memory allocated to process B is non-contiguous physical memory.

[0069] 3. Memory partition

[0070] The kmalloc function can be used to apply for continuous physical memory from the kernel space, and the vmalloc function can be used to apply for non-contiguous physical memory from the kernel space. In the kernel space, different memory spaces support different allocation methods. For example, see Figure 2 , Figure 2 Schematic diagram of a memory partition provided by an embodiment of the present application. Figure 2 As shown, the kernel space may include a direct mapping area and a non-direct mapping area, wherein there is a linear conversion relationship between the virtual memory address and the physical memory address of the direct mapping area, such as the above Figure 1 The memory allocated to process A in the above example can be considered to be obtained from the direct mapping area. The virtual memory addresses of the non-direct mapping area are continuous, but the physical memory addresses corresponding to the virtual memory addresses are not necessarily continuous. For example, Figure 1 The memory allocated to process B can be considered to be obtained from the non-direct mapping area.

[0071] Therefore, it can be understood that the memory requested by the kmalloc function belongs to the direct mapping area, and the memory requested by the vmalloc function belongs to the indirect mapping area. The address segment included in the direct mapping area is different from the address segment included in the indirect mapping area, and the address segment included in the direct mapping area does not overlap with the address segment included in the indirect mapping area. For ease of understanding, taking a CPU with a 32-bit address bus as an example, in a kernel space of 1GB in size, the interval from 0xC0000000 (i.e. 3GB) to a maximum of 896M can be understood as a direct mapping area, and the interval from vmalloc_start to vmalloc_end can be understood as a indirect mapping area. Among them, the indirect mapping area from vmalloc_start to vmalloc_end does not overlap with the direct mapping area, that is, vmalloc_start is outside the direct mapping area, and vmalloc_end is within 0xFFFFFFFF (i.e. 4GB). For example Figure 2 As shown, a buffer may be included between the non-direct mapping area and the direct mapping area to prevent out-of-bounds memory requests.

[0072] It is understandable that the specific locations of the direct mapping area and the indirect mapping area in different electronic devices may be different, but for a certain electronic device, the direct mapping area and the indirect mapping area in the memory are fixed. Therefore, if an address falls within the memory address range of the direct mapping area, then the memory can be considered to be physical memory, which is obtained by applying for the kmalloc function. Similarly, if the address falls within the memory address range of the indirect mapping area, then the memory can be considered to be non-contiguous physical memory, which is obtained by applying for the vmalloc function.

[0073] Optionally, the direct mapping area may also be called a kmalloc area, a physical memory mapping area, etc.; the indirect mapping area may also be called a dynamic mapping area, a virtual memory mapping area, a vmalloc area, etc.

[0074] In summary, the memory requested by the kmalloc function is continuous physical memory in the direct mapping area, and its virtual memory address and physical memory address are continuous; while the memory requested by the vmalloc function is non-continuous physical memory in the non-direct mapping area, and its virtual memory address is continuous, but the physical memory address is not necessarily continuous.

[0075] The method provided in the embodiment of the present application is executed by an electronic device. Next, the electronic device provided in the embodiment of the present application is introduced. Figure 3 , Figure 3 It is a structural diagram of an electronic device 100 provided in an embodiment of the present application.

[0076] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an acceleration sensor 180C, a fingerprint sensor 180D, a temperature sensor 180E, a touch sensor 180F, an ambient light sensor 180G, etc.

[0077] It is understandable that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0078] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0079] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0080] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0081] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0082] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180F, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180F through the I2C interface, so that the processor 110 communicates with the touch sensor 180F through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0083] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

[0084] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0085] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0086] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0087] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0088] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0089] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0090] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.

[0091] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0092] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0093] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0094] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0095] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays a picture or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0096] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0097] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0098] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0099] The display screen 194 is used to display pictures, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1. In some embodiments, the display screen 194 can be used for dynamic effect display.

[0100] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0101] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, a picture or video playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0102] In some embodiments, the internal memory 121 may also be referred to as a memory, and may include the above-mentioned user space and the above-mentioned kernel space, wherein the kernel space may include the above-mentioned direct mapping area and the above-mentioned indirect mapping area.

[0103] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0104] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0105] The speaker 170A, also called a horn, is used to convert audio electrical signals into sound signals.

[0106] The receiver 170B, also called an earpiece, is used to convert an audio signal into a sound signal. When the electronic device 100 receives a call or a voice message, the voice can be received by placing the receiver 170B close to the ear.

[0107] Microphone 170C, also known as a microphone or a microphone, is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C with his mouth to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to realize the collection of sound signals, noise reduction, identification of sound sources, realization of directional recording function, etc.

[0108] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface.

[0109] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a device including at least two parallel plates with conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes.

[0110] The electronic device 100 can determine the intensity of the pressure based on the change in capacitance. Exemplarily, when a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity based on the pressure sensor 180A. Also exemplarily, the electronic device 100 can also calculate the touch position based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than a first pressure threshold acts on a short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on a short message application icon, an instruction to create a new short message is executed.

[0111] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0112] The acceleration sensor 180C can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0113] The fingerprint sensor 180D is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0114] The temperature sensor 180E is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180E to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180E exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180E to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0115] The touch sensor 180F is also called a "touch panel". The touch sensor 180F can be arranged on the display screen 194, and the touch sensor 180F and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180F is used to detect touch operations acting on or near it. The touch sensor 180F can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180F can also be arranged on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0116] The ambient light sensor 180G is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180G can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180G can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0117] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0118] In other embodiments, the processor 110 may call computer instructions stored in the internal memory 121 to implement the memory management method provided in the embodiments of the present application.

[0119] Exemplarily, the processor 110 may call a computer instruction stored in the internal memory 121 to determine the memory size to be applied for (which may be understood as the above-mentioned memory application amount), and then apply for memory from different memory spaces according to the memory size. Exemplarily, the computer instruction may apply for continuous physical memory from a direct mapping area, or may apply for non-continuous physical memory from a non-continuous mapping area.

[0120] It is understandable that the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture, and this application does not limit this. Figure 4 , Figure 4 This is a software structure diagram provided by the embodiment of the present application. Figure 4 The layered architecture shown divides the software into several layers. Each layer has a clear role and division of labor, and the layers can communicate through software interfaces.

[0121] In some embodiments, the system of the electronic device can be divided into five layers, from top to bottom, namely, the application layer, the application framework layer, the system runtime layer, the hardware abstraction layer (HAL) and the kernel layer. The description of each of the above layers is as follows:

[0122] The application layer may include a series of application packages. For example, the application packages of the application layer may include applications such as camera, gallery, calendar, call, map, navigation, browser, video, music, and short message.

[0123] The application framework layer can provide an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer can include some predefined functions.

[0124] Exemplarily, the application framework layer may include an activity manager, a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and an accelerated graphics port (AGP). Among them:

[0125] The activity manager can be used to manage the individual application lifecycles as well as general navigation back functionality.

[0126] The window manager can be used to manage window programs. For example, the window manager can obtain the display screen size of the electronic device 100, lock the screen, capture the screen, and determine whether there is a status bar.

[0127] Content providers can be used to store and retrieve data and make the data accessible to applications so that different applications can access or share data. For example, the data may include videos, images, audio, calls made and received, browsing history and bookmarks, and phone books.

[0128] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0129] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including answering a call, hanging up a call, etc.).

[0130] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, etc.

[0131] The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager can be used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0132] AGP in the application framework layer can be used to improve the rendering performance of the graphics card, such as providing the graphics card with more cache capacity to achieve faster image processing speed.

[0133] The system runtime layer may include system libraries and Android runtime.

[0134] The Android runtime includes a core library and a virtual machine. The Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0135] The system library can be understood as the support of the application framework, and is an important link between the application framework layer and the kernel layer. The system layer can include multiple functional modules, such as surface managers, media libraries, 3D graphics processing libraries (such as OpenGL ES), 2D graphics engines (such as SGL), etc. Among them:

[0136] The surface manager can be used to manage the display subsystem, for example, when the electronic device 100 executes multiple applications, it is responsible for managing the interaction between display and access operations. The surface manager can also be used to provide fusion of two-dimensional and three-dimensional layers for multiple applications.

[0137] The media library can support playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0138] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing.

[0139] A two-dimensional graphics engine can be understood as a drawing engine for two-dimensional drawing.

[0140] The hardware abstraction layer provides a standard interface, such as the HAL interface definition language (HIDL) interface or the Android interface definition language (AIDL) interface.

[0141] The kernel layer can be understood as an abstract layer between hardware and software. The kernel layer may include system services such as security, memory management, process management, power management, network protocol management, and driver management. Exemplarily, the kernel layer may include a driver and a memory processing module, wherein the driver may include a display driver, a camera driver, an audio driver, and a sensor driver, etc. Optionally, the kernel layer may also be referred to as an Android kernel or a kernel program. Exemplarily, the hardware layer of an electronic device may include a touch panel (TP), a liquid crystal display (LCD), etc.

[0142] In some embodiments, the kernel layer can be understood as kernel state, and the other four layers (ie, application layer, application framework layer, system runtime layer, and HAL) can be understood as user state.

[0143] It is understandable that multiple applications that may exist in the application layer have video recording and / or playback functions. For example, if a camera has a video recording function, applications such as gallery, navigation, and browser may have a video playback function. Furthermore, based on the length, resolution, and shooting parameters of the video, the recording and / or playback of the video may be affected. The shooting parameters may include aperture value, shutter speed, sensitivity, exposure, focal length, depth of field, and the like.

[0144] For example, the video recording and / or playback related parameters supported by various applications can be stored in a sensor binary file (sensor bin), and the sensor bin file can be stored in an external memory, such as a disk or a hard disk. When a user uses a specific application to record and / or play a video, the application can read the video recording and / or playback related parameters into the memory so that the user can use the application normally and ensure the user's experience.

[0145] In some embodiments, the memory application module can be coupled to the driver, that is, it can be implemented by the driver in the kernel layer. For ease of understanding, for example, refer to Figure 5 , Figure 5 The present invention is a flowchart of a memory application method provided by the prior art. The method can be executed by a driver in the kernel layer, and includes:

[0146] S501: Receive a memory request message sent by an upper layer of the kernel layer, and determine a memory request amount.

[0147] It should be noted that Figure 5 The corresponding existing technology is applied to image acquisition scenarios (such as obtaining different photos based on different shooting modes).

[0148] In this step, the upper layer of the inner core layer can be understood as any layer above the inner core layer, such as Figure 4 The application layer, application framework layer, system runtime layer and HAL layer in it, or it can also be understood as the above-mentioned user state. Exemplarily, when the application has a memory application requirement, the application sends a memory application message to the lower layer, and then passes it to the driver, such as through the above-mentioned HIDL / AIDL interface. Exemplarily, the scenario in which the application has a memory application requirement can be the camera application switching shooting mode, or adjusting shooting parameters without changing the shooting; it can also be the scene in which the player switches the sound effect mode, etc.

[0149] In an embodiment of the present application, the memory request message can be the data to be stored itself, or the size of the data to be stored (for example, 5KB), or other information indicating the data to be stored or the size of the data to be stored, as long as the driver can determine the memory request amount based on the memory request message.

[0150] S502: Determine whether the memory application amount is greater than the minimum application amount of the vmalloc area.

[0151] It can be understood that when the hardware resources of the electronic device do not change, the kmalloc area and the vmalloc area in the memory are fixed, the address range they each include is also fixed, the respective memory allocation principles are also fixed, and therefore, the respective minimum application amounts are also fixed. Exemplarily, memory allocation is performed in the vmalloc area in units of pages, and therefore, the minimum application amount of the vmalloc area is the size of a page, such as 4KB.

[0152] If the judgment result of step S502 is yes, step S503 is executed: applying for memory from the kmalloc area.

[0153] It can be understood that the kmalloc area is a direct mapping area in the memory, the physical memory address of the allocated memory is continuous, the virtual memory address is also continuous, and the physical memory address and the virtual memory address are simply offset (such as offset), and in electronic devices, the address offset is fixed. Therefore, after applying for the physical memory address from the kmalloc area, the virtual memory address can be uniquely determined, and there is no need to separately establish a mapping relationship between the physical memory address and the virtual memory address. Optionally, step S503 may specifically include:

[0154] Determine the amount of memory requested.

[0155] Based on the memory request amount, apply for memory with continuous physical memory address from the kmalloc area to obtain the physical memory address.

[0156] Returns a pointer to the virtual memory address corresponding to this physical memory address.

[0157] If the judgment result of step S502 is no, step S504 is executed: applying for memory from the vmalloc area.

[0158] It can be understood that in the method of the prior art, for a certain memory request, the memory obtained may be the memory with continuous physical memory address in the kmalloc area, or the memory with discontinuous physical memory address in the vmalloc area. The key lies in the size of the memory request, that is, the judgment result of step S502 determines the type of memory finally obtained.

[0159] It should be noted that the physical memory address of the memory applied for based on the kmalloc function is continuous, and the physical memory address of the memory applied for based on the vmalloc function is discontinuous, which easily leads to the scattered distribution of the free memory space of the electronic device in the prior art, and may eventually lead to the size of the memory space with continuous physical addresses failing to meet the memory application requirements corresponding to step S503 (such as the size of the free, continuous physical memory address memory space is smaller than the memory application requirements corresponding to step S503), thereby causing abnormal memory allocation and affecting the normal operation of the electronic device. However, a memory management method provided in an embodiment of the present application only needs to use the vmalloc function for memory application, which can effectively avoid the above-mentioned abnormal memory allocation situation, and the embodiment of the present application meets the memory usage requirements of the application by using a variety of memory pages with different application specifications, which helps to reduce the waste of memory space for electronic devices.

[0160] For a detailed description of the method provided in the embodiment of the present application and the corresponding beneficial effects of the method, please refer to Figure 6 , Figure 6 is a flow chart of a memory management method provided by an embodiment of the present application. Figure 6 As shown, the method is executed by a driver in the kernel layer, and the method may include:

[0161] S601: Receive a memory request message sent by an upper layer of the kernel layer.

[0162] It can be understood that the target application sends an application message to the driver. The target application can be an application with a video playback function, such as a gallery, a browser, a video player, a short video social software, and a social software with a video call function.

[0163] In this step, the upper layer of the inner core layer can be understood as any layer above the inner core layer, such as Figure 4 The application layer, application framework layer, system runtime layer and HAL layer in it, or it can also be understood as the above-mentioned user state. Exemplarily, when the application has a memory application requirement, the application sends a memory application message to the lower layer, and then passes it to the driver, such as through the above-mentioned HIDL / AIDL interface. Exemplarily, the scenario in which the application has a memory application requirement can be a scenario in which a video player plays a video, or shoots a video in a camera application; it can also be a scenario such as making a video call through a social software.

[0164] S602: Determine the memory request amount corresponding to the memory request message.

[0165] In an embodiment of the present application, the memory request message can be the data to be stored itself, or the size of the data to be stored (for example, 5KB), or other information indicating the data to be stored or the size of the data to be stored, as long as the driver can determine the memory request amount based on the memory request message.

[0166] S603: Determine the type and quantity of memory pages to be applied for based on the memory application amount, and apply for target memory pages in a preset memory space based on the type and quantity.

[0167] The type of memory page may include at least one of a first composite page, a second composite page and a basic memory page. Further, the memory space corresponding to the first composite page is larger than the memory space corresponding to the second composite page, and the memory space corresponding to the second composite page is larger than the memory space of the basic memory page.

[0168] In some embodiments, the driver can achieve the purpose of applying for the target memory page from the preset memory space by calling the vmalloc function. It can be understood that the physical memory addresses of the first composite page, the second composite page and the base memory page are not continuous. It should be noted that the composite page (i.e., the first composite page and the second composite page) is composed of two or more memory pages with continuous physical memory addresses, that is, the physical memory addresses of the memory pages inside the composite page are continuous.

[0169] Furthermore, the physical memory addresses between different first composite pages are not continuous, the physical memory addresses between different second composite pages are not continuous, and the physical memory addresses between different basic memory pages are not continuous.

[0170] In other implementations, determining the type and quantity of memory pages to be applied for based on the memory application amount, and applying for target memory pages in a preset memory space based on the type and quantity may include:

[0171] In response to the memory application amount being greater than or equal to a first preset value, determining that the type of the memory page to be applied is a first composite page, the first composite page being used to store data whose memory size is the first preset value;

[0172] Determining a first quantity of first composite pages based on a quantitative relationship between a memory application amount and a first preset value;

[0173] A target memory page is applied for in a preset memory space based on the first quantity, and a memory application amount is updated based on the first preset value and the first quantity.

[0174] The first composite page is used to store data whose memory size is a first preset value, and the updated memory application amount is smaller than the memory application amount corresponding to the memory application message.

[0175] Exemplarily, assuming that the first preset value is 2MB, if the memory application amount corresponding to the memory message is 2256KB, then a first composite page can be applied for in the preset memory space to store 2048KB (i.e., 2MB) of data. Further, it is also necessary to update the memory application amount based on the first preset value. The specific updating method can be to subtract the first preset value from the memory application amount, such as 2256KB-2048KB=208KB, so that the updated memory application amount is 208KB, and the electronic device (or driver) can subsequently make further memory applications based on the memory application amount of 208KB. Furthermore, if the memory application amount corresponding to the memory message is 4096KB, then two first composite pages can be applied for in the preset memory space, and the physical memory addresses corresponding to the two first composite pages can be discontinuous. Further, referring to the above-mentioned method for updating the application amount, the updated memory application amount is 4096KB-2048KB-2048KB=0KB, and it can be considered that the memory application operation corresponding to the memory application message is completed.

[0176] In other implementations, determining the type and quantity of memory pages to be applied for based on the memory application amount, and applying for target memory pages in a preset memory space based on the type and quantity may also include:

[0177] In response to the memory application amount being less than a first preset value and greater than or equal to a second preset value, determining that the type of the memory page to be applied is a second composite page, the second composite page is used to store data with a memory size of a second preset value, and the second preset value is less than the first preset value;

[0178] Determining a second quantity of second composite pages based on a quantitative relationship between the memory application amount and a second preset value;

[0179] A target memory page is applied for in a preset memory space based on the second quantity, and a memory application amount is updated based on the second preset value and the second quantity.

[0180] The second composite page is used to store data whose memory size is a second preset value, and the second preset value is smaller than the first preset value.

[0181] Exemplarily, assuming that the second preset value is 64KB, if the target application currently corresponds to a memory application amount of 208KB, then three second compound pages can be applied for in the preset memory space to store 64KB×3=192KB of data. Furthermore, it is necessary to update the memory application amount based on the second preset value. The specific updating method can be to subtract the second preset value from the memory application amount, such as 208KB-192KB=16KB, and the updated memory application amount can be 16KB. The electronic device (or driver) can subsequently make further memory applications based on the memory application amount of 16KB. Among them, the memory application amount of 208KB can be the memory application amount updated by the first preset value, or it can be the initial memory application amount corresponding to the memory application message of the target application.

[0182] In other implementations, determining the type and quantity of memory pages to be applied for based on the memory application amount, and applying for target memory pages in a preset memory space based on the type and quantity may also include:

[0183] In response to the memory application amount being less than the second preset value, determining that the type of the memory page to be applied is a basic memory page, the basic memory page being used to store data whose memory size is a third preset value, the third preset value being less than the second preset value;

[0184] Determining a third number of basic memory pages based on a quantitative relationship between the memory application amount and a third preset value;

[0185] A target memory page is allocated in a preset memory space based on the third quantity.

[0186] The basic memory page may be used to store data whose memory size is a third preset value, and the third preset value is smaller than the second preset value.

[0187] Specifically, determining the third number of basic memory pages based on the quantitative relationship between the memory application amount and the third preset value may include:

[0188] In response to the memory application amount being N times the third preset value, determining the third quantity to be N, where N is a positive integer;

[0189] In response to the memory application amount being less than N times the third preset value and greater than N-1 times the third preset value, determining the third amount to be N;

[0190] In response to the memory application amount being equal to 0, it is determined that the memory application operation corresponding to the memory application message is completed.

[0191] Exemplarily, assuming that the third preset value is 4KB, if the target application currently corresponds to a memory request amount of 16KB, then 4 basic memory pages can be applied for in the preset memory space to store 16KB of data; if the target application currently corresponds to a memory request amount of 3KB, then 1 basic memory page can be applied for in the preset memory space to store 3KB of data. It should be noted that the above-mentioned memory request amounts of 16KB and 3KB can be memory request amounts updated by the first preset value and / or the second preset value, or can be the initial memory request amounts corresponding to the memory request message of the target application.

[0192] In another prior art, in order to improve the efficiency of memory allocation, the prior art introduces a hugepage mechanism. Specifically, when the memory application amount corresponding to the application is greater than PMD_SIZE (i.e. 2MB), the electronic device (or driver) will force the application of memory in a 2MB aligned manner (i.e. the final memory size applied for is an integer multiple of 2MB). Exemplarily, if the memory application amount is 2.1MB, the electronic device (or driver) will apply for 4MB of memory space from the preset memory space to store data, which will cause a huge waste of memory resources and is not conducive to the normal operation of the electronic device. On the contrary, the method of the embodiment of the present application can greatly reduce the waste of memory resources. For example, if the method of the embodiment of the present application is adopted, when the memory application amount is 2.1MB (that is, 2150.4KB), 1 first compound page, 1 second compound page and 10 basic memory pages can be applied for from the preset memory space, and the final applied memory space size is 2048KB+64KB+40KB=2152KB. Compared with the 1.9MB of memory resource waste caused by the prior art, the method of the embodiment of the present application will only have 1.6KB of memory resource waste. It can be seen that the method of the embodiment of the present application can apply for memory by adopting a variety of memory application forms with different memory specifications. While ensuring the memory application efficiency, it can also greatly reduce the waste of memory resources, which helps to ensure the normal operation of the electronic device, thereby improving the user experience.

[0193] In some other embodiments, after applying for the target memory page in the preset memory space based on the type and quantity, the method may further include:

[0194] Based on the mapping process corresponding to the type of the memory page to be applied for, a mapping relationship between the target memory page and the virtual memory is established;

[0195] The association relationship between each memory page in the first composite page and / or the second composite page is released.

[0196] When the electronic device (or driver) applies for various types of memory pages, mapping identifiers corresponding to various memory page types are generated. For example, the method of the embodiment of the present application can calculate each mapping label based on the quantitative relationship between the first preset value, the second preset value, and the third preset value and the third preset value, respectively. Assuming that the first preset value is 2MB, the second preset value is 64KB, and the third preset value is 4KB, the first preset value is 2MB, and the third preset value is 64KB. 9 times, the second preset value is twice the third preset value 4 , the third preset value is 2 of the third preset value 0 Therefore, the mapping identifier corresponding to the first composite page can be set to 9, the mapping identifier corresponding to the second composite page can be set to 4, and the mapping identifier corresponding to the third composite page can be set to 0.

[0197] To explain in detail the steps of determining the mapping type in the embodiment of the present application, please refer to Figure 7 , Figure 7 This is a schematic diagram of a process for determining a mapping type provided in an embodiment of the present application. Figure 7 As shown, the process may include:

[0198] S701: Traverse the target array to determine the mapping identifier corresponding to each element in the target array.

[0199] Among them, the target array stores the memory application status corresponding to a certain memory application message of the target application. Exemplarily, if the memory application amount corresponding to a certain memory application message of the target application is 2256KB, the electronic device can apply for 1 first composite page, 3 second composite pages and 4 basic memory pages from the preset memory space, and save the identity information corresponding to 1 first composite page, 3 second composite pages and 4 basic memory pages to the target array, and the identity information can be related to the physical memory address (such as indicating the physical memory address range corresponding to each composite page, and the physical memory address corresponding to each basic memory page). Among them, please refer to Table 1, which provides the corresponding relationship between each element in the target array and each type of memory page, and Table 1 also presents the mapping identifier corresponding to each element. As shown in Table 1, it can be considered that the target array contains a first element 710 (corresponding to the first composite page), a second element 711 (corresponding to the first second composite page), a third element 712 (corresponding to the second second composite page), a fourth element 713 (corresponding to the third second composite page), a fifth element 714 (corresponding to the first basic memory page), a sixth element (corresponding to the first basic memory page), a seventh element (corresponding to the first basic memory page), and an eighth element (corresponding to the first basic memory page).

[0200] Table 1

[0201]

[0202]

[0203] S702: Determine whether the mapping identifier of the element is equal to 9.

[0204] If the answer in step S702 is yes, execute step S703: call the pmd_set_huge function to implement large page table mapping.

[0205] If the result of step S702 is no, step S704 is executed: determining whether the mapping identifier of the element is equal to 4.

[0206] If the result of the determination in step S704 is yes, step S705 is executed: calling the set_pte_at function to implement continuous page table mapping.

[0207] It can be understood that implementing continuous page table mapping is to map the second composite page between the physical memory address and the virtual memory address.

[0208] If the judgment in step S704 is no, step S706 is executed: calling the set_pte_at function to implement normal page table mapping.

[0209] In one embodiment, when the memory areas corresponding to the elements in the target array have completed the operation of mapping from the physical memory address to the virtual memory address, the electronic device (or driver) will release the association between the continuous memory pages in the composite page (such as the first composite page and the second composite page). It can be understood that when applying for memory, the electronic device (or driver) will apply for the memory area corresponding to the composite page in a whole form, that is, the memory application can be completed by only determining the physical memory address range, but after the mapping relationship between the physical memory address and the virtual memory address is established, the electronic device can complete the reading and / or release of data based on the virtual memory address, so there is no need to continue to maintain the overall state of the composite page in the physical memory space, and the association state of each memory page in the composite page can be released, so that each memory page maintains an independent state similar to the basic memory page, which is also convenient for the subsequent operation of the electronic device.

[0210] In some embodiments, a translation lookaside buffer (TLB) and a three-level page table are provided in the central processing unit (CPU) of the electronic device, wherein the three-level page tables are respectively a page global directory (PGD), a page middle directory (PMD), and a page table entry (PTE). When the kernel layer driver responds to a memory access instruction sent by an application (the address carried by the access instruction is a virtual memory address), the electronic device first searches the TLB for a page table entry corresponding to the virtual memory address. If there is such a page table entry, the corresponding physical memory address can be directly searched based on the page table entry and the query result is returned; if there is such a page table entry, the search will continue in the PGD page table, the PMD page table, and the PTE page table level by level, and the query result will be buffered in the TLB.

[0211] It should be noted that when establishing the mapping relationship between the physical memory address and the virtual memory address, the virtual memory address will retain the association relationship between the various memory pages in the composite page, which is convenient for the electronic device to read data later. Figure 8 , Figure 8 Schematic diagram of a memory access scenario provided by an embodiment of the present application. Figure 8 As shown, assuming that the virtual memory address corresponding to the memory requested by the target application is 0x30-0x40 (corresponding to the physical memory address is 0x10-0x20, which can be regarded as the virtual memory address corresponding to the first composite page), 0x45-0x50 (corresponding to the physical memory address is 0x33-0x38, which can be regarded as the virtual memory address corresponding to the second composite page) and 0x60-0x62 (corresponding to the physical memory address is 0x58-0x60, which can be regarded as the virtual memory address corresponding to the basic memory page), when the kernel layer driver responds to the memory access instruction sent by the application (the address carried by the access instruction is the virtual memory address), if The virtual memory address is 0x33. Since the data stored in 0x30-0x40 belong to the same composite page, the data corresponding to the virtual memory address 0x30-0x40 can be directly read and returned. Similarly, if the virtual memory address is 0x45, since the data stored in 0x45-0x50 belong to the same composite page, the data corresponding to the virtual memory address 0x45-0x50 can be directly read and returned. It can be seen that the method of the embodiment of the present application can save the process of the application retrieving data from the memory space, and enable the application to quickly and completely obtain the required data, thereby improving the smoothness of the application operation and improving the user experience.

[0212] In other implementations, the method of the embodiment of the present application may further include: receiving a memory release message, and releasing memory from a preset memory space.

[0213] Exemplarily, the driver may call a vfree function to release memory from a preset memory space.

[0214] It can be seen that by implementing the method of the embodiment of the present application, the occurrence of memory resource waste in the memory application process can be effectively reduced. Moreover, using the method of the embodiment of the present application to apply for memory helps to simplify the process of electronic devices reading data from memory space, increase the running speed of applications, and thus improve the user experience.

[0215] See also Fig. 9 , Fig. 9 It is a schematic diagram of a memory management process in a video playback scenario provided by an embodiment of the present application.

[0216] like Fig. 9 As shown, this may include:

[0217] S901: The target application determines target video data in response to a video play instruction from a user.

[0218] Among them, the target application can be an application with a video playback function, such as a gallery, a browser, a video player, a short video social software, and a social software with a video call function, etc. Furthermore, the user's video playback instruction can be the user selecting a specific video to play, or the user connecting a video call, which is not limited in this application. Then, the target application can pass the identification information corresponding to the target video to the target application HIDL / AIDL. Furthermore, the target application can determine whether the user performs a video playback operation through the sensor driver of the electronic device (such as a touch sensor driver).

[0219] S902: The target application HIDL / AIDL transmits identification information of the target video.

[0220] In this step, the target application HIDL / AIDL passes the representation information of the target video to the independent graphics driver in the kernel space, and the independent graphics driver applies for memory for the relevant parameters of the target video, including:

[0221] S903: Determine the data volume of the target video based on the identification information.

[0222] In this step, the independent graphics card driver determines the data volume of the target video, which can be understood as the size of the memory space required to store the target video. Exemplarily, the data volume corresponding to the target video can be obtained through the keyword sizeof.

[0223] S904: Call vmalloc function to apply for memory.

[0224] It can be understood that the memory requested by the vmalloc function is non-contiguous physical memory. The specific process may include: determining the memory request amount.

[0225] It can be understood that the independent graphics card driver can pass the memory size to be applied for as a parameter to the vmalloc function when calling the vmalloc function. Therefore, the vmalloc function can determine the memory application amount through the passed-in parameters.

[0226] The process of calling the vmalloc function to apply for memory may also include: applying for a target memory page from a preset memory space based on the memory application amount to obtain a physical memory address.

[0227] The preset memory space may be a double data rate synchronous dynamic random access memory (Double Data Rate, DDR) or a random access memory (Random Access Memory, RAM), and this application does not impose any limitation thereto.

[0228] Optionally, the type of the target memory page may include at least one of a first compound page, a second compound page and a basic memory page. Furthermore, the memory space corresponding to the first compound page is larger than the memory space corresponding to the second compound page, and the memory space corresponding to the second compound page is larger than the memory space of the basic memory page. It can be understood that the physical memory addresses of the first compound page, the second compound page and the basic memory page are not continuous. It should be noted that the compound page (that is, the first compound page and the second compound page) is composed of two or more memory pages with continuous physical memory addresses, that is, the physical memory addresses of the memory pages inside the compound page are continuous. Among them, the specific process of applying for memory can be referred to. Figure 6 The contents corresponding to the related embodiments will not be repeated here.

[0229] The process of calling the vmalloc function to apply for memory may also include: applying for a virtual memory address for the physical memory address.

[0230] The process of calling the vmalloc function to apply for memory may also include: establishing a mapping relationship between the physical memory address and the virtual memory address.

[0231] It can be understood that in the vmalloc function, the physical memory address applied for is discontinuous, but the virtual memory address applied for is continuous. Therefore, it is necessary to establish a mapping relationship between the physical memory address and the virtual memory address so that after determining a virtual memory address, the corresponding physical memory address can be obtained through the mapping relationship.

[0232] The process of calling the vmalloc function to apply for memory may also include: returning a pointer to the virtual memory address.

[0233] It can be understood that the pointer stores the virtual memory address of the requested memory. The physical memory address can be obtained through the virtual memory address and the mapping relationship, so that the data can be stored in the memory.

[0234] S905: The shooting parameters are stored in the applied memory.

[0235] S906: Transmit the target video to the graphics card driver.

[0236] The graphics card driver may be a direct rendering manager (Direct Rendering Manager, DRM).

[0237] S907: The graphics card driver transmits the target video to the display device.

[0238] The display device may be a liquid crystal display (LCD), etc., and this application does not make any limitation thereto.

[0239] In this step, after the target video is transmitted to the display device, the effect of presenting the target video to the user can be achieved.

[0240] It should be understood that each step in the above method embodiment can be completed by an integrated logic circuit of hardware in a processor or by instructions in the form of software. The method steps disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.

[0241] The present application also provides an electronic device, which may include: a memory and a processor. The memory may be used to store a computer program; the processor may be used to call the computer program in the memory so that the electronic device executes the method executed by the electronic device side in any of the above embodiments.

[0242] The present application also provides a chip system, which includes at least one processor for implementing the functions involved in the electronic device side in any of the above embodiments.

[0243] In one possible design, the chip system also includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.

[0244] The chip system may be composed of the chip, or may include the chip and other discrete devices.

[0245] Optionally, the processor in the chip system may be one or more. The processor may be implemented by hardware or by software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.

[0246] Optionally, the memory in the chip system may also be one or more. The memory may be integrated with the processor or may be separately arranged with the processor, which is not limited in the embodiments of the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be arranged on different chips respectively. The embodiments of the present application do not specifically limit the type of memory and the arrangement of the memory and the processor.

[0247] Exemplarily, the chip system can be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD) or other integrated chips.

[0248] The present application also provides a computer program product, which includes: a computer program (also referred to as code, or instruction), which, when executed, enables a computer to execute the method executed by the electronic device side in any of the above embodiments.

[0249] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program (also referred to as code or instruction). When the computer program is executed, the computer executes the method executed by the electronic device side in any of the above embodiments.

[0250] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0251] The various implementation modes of the present application can be combined arbitrarily to achieve different technical effects.

[0252] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)), etc.

[0253] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

[0254] In short, the above is only an embodiment of the technical solution of this application, and is not intended to limit the protection scope of this application. Any modification, equivalent replacement, improvement, etc. made according to the disclosure of this application shall be included in the protection scope of this application.

Claims

1. A memory management method, characterized in that: The method is applied to an electronic device, wherein the electronic device has a preset memory space, and the preset memory space is a physical memory space; the method comprises: Receive memory request message; Determine a memory request amount corresponding to the memory request message; Based on the memory application amount, the type and quantity of memory pages to be applied for are determined, and based on the type and quantity, target memory pages are applied for in the preset memory space, wherein the types of memory pages include a first compound page, a second compound page, and a basic memory page, the memory space corresponding to the first compound page is larger than the memory space corresponding to the second compound page, the memory space corresponding to the second compound page is larger than the memory space corresponding to the basic memory page, and the physical memory addresses of the first compound page, the second compound page, and the basic memory page are not continuous.

2. The method according to claim 1, characterized in that The determining the type and quantity of memory pages to be applied for based on the memory application amount, and applying for target memory pages in the preset memory space based on the type and quantity, includes: In response to the memory application amount being greater than or equal to a first preset value, determining that the type of the memory page to be applied is a first composite page, the first composite page being used to store data having a memory size of the first preset value; Determining a first quantity of the first composite pages based on a quantitative relationship between the memory application amount and the first preset value; A target memory page is applied for in the preset memory space based on the first quantity, and the memory application amount is updated based on the first preset value and the first quantity, wherein the updated memory application amount is smaller than the memory application amount corresponding to the memory application message.

3. The method according to claim 2, characterized in that The method further comprises: In response to the memory application amount being less than the first preset value and greater than or equal to a second preset value, determining that the type of the memory page to be applied is a second composite page, the second composite page is used to store data whose memory size is the second preset value, and the second preset value is less than the first preset value; Determining a second quantity of the second composite pages based on a quantitative relationship between the memory application amount and the second preset value; A target memory page is applied for in the preset memory space based on the second number, and the memory application amount is updated based on the second preset value and the second number.

4. The method according to claim 3, characterized in that The method further comprises: In response to the memory application amount being less than the second preset value, determining that the type of the memory page to be applied is a basic memory page, the basic memory page being used to store data whose memory size is a third preset value, the third preset value being less than the second preset value; Determining a third number of the basic memory pages based on a quantitative relationship between the memory application amount and the third preset value; A target memory page is requested in the preset memory space based on the third number.

5. The method according to claim 4, characterized in that The determining the third number of the basic memory pages based on the quantitative relationship between the memory application amount and the third preset value includes: In response to the memory application amount being N times the third preset value, determining the third amount to be N, where N is a positive integer; In response to the memory application amount being less than N times the third preset value and greater than N-1 times the third preset value, determining the third amount to be N; In response to the memory application amount being equal to 0, it is determined that the memory application operation corresponding to the memory application message is completed.

6. The method according to any one of claims 1 to 5, characterized in that: After applying for a target memory page in the preset memory space based on the type and quantity, the method further includes: Based on the mapping process corresponding to the type of the memory page to be applied for, establishing a mapping relationship between the target memory page and the virtual memory; The association relationship between each memory page in the first composite page and / or the second composite page is released.

7. The method according to claim 6, characterized in that The method further includes: receiving a memory release message, and releasing memory from the preset memory space.

8. The method according to claim 7, characterized in that The applying for the target memory page in the preset memory space based on the type and quantity includes: calling a vmalloc function to apply for the target memory page from the preset memory space.

9. The method according to claim 7 or 8, characterized in that: The receiving of the memory release message and releasing the memory from the preset memory space comprises: calling a vfree function to release the memory from the preset memory space.

10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions so that the method according to any one of claims 1 to 9 is executed.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the method according to any one of claims 1 to 9 is executed.

Citation Information

Patent Citations

  • Memory management method, server and readable storage medium

    CN110674052A

  • Memory management method and device

    CN115794417A

  • Memory management method and device for graphics processor, equipment and storage medium

    CN116563089A

  • Memory processing method and related device

    CN116627855A