Region management method based on power consumption control, chip and electronic equipment
By dividing the heap area memory into two parts: working state and low power consumption state, and combining the low power memory space when required, the problem of high power consumption in the heap area is solved, achieving more efficient memory management and reducing power consumption.
Patent Information
- Application Number
- CN202510612820.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-19
AI Technical Summary
The existing memory management method causes the heap area memory to always be in a working state, resulting in large power consumption problems.
The heap area memory is divided into a first memory space and a second memory space. The first memory space is in a working state and the second memory space is in a low power state. When the first memory space does not meet the needs, some memory space is awakened from the second memory space to merge into the first memory space to meet the needs.
It effectively reduces the overall power consumption of the heap area memory, improves the effectiveness and reliability of memory management, and reduces memory fragmentation.
Smart Images

Figure CN120508255A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of integrated circuits, and specifically provides a stack area management method, chip, and electronic device based on power consumption control. Background Art
[0002] Part of the memory of the SOC (System on Chip) will be divided into the heap area, which is a memory space in memory management specifically used for dynamic application and release by application programs.
[0003] In existing memory management, software programs are typically allocated a specific amount of memory. When an application is running, the allocated memory area is in operation. However, the memory space allocated as the heap area remains in operation. This approach results in higher power consumption in the heap area. Summary of the Invention
[0004] In view of this, the present application aims to provide a heap area management method, chip and electronic device based on power consumption control to reduce the power consumption of memory.
[0005] In the first aspect, an embodiment of the present application provides a heap area management method based on power consumption control, including: receiving a memory application request from an application; the memory application request includes the required memory of the application; judging whether a first memory space meets the required memory; the first memory space belongs to the heap area memory, and the heap area memory also includes a second memory space, wherein: the first memory space is in a working state and is allowed to be allocated, and the second memory space is in a low power consumption state; when the first memory space does not meet the required memory, waking up at least part of the memory space from the second memory space and merging it into the first memory space, so that the first memory space meets the required memory; when the first memory space meets the required memory, allocating memory space matching the required memory to the application in the first memory space.
[0006] In an embodiment of the present application, the heap memory is configured as a first memory space and a second memory space. The first memory space is in a working state and its memory can be allocated. The second memory space is in a low-power state. The power consumption of the second memory space is less than that of the first memory space. When the first memory space does not meet the needs of the application, part of the memory space is awakened from the second memory space in a low-power state and merged into the first memory space for allocation by the first memory space. In this way, part of the heap memory can be in a low-power state without being in a working state at all times, which can effectively reduce the power consumption of the heap memory as a whole.
[0007] In one embodiment, before receiving the memory application request from the application, the method includes: generating the heap memory in response to an instruction to divide the memory; initializing all physical memory blocks providing the heap memory, and configuring the physical memory blocks providing the heap memory to a low power consumption state, wherein the second memory space is provided by the physical memory blocks in the low power consumption state.
[0008] The memory space is provided by the physical memory blocks of the hardware. In an embodiment of the present application, at the initial moment when the heap memory is divided, all physical memory blocks corresponding to the heap memory are configured to a low power consumption state, effectively reducing power consumption when the heap memory is not allocated.
[0009] In one embodiment, the initialization of all physical memory blocks providing the heap memory includes: obtaining the target address range of the heap memory; configuring switching control logic for all physical memory blocks corresponding to the address range of the heap memory; wherein the switching control logic is used to switch the physical memory blocks from the working state to the low power state, or switch the physical memory blocks from the low power state to the working state; based on the switching control logic, the physical memory blocks corresponding to the address range of the heap memory are configured to be in a low power state.
[0010] In an embodiment of the present application, the switching logic of the physical memory block between the working state and the low power consumption state is pre-configured to abstract the interface capable of switching from the software level, so that it can be used on different hardware platforms and expand the scope of application.
[0011] In one embodiment, the determination of whether the first memory space meets the required memory includes: determining the required memory from the memory application request; calculating the target memory space based on a preset management data structure, a preset architecture alignment requirement and the required memory; if the target memory space is less than or equal to any continuous memory space in the first memory space, determining that the first memory space meets the required memory; if the target memory space is larger than the first memory space, determining that the first memory space does not meet the required memory.
[0012] In an embodiment of the present application, the memory allocated to the application needs to be managed by a specific structure, and different processor architectures have different byte alignment requirements. Therefore, when determining whether the first memory space meets the required memory, it is also necessary to combine the preset management data structure and the preset architecture alignment requirements to make a judgment in order to accurately allocate memory to the application.
[0013] In one embodiment, the heap area memory is provided by multiple physical memory blocks; when the first memory space does not meet the required memory, at least part of the memory space is awakened from the second memory space and merged into the first memory space, including: obtaining a first record value and a second record value; the first record value is used to record the identification information of the last physical memory block awakened in response to the memory application request; the second record value represents the number of physical memory blocks that have been awakened in response to the memory application request; based on the first record value and the second record value, a target physical memory block in a low power consumption state is determined; the target physical memory block is awakened; and the memory space corresponding to the target physical memory block is merged with the original first memory space to obtain a merged first memory space.
[0014] In an embodiment of the present application, the first record value is used to record the identification information of the last physical memory block that was awakened in response to the current memory application request, and the second record value represents the number of physical memory blocks that have been awakened in response to the memory application request. The first record value and the second record value can be used to accurately determine the awakening status of the physical memory block in response to the current memory application request and manage it to accurately wake up and allocate memory.
[0015] In one embodiment, determining a target physical memory block in a low power consumption state based on the first record value and the second record value includes: obtaining a physical memory block status table; the physical memory block status table includes providing memory space, identification information and status corresponding to all physical memory blocks of the heap memory; judging whether there is a physical memory block that has been awakened by the second record value; if the second record value indicates that there is no physical memory block that has been awakened, then determining the target physical memory block from the first record value in the physical memory block status table; after awakening the target physical memory block, the method further includes: updating the physical memory block status table, the first record value and the second record value in response to the awakening of the target physical memory block; wherein the first record value is updated to the identification information of the target physical memory block.
[0016] In an embodiment of the present application, the status and identification information of all physical memory blocks are recorded through a physical memory block status table, so as to quickly determine the status of each physical memory block during memory allocation, thereby improving the accuracy and timeliness of physical memory block wake-up and memory space allocation.
[0017] In one embodiment, after determining whether there is a physical memory block that has been awakened through the second record value, the method further includes: if it is determined from the physical memory block status table that there are no continuous physical memory blocks in a low-power state, and the number of physical memory blocks meets the number of physical memory blocks corresponding to the required memory, invalid information is fed back to the application to indicate that the required memory cannot be provided.
[0018] Compared to existing heap memory, in the embodiment of the present application, the heap memory is divided into a first memory space and a second memory space. When determining whether memory space can be allocated to an application, it is necessary to simultaneously determine whether the sum of the first memory space and the second memory space can meet the required memory. When the first memory space can wake up the physical memory block from the second memory space, if the required memory is still not met after the physical memory block has been woken up, that is, when the first memory space cannot meet the required memory and it is determined that there are no physical memory blocks that meet the required memory, are continuous, and are in a low-power state, invalid information is fed back to the application, so that memory management can be accurately performed even when the heap memory is divided into the first memory space and the second memory space.
[0019] In one embodiment, after receiving a memory application request from an application, the method further includes: initializing the first record value and the second record value so that the first record value is a preset invalid value, and the second record value is 0; determining the target physical memory block in the physical memory block status table starting from the first record value, including: when the first record value is the preset invalid value, determining the target physical memory block in the physical memory block status table starting from the first physical memory block of the heap memory.
[0020] In an embodiment of the present application, each time an application requests memory, the first record value and the second record value are initialized so that the current memory request is not affected by the previous memory request. Thus, on the basis of being able to reduce memory power consumption, the effectiveness and reliability of managing the physical memory block and its memory space during each memory request can also be improved.
[0021] In one embodiment, after determining whether there is a physical memory block that has been awakened through the second record value, the method further includes: if the second record value indicates that there is a physical memory block that has been awakened, determining the next physical memory block from the physical memory block status table starting from the first record value; the address of the next physical memory block is continuous with the address of the awakened physical memory block; if the next physical memory block is in the low power consumption state, waking up the next physical memory block; in response to the awakening of the next physical memory block, updating the physical memory block status table, the first record value and the second record value based on the next physical memory block.
[0022] In an embodiment of the present application, the memory allocated to the application needs to be continuous. Therefore, when waking up the physical memory block, the awakened physical memory block should be continuous with the physical memory block that has already been awakened. This can further improve the effectiveness of memory management while reducing memory power consumption.
[0023] In one embodiment, after determining the next physical memory block from the physical memory block status table starting from the first record value, the method further includes: if the next physical memory block is in a working state, configuring the awakened physical memory block to a low power consumption state; starting from the identification information of the next physical memory block, re-searching the physical memory block in the low power consumption state in the physical memory block status table and waking it up.
[0024] In an embodiment of the present application, in the same application's request for memory, the awakened physical memory blocks should be continuous. If there is no physical memory block in a low-power state that is continuous with the previously awakened physical memory block, a new physical memory block is searched for awakening. This method can improve the effectiveness of heap memory management while reducing memory power consumption.
[0025] In one embodiment, the memory space corresponding to the target physical memory block is merged with the original first memory space, including: traversing the original first memory space, searching for insertion points from the original first memory space in sequence according to the address of the target physical memory block; inserting the memory space corresponding to the target physical memory block into the original first memory space according to the insertion point, to obtain the merged first memory space.
[0026] In response to different memory application requests, the allocated physical memory blocks are different, and the addresses of the corresponding memory spaces are also different. In an embodiment of the present application, the insertion point is searched in sequence from the original first memory space according to the address of the target physical memory block, so that the memory space provided by the physical memory block can be arranged in sequence in the first memory space. This method helps to improve the effectiveness of memory management.
[0027] In one embodiment, after searching for the insertion point in sequence from the original first memory space according to the address of the target physical memory block, the method further includes: determining whether the memory space corresponding to the target physical memory block is continuous with the memory space in the original first memory space; if the memory space corresponding to the target physical memory block is continuous with the memory space in the original first memory space, merging the memory space of the target physical memory block with the continuous memory space in the first memory space.
[0028] In an embodiment of the present application, if the inserted memory space is continuous with the memory space in the original first memory space, the two are merged to help reduce memory fragmentation, making the memory space easier to manage while reducing memory power consumption.
[0029] In one embodiment, before inserting the memory space in the target physical memory block into the original first memory space according to the insertion point, the method also includes: judging whether a third record value is empty, the third record value is used to record the starting address of the first memory space; the third record value is empty, indicating that all physical memory blocks corresponding to the heap memory are in a low power consumption state; if the third record value is empty, configuring the first memory space according to the address of the target physical memory block.
[0030] In the embodiment of the present application, the starting address of the first memory space is recorded by the third record value. When the heap memory is not in use, all physical memory blocks are in a low-power state, which can effectively reduce the power consumption of the heap memory. When the heap memory needs to be used, the first memory space can be directly configured according to the address of the target physical memory block, without having to insert the memory space of the target physical memory block into a specific position. On the basis of reducing memory power consumption, the difficulty of configuring the first memory space in the heap memory is further simplified.
[0031] In one embodiment, allocating a memory space matching the required memory to the application in the first memory space includes: traversing the first memory space in address order, determining a memory space block that is greater than or equal to the target memory space from the first memory space; splitting a subspace block matching the target memory space from the memory space block; and allocating the subspace block to the application.
[0032] In an embodiment of the present application, due to the allocation and release of the first memory space in the heap memory, the memory available for allocation in the first memory space may not be continuous, but is divided into multiple parts, each part being a memory space block. Therefore, when allocating, a memory space block that is greater than or equal to the target memory space should be selected, thereby reducing the situation of allocating fragmented and discontinuous memory to the application, and improving the effectiveness of memory management while reducing memory power consumption.
[0033] In one embodiment, after traversing the first memory space in address order and determining a memory space block that is greater than or equal to the target memory space from the first memory space, the method further includes: calculating the remaining memory space after splitting the memory space block into subspace blocks that match the target memory space; if the remaining memory space is less than or equal to a preset size, allocating all of the memory space blocks to the application.
[0034] In an embodiment of the present application, the split memory space needs to be aligned according to the architecture alignment requirements, and a management data structure needs to be configured. The management data structure, the memory space required for the architecture alignment requirements, etc. need to occupy part of the memory space. Therefore, it can be determined whether the remaining memory space is less than or equal to the preset size. If the remaining memory space is less than or equal to the preset size, all the memory of the memory space block can be allocated to the application to avoid the situation where the memory space cannot be managed.
[0035] In one embodiment, after calculating the remaining memory space after splitting the memory space block to obtain a subspace block that matches the target memory space, the method further includes: if the remaining memory space is larger than the memory space required by the management data structure and the architecture alignment requirements, then after splitting the subspace block that matches the target memory space from the memory space block, configuring the remaining memory space as a new memory space block; the memory space block is the memory space in the first memory space that includes the management data structure and meets the architecture alignment requirements.
[0036] In an embodiment of the present application, if the remaining memory space obtained by splitting is larger than the memory space required for the management data structure and the architecture alignment requirements, the remaining memory space is configured as a new memory space block to facilitate the next allocation. In one embodiment, after allocating memory space that matches the required memory for the application in the first memory space, the method further includes: when the application releases memory space, obtaining the released memory space; inserting the released memory space into the first memory space in address order; judging whether the first memory space after inserting the released memory space includes all the memory space provided by an adjustable physical memory block; the adjustable physical memory block is any one of the multiple physical memory blocks that provide the heap memory; if the first memory space includes all the memory space of an adjustable physical memory block, then splitting all the memory space of the adjustable physical memory block from the first memory space and configuring the adjustable physical memory block to a low power consumption state.
[0037] In an embodiment of the present application, after an application releases memory, the released memory space is merged into the first memory space to facilitate the next allocation. The present application further determines whether the released memory, after being merged with the memory in the original first memory space, includes the entire memory space of at least one adjustable physical memory block. If the first memory space includes the entire memory space of a physical memory block, the physical memory block is configured to a low-power state to reduce power consumption.
[0038] In one embodiment, splitting the entire memory space of the adjustable physical memory block from the first memory space and configuring the adjustable physical memory block to a low power consumption state includes: determining whether the starting address of the first memory space is equal to the starting address of the adjustable physical memory block; if not, splitting the first memory space according to the starting address of the adjustable physical memory block to obtain two different first sub-memory spaces; splitting the first sub-memory space whose starting address is the same as the starting address of the adjustable physical memory block for a second time to obtain a memory space corresponding to the adjustable physical memory block; the split size of the second split is the same as the memory space size of the adjustable physical memory block; removing the memory space corresponding to the adjustable physical memory block from the first memory space; and configuring the adjustable physical memory block to a low power consumption state.
[0039] In the embodiment of the present application, by splitting twice in succession, the memory block of the adjustable physical memory block can be completely separated from the first memory space, thereby configuring it to a low power consumption state and reducing the overall power consumption of the heap memory.
[0040] In one embodiment, after the released memory space is inserted into the first memory space in address order, the method further includes: determining whether the address of the released memory space is continuous with the address of the existing memory space in the first memory space; if the addresses are continuous, merging the memory spaces with continuous addresses in the first memory space.
[0041] In an embodiment of the present application, after the released memory space is inserted into the first memory space, if the address of the released memory space is continuous with the address of the existing memory space in the first memory space, the memory space with continuous addresses in the first memory space is merged to reduce memory fragmentation and improve the effectiveness of memory management while reducing memory power consumption.
[0042] In a second aspect, an embodiment of the present application provides a system-level chip, comprising: a controller and multiple physical memory blocks; the controller is connected to the multiple physical memory blocks, and the physical memory blocks are used to provide memory space; the controller is used to execute the heap area management method based on power consumption control as described in any one of the first aspects.
[0043] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a system-level chip as described in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For those skilled in the art, other relevant drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 A flowchart of a method for managing a heap area based on power consumption control provided in one embodiment of the present application;
[0046] Figure 2 A schematic diagram of a management data structure provided in one embodiment of the present application;
[0047] Figure 3 A schematic diagram of the management data structure of the first memory space;
[0048] Figure 4 A schematic diagram of a target memory provided in one embodiment of the present application;
[0049] Figure 5 A schematic diagram of memory space merging provided in an embodiment of the present application;
[0050] Figure 6 This is a schematic diagram of the first splitting provided in the embodiment of the present application;
[0051] Figure 7 This is a schematic diagram of the second splitting provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0053] See also Figure 1 , Figure 1 This is a flow chart of a heap management method based on power consumption control provided in one embodiment of the present application. The heap management method based on power consumption control includes:
[0054] S110: Receive a memory application request from an application program.
[0055] In an embodiment of the present application, when an application needs to use memory space, it can issue a memory application request malloc to the heap area to dynamically apply for memory space. The memory application request malloc will include the application's required memory size malloc_size, which is the size of the memory space that needs to be dynamically applied for.
[0056] In an embodiment of the present application, the heap area is pre-divided, and the division method can refer to the existing technology. The heap area memory is a memory space of one or more consecutive addresses, which is configured as a dynamically allocated memory space through a preset data structure. The meaning and division method of the heap area memory can refer to the existing technology and will not be expanded here.
[0057] In the embodiments of the present application, memory space and heap memory both refer to memory allocated and used at the software level. Memory space and heap memory are provided by physical memory blocks. All memory space of heap memory can be provided by multiple physical memory blocks. The memory space provided by each physical memory block can be the same or different. Normally, each physical memory block is of the same size, but this is not a limitation.
[0058] In an embodiment of the present application, the heap memory may include two parts, namely a first memory space and a second memory space, the first memory space is in a working state and is allowed to be allocated, and the second memory space is in a low power consumption state. That is, the first memory space can be understood as an allocatable memory space. The first memory space and the second memory space are provided by different physical memory blocks. For example, all the memory space of the heap space is provided by 10 physical memory blocks, the first memory space may be provided by physical memory blocks No. 1 to No. 3, and the second memory space is provided by physical memory blocks No. 4 to No. 10. The physical memory blocks that provide the first memory space may also be referred to as allocatable memory blocks. In addition, after part of the memory space in the first memory space is allocated to an application, when calculating the remaining memory space of the first memory space, the part of the memory space that is divided out is not counted in the first memory space until the memory space that is divided out is released and merged into the first memory space.
[0059] In an embodiment of the present application, the physical memory blocks may be arranged in sequence according to the addresses of the memory spaces they provide, and representation information, such as numbering, may be configured for each physical memory block according to the arrangement order.
[0060] In the embodiments of the present application, the memory space in the heap memory in the working state is referred to as the first memory space or a portion of the first memory space, and the memory space in the low-power state is referred to as the second memory space. For ease of distinction and simplicity of description, the memory spaces in different states are described herein as the first memory space and the second memory space. In actual implementation, the heap memory may not be divided.
[0061] In the embodiments of the present application, the low-power state is achieved by performing low-power operations on the physical memory block that provides the memory space, including but not limited to performing low-power operations such as clock gating, memory shutdown, and power gating on the physical memory block, and for example, reducing the voltage, operating frequency, etc. The memory space provided by the physical memory block in the low-power state may also be referred to as the memory space in the low-power state or the second memory space.
[0062] In an embodiment of the present application, after the heap area is divided, when the heap area memory is divided, all physical memory blocks providing the heap area memory can be configured to a low power consumption state, so that all memory spaces of the heap area memory are second memory spaces. The process may include: generating the heap area memory in response to an instruction to divide the memory; initializing all physical memory blocks providing the heap area memory to configure the physical memory blocks providing the heap area memory to a low power consumption state. By configuring the physical memory blocks corresponding to all heap area memories to a low power consumption state, the power consumption of the heap area memory when the heap area memory is divided can be effectively reduced.
[0063] In other embodiments of the present application, during initialization, a portion of the physical memory blocks can be configured as a working state, and the remaining portion of the physical memory blocks can be configured as a low power state, so that memory space can be allocated in a timely manner after the heap memory is divided.
[0064] In some embodiments of the present application, initializing all physical memory blocks providing heap memory may include: obtaining a target address range of the heap memory; configuring switching control logic for all physical memory blocks corresponding to the address range of the heap memory; and configuring the physical memory blocks corresponding to the address range of the heap memory to a low power consumption state based on the switching control logic.
[0065] The switching control logic is used to switch the physical memory block from a working state to a low power consumption state, or to switch the physical memory block from a low power consumption state to a working state.
[0066] In an embodiment of the present application, different application interfaces are configured, including: an initialization interface, an application interface, and a release interface. The application interface is used to receive a memory application request from an application, and the release interface is used to receive the memory space released by the application. The application interface and the release interface can refer to the interface of the existing heap area and will not be described in detail here. The initialization interface is used to receive the address of the heap area memory when the memory is divided, that is, to receive the target address range of the heap area memory, and then configure the switching control logic between the working state and the low-power state for all physical memory blocks corresponding to the address range of the heap area memory, such as configuring the instruction for switching the working state and its corresponding execution method, such as the execution of entering the low-power state and the low-power operation required to be performed, or the instruction for waking up the physical memory block to enter the working state and the operation required to be performed, etc., thereby facilitating accurate control during the subsequent dynamic allocation of memory space and being able to respond to the instruction switching state in a timely manner. The low-power operations performed by different devices and equipment may be different. For example, the low-power operation of some devices is to reduce the internal voltage of the physical memory block, and the control logic may be to reduce the voltage and increase the voltage. For another example, the low-power operation of some devices is to turn off the clock or turn off the power. The above is only an example, and the specific content of the switching control logic will not be expanded here.
[0067] In an embodiment of the present application, a physical memory block status table can also be configured. The physical memory block status table includes the memory space (such as the corresponding address range), identification information (such as number) and status (such as working status and low power consumption status) corresponding to all physical memory blocks providing heap memory. In the physical memory block status table, each physical memory block can be sorted according to the address of the memory space or the identification information.
[0068] S120: Determine whether the first memory space meets the required memory.
[0069] In an embodiment of the present application, the heap memory includes a first memory space and a second memory space. The first memory space can be directly allocated, and the physical memory block corresponding to the second memory space is configured in a low-power state, which can effectively reduce power consumption. Therefore, it can be determined whether the first memory space meets the required memory. If so, the first memory space is directly allocated. If not, it is woken up from the second memory space to reduce power consumption.
[0070] In one embodiment of the present application, determining whether a first memory space meets the required memory may include: determining the required memory from a memory application request; calculating a continuous target memory space based on a preset management data structure, a preset architecture alignment requirement and the required memory; if the target memory space is less than or equal to the first memory space, determining that the first memory space meets the required memory; if the target memory space is larger than the first memory space, determining that the first memory space does not meet the required memory.
[0071] When allocating memory to an application, it's allocated based on the application's needs. Therefore, the memory request contains the application's memory requirements. During memory allocation, the required memory can be determined from the request. For example, the request includes the parameter malloc_size, which specifies the size of the memory to be dynamically allocated. The required memory can be determined by determining the value of malloc_size.
[0072] The memory space allocated to the application should be continuous. Therefore, the target memory space should also have a continuous address, rather than a combination of multiple discontinuous memory spaces. Accordingly, as the heap memory is dynamically allocated and released by the application, the first memory space also changes dynamically and may be divided into multiple memory spaces. Therefore, when determining whether the required memory is met, it is possible to determine whether the target memory space is less than or equal to any continuous memory space in the first memory space.
[0073] Heap memory can be dynamically allocated and released by applications. To facilitate the management of heap memory, you can configure corresponding data structures for the memory space of the heap memory. Figure 2 , Figure 2 A schematic diagram of a management data structure provided in an embodiment of the present application.
[0074] In an embodiment of the present application, the management data structure of a memory space block includes pointer information p_next, size information size, and available memory. The pointer information p_next is used to point to the address of the next allocatable memory space block. If it is empty, it indicates that the memory space block is the last allocatable memory space block in the first memory space. The size information size indicates the size of the current memory space block. The memory space block includes the pointer information p_next, the memory occupied by the size information size, and the available memory.
[0075] A memory space block is a memory space obtained by splitting the first memory space or the second memory space and having a preset management data structure. Any of the heap memory, the first memory space, or the second memory space can include multiple memory space blocks. The size of each memory space block can be different, determined based on the actual splitting and combination of the memory space. A memory space block is a software-level memory space. The memory space provided by a physical memory block can be split into one or more memory space blocks. The same memory space block can also span different physical memory blocks.
[0076] See also Figure 3 , Figure 3This is a schematic diagram of the management data structure of the first memory space. In addition to the management data structure of each memory space block, a global variable g_start is also configured in the management data structure of the first memory space. The global variable g_start points to the first allocatable memory space block of the first memory space.
[0077] The architectural alignment requirement refers to the alignment size in bytes required by different processor architectures. Different processor architectures have different default architectural alignment requirements. For example, some 32-bit processors require 4 bytes, while 64-bit processors require 8 bytes. The architectural alignment requirement can be expressed as: LP_HEAP_CONFIG_ALIGNED_SIZE, or simply Align.
[0078] See also Figure 4 , Figure 4 A schematic diagram of target memory provided for one embodiment of the present application shows that, based on the aforementioned management data structure and architecture alignment requirements, the target memory actually required when allocating memory space for an application can be determined to include the management data structure (e.g., pointer information p_next, size information size), the memory space required by the architecture alignment requirements (Align), and the required memory. Align can be 0.
[0079] Therefore, in an embodiment of the present application, when determining whether the first memory space meets the required memory, a target memory space is calculated based on a preset management data structure, preset architecture alignment requirements, and the required memory, and then the target memory space is compared with the first memory space. If the target memory space is less than or equal to the first memory space, it is determined that the first memory space meets the required memory; if the target memory space is greater than the first memory space, it is determined that the first memory space does not meet the required memory. For example, if the target memory space is need_size and the first memory space is g_remain_size, the size relationship between need_size and g_remain_size is determined.
[0080] S130: When the first memory space does not meet the required memory, wake up at least part of the memory space from the second memory space and merge it into the first memory space, so that the first memory space meets the required memory.
[0081] In some embodiments of the present application, if the first memory space does not meet the required memory, indicating that the first memory space cannot provide sufficient memory for the application, at least part of the memory space can be awakened from the second memory space and merged into the first memory space so that the first memory space meets the required memory. Awakening refers to causing the physical memory block corresponding to the memory space in a low-power state to exit the low-power state and enter a working state.
[0082] In an embodiment of the present application, waking up at least part of the memory space from the second memory space and merging it into the first memory space may include: obtaining a first record value and a second record value; determining a target physical memory block in a low power consumption state based on the first record value and the second record value; waking up the target physical memory block; merging the memory space corresponding to the target physical memory block with the original first memory space to obtain a merged first memory space.
[0083] Since part of the memory space in the heap area of this application will be configured as a low-power state and needs to be woken up when memory is allocated, it is necessary to manage the state of the physical memory block and record the operations performed by each memory application to accurately control memory allocation.
[0084] In an embodiment of the present application, the first record value is used to record the identification information of the last physical memory block awakened in response to the current memory request; the second record value represents the number of physical memory blocks awakened in response to the current memory request. Some applications require a small amount of memory and may only need to awaken one physical memory block, while other applications require a large amount of memory and may need to awaken multiple physical memory blocks. The first and second record values can be used to record the awakening of physical memory blocks for each memory request.
[0085] Since the first record value and the second record value are record values for each memory application request, each time a memory application request is received from the receiving application, the first record value and the second record value can be initialized so that the first record value is a preset invalid value and the second record value is 0. For example, the first record value last_power_on_id is a preset invalid value and the second record value block_num = 0.
[0086] If the second record value is 0, the physical memory blocks in the low-power state can be searched sequentially from the starting position of the first memory space, the first physical memory block found can be awakened, and the first record value is used as the identification information of the first awakened physical memory block, and 1 is added to the second record value. If the second record value is not 1, the physical memory blocks in the low-power state can be searched sequentially from the position of the first record value and awakened, the first record value is updated according to the identification information of the awakened physical memory block, and 1 is added to the second record value.
[0087] In an embodiment of the present application, determining a target physical memory block in a low-power state based on a first record value and a second record value may include: obtaining a physical memory block status table; determining whether a physical memory block has been awakened based on the second record value; if the second record value indicates that no physical memory block has been awakened, determining the target physical memory block from the first record value in the physical memory block status table. And, after waking up the target physical memory block, in response to the awakening of the target physical memory block, updating the physical memory block status table, the first record value, and the second record value; wherein the first record value is updated to the identification information of the target physical memory block.
[0088] As mentioned above, the physical memory block status table includes the memory space, identification information and status corresponding to all physical memory blocks that provide heap memory. Through the physical memory block status table, the status of each physical memory block can be quickly determined, thereby determining the physical memory block in the low power consumption state, improving the wake-up efficiency of the physical memory block, and thus improving the memory allocation efficiency.
[0089] Wherein, when the first record value is a preset invalid value, determining the target physical memory block based on the first record value may be determining the target physical memory block from the first physical memory block of the heap memory in the physical memory block status table.
[0090] In one embodiment of the present application, if it is determined from the physical memory block status table that there are no physical memory blocks in a low power consumption state whose number meets the number of continuous physical memory blocks corresponding to the required memory, invalid information is fed back to the application to indicate that the required memory cannot be provided.
[0091] The memory space provided by a single physical memory block may not meet the required memory, requiring multiple physical memory blocks to meet the required content. Therefore, the physical memory block status can be used to determine whether the number of physical memory blocks in a low-power state meets the required memory. Furthermore, the physical memory blocks provided to the application should be contiguous, so both quantity and contiguousness can be used to determine whether the required memory is met.
[0092] For example, the parameter cur_power_on_id represents identification information of the physical memory block awakened by this memory application request. An invalid value of cur_power_on_id may be fed back to the application to indicate that the requested memory cannot be provided.
[0093] Each time a physical memory block is woken up, the memory space of the woken physical memory block can be merged into the first memory space, and then memory allocation is performed. If sufficient memory space cannot be allocated for the application (i.e., allocation fails), the process of waking up a new physical memory block is entered.
[0094] When multiple physical memory blocks need to be awakened to provide sufficient memory space, starting from the second wake-up process, the second record value is not 0, and it is judged that there is a physical memory block that has been awakened. In some embodiments of the present application, the process of awakening multiple physical memory blocks may include: if the second record value indicates that there is a physical memory block that has been awakened, then determining the next physical memory block from the physical memory block status table starting from the first record value; if the next physical memory block is in a low power consumption state, then waking up the next physical memory block; in response to the awakening of the next physical memory block, updating the physical memory block status table, the first record value, and the second record value based on the next physical memory block.
[0095] In this embodiment, the address of the next physical memory block is continuous with the address of the awakened physical memory block. As previously described, the physical memory block status table is sorted according to the address sequence. Therefore, determining whether the addresses are continuous can be determining whether the serial numbers of the physical memory blocks are continuous. For example, if the serial number of the first record value is 3, the serial number of the next physical memory block is 4.
[0096] Update the physical memory block status table, the first record value and the second record value based on the next physical memory block. This can be to update the status of the physical memory block in the physical memory block status table to the working status, update the first record value to the serial number of the physical memory block, and add 1 based on the second record value.
[0097] In an embodiment of the present application, the physical memory blocks with continuous addresses are awakened so that the memory space provided by the awakened physical memory blocks is continuous with the first memory space, which facilitates memory management.
[0098] In some embodiments of the present application, after determining the next physical memory block from the physical memory block status table starting from the first record value, the method also includes: if the next physical memory block is in a working state, configuring the awakened physical memory block to a low power consumption state; starting from the identification information of the next physical memory block, re-searching the physical memory block in the low power consumption state in the physical memory block status table and waking it up.
[0099] For example, if the first record value is last_power_on_id, the identification information of the next physical memory block is last_power_on_id + 1. For example, if the first physical memory block awakened is physical memory block 3 (last_power_on_id is 3), then the next physical memory block is physical memory block 4 (last_power_on_id + 1 = 4). If physical memory block 4 is in the working state, physical memory block 3 needs to be reconfigured to the low power state, and a new physical memory block in the low power state is searched after physical memory block 4 and awakened.
[0100] This method can make the awakened physical memory block and its memory space continuous, thereby further facilitating the management of the memory space while reducing memory power consumption.
[0101] In an embodiment of the present application, after the target physical memory block is awakened, the memory space provided by the target physical memory block will belong to the first memory space, and the memory space corresponding to the target physical memory block is merged with the original first memory space to obtain the merged first memory space, which may refer to configuring a corresponding management data structure for the memory space corresponding to the target physical memory block and making it meet the preset architecture alignment requirements, as well as modifying the pointing information of the management data structure of other memory space blocks in the first memory space, so that the memory space of the original first memory space and the memory space corresponding to the target physical memory block have an address association relationship.
[0102] In one embodiment of the present application, merging the memory space corresponding to the target physical memory block with the original first memory space may include: traversing the original first memory space, searching for insertion points from the original first memory space in sequence according to the address of the target physical memory block; inserting the memory space corresponding to the target physical memory block into the original first memory space according to the insertion point to obtain the merged first memory space.
[0103] In this embodiment, the heap memory is dynamically allocated and released. The memory space block records the size information size and pointing information p_next of each memory space block through the management data structure. The next memory space block is determined by the pointing information, and the addresses of the memory space blocks of the first memory space are also arranged in sequence. Therefore, when a memory space corresponding to a new target physical memory block needs to be inserted, it is necessary to determine the insertion point to be inserted, and the pointing information of the previous memory space block of the insertion point is modified to point to the memory space corresponding to the target physical memory block through the address of the insertion point. At the same time, the memory space corresponding to the target physical memory block is configured with a corresponding preset management data structure and aligned according to the architecture alignment requirements, so that the pointing information p_next corresponding to the physical memory block points to the address of the memory space block after the insertion point.
[0104] In an embodiment of the present application, if the memory space corresponding to the target physical memory block is continuous with the original first memory space in terms of address, the preset management data structure between the two can also be deleted so that the two are merged into one memory space block.
[0105] In this embodiment, after searching for the insertion point in sequence from the original first memory space according to the address of the target physical memory block, the method may further include: determining whether the memory space corresponding to the target physical memory block is continuous with the memory space in the original first memory space; if the memory space corresponding to the target physical memory block is continuous with the memory space in the original first memory space, merging the memory space of the target physical memory block with the continuous memory space in the first memory space.
[0106] The above method is usually for the case where the first memory space already has a memory space block. If the physical memory blocks of the heap memory are all in a low power state, the first memory space does not exist at this time, or the first memory space is empty, and the insertion point cannot be found.
[0107] Therefore, before traversing the original first memory space and searching for the insertion point in sequence from the original first memory space according to the address of the target physical memory block, it is also possible to determine whether the third record value is empty. If the third record value is empty, the first memory space is configured according to the address of the target physical memory block.
[0108] The third record value can be expressed as g_start.p_next, which is used to record the starting address of the first memory space. If the third record value is empty, it indicates that all physical memory blocks corresponding to the heap memory are in a low power state. For example, when the heap memory is divided, all physical memory blocks of the heap memory are configured to a low power state, or, after all physical memory blocks of the heap memory are released by the application, all physical memory blocks are configured to a low power state.
[0109] The target physical memory block is represented as insert_block. If the third record value is empty, it indicates that there is no memory space block in the first memory space. In this case, the target physical memory block insert_block can be directly configured with pointing information and size information, and the global variable can be configured as the address of the target physical memory block insert_block to configure the memory space of the target physical memory block insert_block as the first memory space. When a new physical memory block is subsequently awakened, the memory space can be merged based on the relationship between the address of the newly awakened physical memory block and the address of the previously awakened physical memory block.
[0110] See also Figure 5 , Figure 5A schematic diagram of memory space merging provided for an embodiment of the present application. In this schematic diagram, before merging, four memory space blocks are included. For example, the first four p_nexts are four memory space blocks respectively, and the last p_next points to null, while the second, third, and fourth are continuous. For example, the starting address of p_free_mem_block is continuous with the ending address of p_insert_block, and the ending address of p_free_mem_block is continuous with the starting address of the next memory space block. Then, the three can be merged into a complete memory space block to reduce memory fragmentation.
[0111] For ease of understanding, an example is provided here to illustrate the process of inserting the target physical memory block into the application.
[0112] For example, in one embodiment, when a target physical memory block needs to be inserted into the first memory space, a determination is first made as to whether the third record value is empty. If so, the first memory space is directly allocated according to the address of the target physical memory block. If not, an insertion point is found, and then the memory space corresponding to the target physical memory block at the insertion point is inserted into the original first memory space.
[0113] S140 : When the first memory space satisfies the required memory, allocate memory space matching the required memory to the application program in the first memory space.
[0114] In an embodiment of the present application, when the first memory space meets the required memory, the memory space that meets the required memory can be split out from the first memory space and allocated to the application, and the allocated memory space can be removed from the first memory space. You can refer to the existing memory allocation and will not elaborate here.
[0115] In an embodiment of the present application, if it is determined in S120 whether the first memory space meets the required memory, if the first memory space meets the required memory, S140 can be directly executed without executing the process of S130.
[0116] In one embodiment, allocating memory space that matches the required memory for the application in the first memory space may include: traversing the first memory space in address order, determining a memory space block that is greater than or equal to the target memory space from the first memory space; splitting a subspace block that matches the target memory space from the memory space block; and allocating the subspace block to the application.
[0117] In the embodiments of the present application, each memory space allocated to an application must be configured as a preset management data structure and meet preset architectural alignment requirements. Therefore, in the embodiments of the present application, a memory space block that is greater than or equal to the target memory space must be determined from the first memory space. This memory space block is then split into subspace blocks allocated to the application. A subspace block is obtained by splitting a memory space block, and is itself a memory space block. Different names are used here for ease of distinction.
[0118] In this embodiment, traversing the first memory space according to the address sequence helps to manage the first memory space in an orderly manner.
[0119] In one embodiment of the present application, if the remaining memory space block after the split is too small or even cannot be configured as a memory space block, there is no need to reconfigure the remaining memory space into a new memory space block.
[0120] Therefore, in one embodiment of the present application, after determining a memory space block that is greater than or equal to the target memory space from the first memory space, the remaining memory space after splitting the memory space block into subspace blocks that match the target memory space can also be calculated; if the remaining memory space is less than or equal to the preset size, the entire memory space block is allocated to the application. The preset size can be configured based on the management data structure and architecture alignment requirements, and is not limited here. In this way, memory space management can be facilitated.
[0121] On the contrary, after calculating the remaining memory space after splitting the memory space block into a subspace block that matches the target memory space, if the remaining memory space is larger than the preset size, then after splitting the subspace block that matches the target memory space from the memory space block, the remaining memory space is configured as a new memory space block; the memory space block is a memory space in the first memory space that includes a management data structure and meets the architectural alignment requirements.
[0122] The above process mainly describes the allocation of memory space, and the application will release the memory space after completing the task. Accordingly, in the embodiment of the present application, an execution method after the application releases the memory space is also provided.
[0123] In one embodiment of the present application, when an application releases memory space, the released memory space is obtained; the released memory space is inserted into the first memory space in address order; it is determined whether the first memory space after the released memory space is inserted includes all the memory space provided by an adjustable physical memory block; if the first memory space includes all the memory space of at least one adjustable physical memory block, the all the memory space of the adjustable physical memory block is split from the first memory space and the adjustable physical memory block is configured to a low power consumption state.
[0124] Inserting the released memory space into the first memory space in address order can refer to the process of inserting the memory space of the awakened physical memory block into the first memory space. The released memory space can also be merged with the existing memory space block of the first memory space, which will not be expanded here.
[0125] In an embodiment of the present application, the adjustable physical memory block is any one of the multiple physical memory blocks that provide the heap memory. If the first memory space includes all the memory space provided by a physical memory block, then the physical memory block can be used as an adjustable physical memory block, split out from the first memory space, and the physical memory block can be configured to a low power consumption state to reduce power consumption.
[0126] In one embodiment of the present application, after the released memory space is inserted into the first memory space in address order, the method also includes: determining whether the address of the released memory space is continuous with the address of the existing memory space in the first memory space; if the addresses are continuous, merging the memory spaces with continuous addresses in the first memory space.
[0127] The merging process can be referred to the above content and will not be described in detail here. In the case where the address of the released memory space is continuous with the address of the existing memory space, the released memory space is merged with the existing memory space to reduce memory fragmentation and facilitate memory management.
[0128] In one embodiment of the present application, splitting the entire memory space of the adjustable physical memory block from the first memory space and configuring the adjustable physical memory block to a low power consumption state may include: determining whether the starting address of the first memory space is equal to the starting address of the adjustable physical memory block; if not, splitting the first memory space according to the starting address of the adjustable physical memory block to obtain two different first sub-memory spaces; splitting the first sub-memory space having the same starting address as the starting address of the adjustable physical memory block for a second time to obtain a memory space corresponding to the adjustable physical memory block; wherein the split size of the second split is the same as the memory space size of the adjustable physical memory block; removing the memory space corresponding to the adjustable physical memory block from the first memory space; and configuring the adjustable physical memory block to a low power consumption state.
[0129] In this embodiment, the splitting of the adjustable physical memory block is divided into two splits. The first split is performed based on the starting address of the adjustable physical memory block. For example, see Figure 6 , Figure 6The first splitting schematic diagram provided for the embodiment of the present application, the original first memory space includes part of the memory of physical memory block A and all the memory of physical memory block B, and is split according to the starting address of physical memory block B, and the starting address of the first memory space is adjusted. The starting address of the original first memory space is p_lower_power_block. After the first splitting, physical memory block A and physical memory block B are obtained, the starting address of physical memory block A is p_head_block, and the starting address of physical memory block B is p_lower_power_block_align, and the memory space of the split physical memory block B is used as a new memory space block, and the starting address p_lower_power_block_align of physical memory block B is used as the starting address of the new memory space block.
[0130] The second split is done with adjustable physical memory block size, see Figure 7 , Figure 7 In the second splitting diagram provided in the embodiment of the present application, the addresses of physical memory block B and physical memory block C are continuous, and they can be split according to the size of physical memory block B, so that the starting address p_tail_block of physical memory block C is used as the starting address of the new memory space block. In this way, physical memory block B can be completely removed from the first memory space.
[0131] Therefore, compared to the method of not switching the state of the heap memory, the method provided by the above embodiment of the present application can enable the heap memory to switch between the working state and the low power consumption state, thereby reducing the power consumption of the heap memory. Accordingly, since the prior art does not require state switching, and does not require the configuration of a corresponding control method, in the embodiments of the present application, different methods are provided at different stages, so that the memory allocation, release, and merging can be accurately controlled on the basis of the first memory space and the second memory space, and on the basis of reducing memory power consumption, the effectiveness and reliability of the heap management executed when the heap memory needs to switch the state are further improved.
[0132] Based on the same inventive concept, an embodiment of the present application also provides a system-level chip, which includes a controller and multiple physical memory blocks; the controller is connected to the multiple physical memory blocks, and the physical memory blocks are used to provide memory space; the controller is used to execute the heap area management method based on power consumption control provided in any of the aforementioned embodiments.
[0133] In the embodiment of the present application, the controller may include one or more processor cores.
[0134] In an embodiment of the present application, the system-level chip can be a processor, for example, the system-level chip can be a GPU (Graphics Processing Unit), a CPU (Central Processing Unit), an AI (Artificial Intelligence), an NPU (Neural Network Processing Unit), an ISP (Image Signal Processor), a DPU (Display Processing Unit), a VPU (Video Processing Unit), a DSP (Digital Signal Processor) data processing core, etc., or it can be a chip used in some scenarios such as large-scale data computing. The above is only an example and should not be a limitation to the present application.
[0135] Based on the same inventive concept, an embodiment of the present application further provides an electronic device, which includes the system-on-chip provided in the aforementioned embodiment. The electronic device may also include other modules, such as a memory, a communication module, etc., which are not limited here.
[0136] In the embodiments of the present application, the electronic device may be a computer, a mobile phone, a server, a vehicle-mounted device, a home appliance, an industrial computer, etc.
[0137] In other embodiments, the electronic device may be a wearable device, such as a Bluetooth headset, a smart bracelet, smart glasses, a smart watch, etc. Wearable devices have high requirements for power consumption. The system-level chip of the electronic device can execute the heap area management method based on power consumption control provided in the embodiment of the present application, which helps to reduce power consumption.
[0138] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
[0139] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
Claims
1. A method for managing a heap area based on power consumption control, characterized in that: include: Receive memory application requests from applications; The memory application request includes the required memory of the application program; Determining whether the first memory space meets the required memory; The first memory space belongs to a heap memory, and the heap memory also includes a second memory space, wherein: the first memory space is in a working state and allows allocation, and the second memory space is in a low power consumption state; In a case where the first memory space does not meet the required memory, waking up at least part of the memory space from the second memory space and merging it into the first memory space, so that the first memory space meets the required memory; In a case where the first memory space meets the required memory, a memory space matching the required memory is allocated to the application in the first memory space.
2. The method according to claim 1, characterized in that Before receiving the memory application request from the application, the method includes: In response to the memory partition instruction, generating the heap area memory; All physical memory blocks providing the heap memory are initialized to configure the physical memory blocks providing the heap memory to a low power consumption state, wherein the second memory space is provided by the physical memory blocks in the low power consumption state.
3. The method according to claim 1, characterized in that Initializing all physical memory blocks providing the heap area memory includes: Obtaining a target address range of the heap memory; Configuring switching control logic for all physical memory blocks corresponding to the address range of the heap memory; wherein the switching control logic is used to switch the physical memory blocks from the working state to the low power state, or switch the physical memory blocks from the low power state to the working state; The physical memory block corresponding to the address range of the heap memory is configured to be in a low power consumption state based on the switching control logic.
4. The method according to claim 1, wherein The determining whether the first memory space meets the required memory includes: Determining the required memory from the memory application request; Calculating a target memory space based on a preset management data structure, a preset architecture alignment requirement, and the required memory; If the target memory space is smaller than or equal to any continuous memory space in the first memory space, determining that the first memory space meets the required memory; If the target memory space is larger than the first memory space, it is determined that the first memory space does not meet the required memory.
5. The method according to claim 4, characterized in that The heap memory is provided by a plurality of physical memory blocks; when the first memory space does not meet the required memory, waking up at least part of the memory space from the second memory space and merging it into the first memory space, including: Obtain a first record value and a second record value; the first record value is used to record identification information of the last physical memory block awakened in response to the memory application request; the second record value represents the number of physical memory blocks that have been awakened in response to the memory application request; Determine a target physical memory block in a low power consumption state based on the first recorded value and the second recorded value; Waking up the target physical memory block; The memory space corresponding to the target physical memory block is merged with the original first memory space to obtain a merged first memory space.
6. The method according to claim 5, characterized in that The determining of a target physical memory block in a low power consumption state based on the first record value and the second record value includes: Obtaining a physical memory block status table; the physical memory block status table includes memory space, identification information, and status corresponding to all physical memory blocks providing the heap area memory; Determine whether there is an awakened physical memory block according to the second record value; If the second record value indicates that there is no awakened physical memory block, determining the target physical memory block from the first record value in the physical memory block status table; After waking up the target physical memory block, the method further includes: In response to the awakening of the target physical memory block, the physical memory block status table, the first record value, and the second record value are updated; wherein the first record value is updated to the identification information of the target physical memory block.
7. The method according to claim 6, characterized in that After determining whether there is an awakened physical memory block according to the second record value, the method further includes: If it is determined from the physical memory block status table that there are no continuous physical memory blocks in a low power consumption state that meet the number of physical memory blocks corresponding to the required memory, invalid information is fed back to the application to indicate that the required memory cannot be provided.
8. The method according to claim 6, characterized in that After receiving the memory application request from the application, the method further includes: Initializing the first record value and the second record value so that the first record value is a preset invalid value and the second record value is 0; The target physical memory block is determined in the physical memory block status table from the first record value, including: when the first record value is the preset invalid value, the target physical memory block is determined in the physical memory block status table from the first physical memory block of the heap memory.
9. The method according to claim 8, characterized in that After determining whether there is an awakened physical memory block according to the second record value, the method further includes: If the second record value indicates that there is an awakened physical memory block, then determining the next physical memory block from the physical memory block state table starting from the first record value; the next physical memory block has an address continuous with the awakened physical memory block; If the next physical memory block is in the low power consumption state, waking up the next physical memory block; In response to the awakening of the next physical memory block, the physical memory block status table, the first record value, and the second record value are updated based on the next physical memory block.
10. The method according to claim 9, characterized in that After determining the next physical memory block from the physical memory block status table starting from the first record value, the method further includes: If the next physical memory block is in a working state, configuring the awakened physical memory block to a low power consumption state; Starting from the identification information of the next physical memory block, the physical memory block in the low power consumption state is searched again in the physical memory block state table and awakened.
11. The method according to claim 5, characterized in that The merging of the memory space corresponding to the target physical memory block with the original first memory space includes: Traversing the original first memory space, searching for insertion points in order from the original first memory space according to the address of the target physical memory block; The memory space corresponding to the target physical memory block is inserted into the original first memory space according to the insertion point to obtain the merged first memory space.
12. The method according to claim 11, characterized in that After searching for insertion points in order from the original first memory space according to the address of the target physical memory block, the method further includes: Determining whether the memory space corresponding to the target physical memory block is continuous with the memory space in the original first memory space; If the memory space corresponding to the target physical memory block is continuous with the memory space in the original first memory space, the memory space of the target physical memory block is merged with the continuous memory space in the first memory space.
13. The method according to claim 11, characterized in that Before searching for insertion points in the original first memory space in order according to the address of the target physical memory block, the method further includes: Determine whether a third record value is empty, the third record value being used to record the starting address of the first memory space; if the third record value is empty, it indicates that all physical memory blocks corresponding to the heap memory are in a low power consumption state; If the third record value is empty, the first memory space is configured according to the address of the target physical memory block.
14. The method according to claim 4, characterized in that The allocating a memory space matching the required memory for the application in the first memory space includes: Traversing the first memory space in address order, and determining a memory space block from the first memory space that is larger than or equal to the target memory space; Splitting a subspace block matching the target memory space from the memory space block; The subspace blocks are assigned to the applications.
15. The method according to claim 14, characterized in that After traversing the first memory space in address order and determining a memory space block from the first memory space that is larger than or equal to the target memory space, the method further includes: Calculating the remaining memory space after splitting the memory space block into subspace blocks matching the target memory space; If the remaining memory space is less than or equal to a preset size, all of the memory space blocks are allocated to the application.
16. The method according to claim 15, characterized in that After calculating the remaining memory space after splitting the memory space block into subspace blocks matching the target memory space, the method further includes: If the remaining memory space is larger than the preset size, after splitting a subspace block matching the target memory space from the memory space block, the remaining memory space is configured as a new memory space block; the memory space block is the memory space in the first memory space that includes the management data structure and meets the architecture alignment requirements.
17. The method according to any one of claims 1 to 16, characterized in that After allocating memory space matching the required memory to the application in the first memory space, the method further includes: When the application releases the memory space, acquiring the released memory space; Inserting the released memory space into the first memory space in address order; Determining whether the first memory space after inserting the released memory space includes all memory spaces provided by at least one adjustable physical memory block; the adjustable physical memory block is any one of a plurality of physical memory blocks providing the heap memory; If the first memory space includes the entire memory space of an adjustable physical memory block, the entire memory space of the adjustable physical memory block is split from the first memory space and the adjustable physical memory block is configured to be in a low power consumption state.
18. The method according to claim 17, characterized in that The step of splitting the entire memory space of the adjustable physical memory block from the first memory space and configuring the adjustable physical memory block to a low power consumption state includes: Determining whether the starting address of the adjustable physical memory block is equal to the starting address of any allocatable sub-memory space in the first memory space; If not equal, splitting the first memory space according to the start address of the adjustable physical memory block to obtain two different first sub-memory spaces; Performing a second split on the first sub-memory space having the same starting address as the starting address of the adjustable physical memory block to obtain a memory space corresponding to the adjustable physical memory block; the split size of the second split is the same as the size of the memory space of the adjustable physical memory block; Removing the memory space corresponding to the adjustable physical memory block from the first memory space; The adjustable physical memory block is configured to be in a low power consumption state.
19. The method according to claim 17, wherein After inserting the released memory space into the first memory space in address order, the method further includes: Determining whether the released memory space is continuous with an address of an existing memory space in the first memory space; If the addresses are continuous, the memory spaces with continuous addresses in the first memory space are merged.
20. A system-on-chip, characterized in that: include: controller, multiple physical memory blocks; The controller is connected to the plurality of physical memory blocks, and the physical memory blocks are used to provide memory space; The controller is used to execute the heap area management method based on power consumption control as described in any one of claims 1-19.
21. An electronic device, characterized in that: include: The system-on-chip as claimed in claim 20.