Memory management method and apparatus, device, and storage medium

By allocating different memory regions for different tasks in the terminal device and adopting multiple memory management strategies, the memory fragmentation problem is solved, and system stability and device performance are improved.

CN122309112APending Publication Date: 2026-06-30GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
Filing Date
2024-12-31
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In existing technologies, during the memory management process of terminal devices, severe memory fragmentation occurs because all tasks are allocated in the same memory area, leading to device malfunctions or lag.

Method used

Different tasks are assigned to different memory regions, multiple memory management strategies are adopted, and memory management is implemented through business layer interfaces to avoid memory fragmentation and improve system stability.

Benefits of technology

By managing different tasks in different memory regions, device failures and lags are reduced, the system stability of terminal devices is improved, and the business layer and memory management are decoupled.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309112A_ABST
    Figure CN122309112A_ABST
Patent Text Reader

Abstract

This application discloses a memory management method, apparatus, device, and storage medium. The method includes: when performing memory management on a target task, managing the target task's memory according to a target memory management strategy corresponding to the target task. The target memory management strategy includes: at least one pre-divided memory region corresponding to the target task, each pre-divided memory region being a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks. This allows different tasks to be allocated to different memory regions, thereby reducing memory fragmentation and preventing terminal device malfunctions or lag.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to data storage technology, including but not limited to a memory management method, apparatus, device, and storage medium. Background Technology

[0002] In the process of memory management of terminal devices, it is usually necessary to allocate and release memory for tasks.

[0003] In the process of allocating memory for tasks, the technical means used in related technologies is to allocate the memory of all tasks to the same memory area, which will lead to severe memory fragmentation and may cause problems such as malfunction or lag in terminal devices. Summary of the Invention

[0004] In view of this, the memory management method, apparatus, device, and storage medium provided in the embodiments of this application can allocate different tasks to different memory regions, thereby reducing memory fragmentation and preventing terminal device malfunctions or lag. The memory management method, apparatus, device, and storage medium provided in the embodiments of this application are implemented as follows:

[0005] One aspect of this application provides a memory management method applied to a terminal device, the method comprising:

[0006] When memory management is performed on the target task, the target memory management is performed according to the target memory management strategy corresponding to the target task. The target memory management strategy includes: at least one pre-divided memory region corresponding to the target task, each pre-divided memory region being a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks.

[0007] Another aspect of the embodiments of this application provides a memory management device applied to a terminal device, the device including: a management module;

[0008] The management module is used to manage the memory of the target task according to the target memory management strategy corresponding to the target task when performing memory management on the target task. The target memory management strategy includes: at least one pre-divided memory region corresponding to the target task, each pre-divided memory region being a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks.

[0009] The computer device provided in this application includes a memory and a processor. The memory stores a computer program that can run on the processor, and the processor executes the program to implement the method of this application.

[0010] The computer-readable storage medium provided in this application embodiment stores a computer program thereon, which, when executed by a processor, implements the method provided in this application embodiment.

[0011] The memory management method, apparatus, device, and storage medium provided in this application embodiment can manage the memory of a target task according to a target memory management strategy corresponding to the target task. The target memory management strategy includes at least one pre-divided memory region corresponding to the target task. Each pre-divided memory region is a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks. By using different memory management strategies, different tasks can be managed, and different tasks can be managed in different memory regions. This avoids memory fragmentation problems, thereby reducing terminal device failures or lag, and improving the system stability of the terminal device. Furthermore, the business layer only needs to implement memory management through an interface, without needing to pay attention to the actual memory management situation, and can also achieve decoupling between the business layer and memory management. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a schematic diagram illustrating the application scenario of the terminal device provided in the embodiments of this application;

[0014] Figure 2 This is a flowchart illustrating the memory management method provided in the embodiments of this application;

[0015] Figure 3 This is a schematic diagram of the software execution of the terminal device provided in the embodiments of this application;

[0016] Figure 4 A schematic diagram illustrating the memory management process of the terminal device provided in this application embodiment;

[0017] Figure 5 A flowchart illustrating the process of determining a target memory management strategy for a terminal device provided in this application embodiment;

[0018] Figure 6 This is another flowchart illustrating the memory management method provided in the embodiments of this application;

[0019] Figure 7 This is a schematic diagram illustrating the memory management strategy provided in the embodiments of this application;

[0020] Figure 8 This is a schematic diagram illustrating the process of updating the memory management strategy provided in the embodiments of this application;

[0021] Figure 9 This is a schematic diagram of another application scenario of the terminal device provided in the embodiments of this application;

[0022] Figure 10 This is a schematic diagram of the memory allocation triggering process provided in the embodiments of this application;

[0023] Figure 11 This is a schematic diagram of the structure of the memory management device provided in the embodiments of this application;

[0024] Figure 12 This is a schematic diagram of the structure of the terminal device provided in the embodiments of this application. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of this application will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application.

[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0027] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0028] It should be noted that the terms "first, second, third" used in the embodiments of this application are used to distinguish similar or different objects and do not represent a specific order of objects. It can be understood that "first, second, third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0029] To more clearly explain the memory management method provided in the embodiments of this application, the actual application scenarios of the method are described below.

[0030] Figure 1 This is a schematic diagram illustrating the application scenario of the terminal device provided in the embodiments of this application. Please refer to... Figure 1 This scenario includes a terminal device 110, which may include, but is not limited to, mobile phones, wearable devices (such as smartwatches, smart bracelets, smart glasses, etc.), tablets, laptops, in-vehicle terminals, PCs (Personal Computers), etc. The functions implemented by this method can be achieved by the processor in the terminal device calling program code. Of course, the program code can be stored in computer storage media. Therefore, the terminal device includes at least a processor and storage media.

[0031] It should be noted that corresponding tasks can run on the terminal device. A task can consist of one or more processes, or one or more threads, and can be a task generated by any application on the terminal device.

[0032] For example, opening an application can be considered a task, displaying preset content through an application can be considered a task, and playing audio or video through an application can also be considered a task. There are no specific restrictions here, and any task that a terminal device needs to perform can be considered a task according to actual needs.

[0033] During the execution of each task, memory management is required for these tasks. For example, allocating corresponding memory to these tasks before execution and releasing the memory allocated to these tasks after completion.

[0034] Optionally, memory management can include memory allocation and memory release, and any task executed in the terminal device can perform corresponding memory management.

[0035] In related technologies, different interfaces or different interface parameters can be used to manage memory in different regions during the memory management process, such as the FreeRTOS heap6 interface.

[0036] However, for some devices that only have one interface and cannot call interface parameters, memory management can only be achieved through the same interface, such as rt-thread's rt_malloc interface and libc's standard malloc interface.

[0037] For such devices, memory can usually only be allocated to all tasks in the same memory area. This leads to severe memory fragmentation after allocation, reducing the utilization rate of memory in the terminal device, which may cause problems such as malfunctions or lag during use.

[0038] To avoid the above situation, this application provides a memory management method, the implementation process of which is as follows:

[0039] Figure 2 This is a flowchart illustrating the memory management method provided in the embodiments of this application. Please refer to... Figure 2 A memory management method applied to terminal devices, the method includes:

[0040] S210: When memory management is performed on the target task, memory management is performed on the target task according to the target memory management strategy corresponding to the target task.

[0041] The execution subject of this method can be the aforementioned terminal device. The target task can be a task generated by the terminal device during operation, such as audio and video playback task, dial display task, motion data display task, etc. No specific restrictions are imposed here. Any task that the terminal device can execute can be used as the aforementioned target task.

[0042] Each target task can correspond to a target memory management strategy. These target memory management strategies can be pre-stored in the terminal device, generated by the terminal device itself, or sent to the terminal device by other devices. No specific restrictions are imposed here.

[0043] The target memory management strategy includes at least one pre-divided memory region corresponding to the target task. Each pre-divided memory region is a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks.

[0044] In one embodiment, any pre-divided memory region can be predetermined, for example, it can be determined according to the task type, the actual physical memory of the terminal device, or it can be a region randomly divided according to preset rules. No specific restrictions are imposed here. Any one or more of the above methods can be combined to determine the pre-divided memory region.

[0045] Optionally, the pre-allocated memory region can be a region for storing the memory of the target task. For example, after allocating a portion of the memory of the pre-allocated memory region A to the target task, the target task can store and retrieve memory through the pre-allocated memory region A, and release the memory of the pre-allocated memory region A after the target task ends.

[0046] Each pre-allocated memory region can be pre-allocated before the target task's memory management, can be allocated by the terminal device itself according to preset rules, or can be allocated actively by the user; no specific restrictions are imposed here.

[0047] In practice, the same pre-allocated memory region can correspond to one or more tasks. If the same pre-allocated memory region corresponds to multiple tasks, these tasks can be tasks that do not run synchronously, or they can be multiple tasks that require the entire memory area of ​​the pre-allocated memory region during synchronous operation.

[0048] For example, pre-allocated memory region B can correspond to task 1 and task 2. Task 1 and task 2 are tasks that do not run synchronously. That is, task 2 will not be executed while task 1 is being executed. In this case, pre-allocated memory region B will only allocate memory to one of the tasks.

[0049] For example, a pre-allocated memory region C can correspond to task 3 and task 4, where the total memory required for task 3 and task 4 is less than the upper limit of the memory in the pre-allocated memory region C.

[0050] If a terminal device generates a new task that does not have a pre-configured corresponding pre-allocated memory region, a memory management policy for that task can be generated. Alternatively, memory can be allocated to the task from other regions outside the pre-allocated memory region, without any specific restrictions.

[0051] It should be noted that the memory of a terminal device may include multiple regions, such as SRAM (Static Random Access Memory), PSRAM (Pseudo Static Random Access Memory), DTCM (Data Tightly Coupled Memory), or other memory regions, without specific limitations. In actual memory management, the pre-partitioned memory region corresponding to the target task can be any one or more of the above-mentioned regions, and the pre-partitioned memory region corresponding to each target task can be all or part of one of these regions.

[0052] The terminal device stores multiple memory management strategies. Different memory management strategies can correspond to different tasks. The task corresponding to the target memory management strategy can be the target task mentioned above.

[0053] Each task can be generated by the business layer of the terminal device. After the business layer generates these tasks, it does not need to worry about how to allocate these tasks. It can simply input them through the preset API (Application Programming Interface). Then, the memory management module in the terminal device can perform the memory allocation and release work.

[0054] The memory management method provided in this application embodiment can manage the memory of a target task according to a target memory management strategy corresponding to the target task. The target memory management strategy includes at least one pre-divided memory region corresponding to the target task. Each pre-divided memory region is a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks. By using different memory management strategies, different tasks can be managed, and different tasks can be managed in different memory regions. This avoids memory fragmentation problems, thereby reducing terminal device failures or lag, and improving the stability of the terminal device's system operation. Furthermore, the business layer only needs to implement memory management through an interface, without needing to pay attention to the actual memory management situation, and can also achieve decoupling between the business layer and memory management.

[0055] The above memory management method will now be explained in conjunction with the software execution process of the terminal device provided in the embodiments of this application.

[0056] Figure 3 This is a schematic diagram of the software execution of the terminal device provided in the embodiments of this application. Please refer to... Figure 3 The terminal device may include: a service layer 310, a memory allocation module 320, and a memory management module 330.

[0057] Among them, the business layer 310 can be a software layer that generates tasks in the terminal device. For example, any application startup, application execution, thread calling, process calling, etc. can be a task. The target task and other related tasks can be generated by the business layer 310.

[0058] The memory allocation module 320 can acquire memory regions. For example, it can allocate a memory region to a target task by calling the corresponding Hook function, or release the memory region allocated to the target task.

[0059] The memory allocation module 320 can call the corresponding Hook function according to the memory management policy. For example, during the memory allocation process, if the memory management policy indicates that the memory region corresponding to the target task is memory region 1, the Hook function corresponding to memory region 1 can be called to allocate memory region 1 to the target task. Similarly, during the memory release process, if the memory management policy indicates that the memory region corresponding to the target task is memory region 2, the Hook function corresponding to memory region 2 can be called to release memory region 2.

[0060] The Hook function can include the malloc function and the free function. The malloc function is used to allocate memory, and the free function is used to release memory.

[0061] After the memory allocation module 320 obtains the allocation result, it can return the allocation result to the target task. For example, if the allocation result indicates that the memory region corresponding to the target task is memory region A, the target task can store memory in memory region A, and after use, it can release memory region A using a similar process as described above.

[0062] The memory management module 330 can be a module that specifically implements memory allocation and memory release. It can preload the corresponding memory allocation mechanism through memory initialization, for example: Figure 3 The diagram shows the memory allocation mechanism used by an RTOS system. Physical memory allocation can be implemented based on this mechanism. The aforementioned memory region A can be... Figure 3 A portion of any physical memory location.

[0063] The memory management module 330 can configure corresponding memory management policies for each task through memory configuration. The memory management policy for each task can be stored in the memory configuration, generated and stored by the terminal device itself, or sent by other devices and stored by the terminal device through memory configuration.

[0064] The memory management mechanism in memory management module 330 can use any memory allocation mechanism to connect to Hook functions to implement memory allocation and memory release. Figure 3 The diagram shows the memory allocation mechanism implemented using an RTOS system. Memory allocation can be performed dynamically.

[0065] For memory allocation mechanisms in RTOS systems, the heap6 dynamic memory allocation algorithm from FreeRTOS can be used. It uses a separate memory pool to manage all dynamic memory allocations. During initialization, the heap6 allocator requests a large contiguous block of memory from the system, then divides this memory into multiple blocks, each capable of accommodating one or more allocation requests. When a program needs to allocate memory, the heap6 allocator finds a block of suitable size from the memory pool and allocates it to the program. When the program releases memory, the heap6 allocator marks the block as free, waiting for the next allocation request. The heap6 allocator avoids memory fragmentation, thus improving memory utilization efficiency.

[0066] In the memory allocation mechanism of RTOS systems, Nuttx dynamic memory can be used during memory management. Nuttx is an open-source real-time operating system that provides a flexible memory management mechanism.

[0067] In addition, RTOS systems can also use memory management modules from other RTOSs to implement memory management, without making specific restrictions here.

[0068] The following explains the specific implementation process of memory management in the terminal device provided in the embodiments of this application.

[0069] Figure 4 Please refer to the flowchart illustrating the memory management process of the terminal device provided in this application embodiment. Figure 4 The target task's memory is managed according to the target memory management policy corresponding to the target task, including: allocating memory to the target task according to the target memory management policy corresponding to the target task; and / or releasing the target task's memory according to the target memory management policy corresponding to the target task.

[0070] Memory management for a target task can include memory allocation and memory release. Memory allocation can be the process of allocating corresponding memory to the target task before it is executed, so that the task can store the corresponding data in the allocated memory during execution. Memory release can be the process of releasing the memory allocated to the target task after it has been executed. After the memory is released, it can be used as free memory and can be reassigned to other tasks.

[0071] During memory management, the decision to allocate or release memory can be made based on the execution status of the target task. If the target task has not yet been executed, memory can be allocated; if the target task has been completed, memory can be released.

[0072] The memory management method provided in this application embodiment can allocate memory to a target task according to the memory management strategy corresponding to the target task; and / or release the memory of the target task according to the memory management strategy corresponding to the target task. By using different memory management strategies, memory allocation and release can be performed on different tasks, and different tasks can be allocated to different memory regions. This avoids memory fragmentation problems, thereby reducing terminal device malfunctions or lag, and improving the stability of the terminal device's system operation.

[0073] The following examples illustrate the memory management process using memory allocation as an example. The memory release process is similar to memory allocation and will not be explained again here.

[0074] The following explains the implementation process of determining the target memory management strategy provided in the embodiments of this application.

[0075] Figure 5 For a flowchart illustrating the process of determining the target memory management strategy for the terminal device provided in this embodiment, please refer to... Figure 5 The terminal device pre-stores the mapping relationship between task identification information and memory management strategy.

[0076] It should be noted that this mapping relationship can be stored in... Figure 3 The memory configuration in the memory management module 330 can be stored in the form of a configuration file. Different memory management strategies can be configured for different tasks, and a large number of memory management strategies can be stored in the memory configuration.

[0077] During the target memory allocation process, it can be first determined whether the mapping relationship includes the identification information of the target task, and then different steps can be performed based on whether the identification information exists:

[0078] Before allocating memory to the target task according to the memory management policy corresponding to the target task, the method further includes: S510: if the mapping relationship includes the identification information of the target task, determine the target memory management policy corresponding to the target task according to the identification information of the target task and the mapping relationship.

[0079] It should be noted that if the mapping relationship includes the identification information of the target task, it can be determined that the terminal device stores the target memory management policy corresponding to the target task. The target memory management policy corresponding to the target task can be determined based on the identification information of the target task and the mapping relationship.

[0080] This mapping relationship can be represented in various ways, for example, it can be recorded in a table, as shown in Table 1:

[0081] Table 1

[0082] Task identification information Memory management strategy Task A Memory management strategy A Task B Memory management strategy B … … Task N Memory management strategy N

[0083] Table 1 shows one way of representing the mapping relationship. The table can record the identification information of each task and the memory management strategy corresponding to the identification information, so that the memory management strategy corresponding to each task can be determined more quickly.

[0084] It should be noted that this mapping relationship can also be represented in other ways. For example, each memory management policy also records the identification information of the task corresponding to the memory management policy, and then the memory management policy with the recorded identification information can be determined based on the identification information of the target task.

[0085] In practical applications, either of the two methods mentioned above can be used to determine the mapping relationship; no specific restrictions are imposed here.

[0086] It should be noted that after performing step S510, step S210 can be performed to achieve memory management.

[0087] The memory management method provided in this application embodiment can determine the target memory management strategy corresponding to the target task based on the target task's identification information and the mapping relationship, when the mapping relationship includes the target task's identification information. Specifically, by using the target task's identification information and the aforementioned mapping relationship, the target memory management strategy corresponding to the target task can be found more accurately and quickly, thus improving the speed of determining the target memory management strategy.

[0088] In one embodiment, if the mapping relationship does not include the identification information of the target task, the method further includes: S520: allocating memory to the target task from the reserved memory area.

[0089] The reserved memory area refers to the memory area outside of the pre-allocated memory areas in the total memory area of ​​the terminal device.

[0090] It should be noted that the set of all pre-partitioned memory regions and reserved memory regions can be the entire memory region of the terminal device. The reserved memory region does not overlap with any pre-partitioned memory region and can be an independent memory region.

[0091] In practical applications, the tasks generated by each service of the terminal device can be managed in memory using the S210 method. However, for some services, such as those with preset memory management methods or unknown services, the above process is not applicable. The reserved memory area can be allocated to these tasks for memory allocation.

[0092] It should be noted that since this type of task is not suitable for memory management based on memory management strategies, the identification information of these tasks does not need to be stored in the mapping relationship. During the memory allocation process, memory can be allocated to the target task from the reserved memory area. During the memory release process, the memory block in the reserved memory area allocated to the task can also be released.

[0093] The memory management method provided in this application embodiment can allocate memory to a target task from a reserved memory area even when the target task's identification information is not included in the mapping relationship. By using the reserved memory area for memory allocation for some tasks, the applicability of memory allocation can be improved, avoiding situations where some tasks cannot be allocated memory.

[0094] The following explains another feasible implementation method for memory management provided in the embodiments of this application.

[0095] Figure 6 This is another flowchart illustrating the memory management method provided in the embodiments of this application. Please refer to... Figure 6 Before performing memory management on the target task according to the target memory management strategy corresponding to the target task, the method further includes:

[0096] S610: Obtain the task type of the target task.

[0097] The task type includes at least one of the following: task execution frequency, task execution priority, and task execution duration.

[0098] It should be noted that the target task can be classified according to any of the above methods. For example, high-frequency tasks with an execution frequency greater than or equal to a preset threshold and low-frequency tasks with an execution frequency less than a preset threshold; or high-priority tasks with a higher execution priority and low-priority tasks with a lower execution priority; or long-term tasks with an execution duration greater than or equal to a preset threshold and short-term tasks with an execution duration less than a preset threshold, etc.

[0099] The execution frequency of a task refers to the number of times the task is executed within a certain period of time. For example, if the task of playing audio is executed once a week, then the task can be considered a low-frequency task; if the task of displaying the clock face is executed multiple times a day, then the task can be considered a high-frequency task.

[0100] The execution priority of tasks can be set by the user. For example, the priority of each task can be determined based on the user's input, or the priority of these tasks can be automatically generated according to the user's usage habits. No specific restrictions are imposed here.

[0101] The execution duration of a task can be the duration of each run of the task. For example, if the average execution time of a task to play a video is 10 minutes, then the task can be a short-term task; if the average execution time of a task to display motion data is 1 hour, then the task can be a long-term task.

[0102] It should be noted that the target task can be classified based on any one or more of the three classification methods mentioned above. Each classification method can be set according to actual needs and is not limited to the above example.

[0103] After obtaining the task types of each target task, the corresponding memory management strategy for that task can be determined based on these task types. For each target task, the target memory management strategy corresponding to that target task can be determined.

[0104] S620: Determine the target memory management strategy corresponding to the target task based on the task type of the target task.

[0105] Optionally, different memory management strategies can be set for different tasks according to actual needs. For example, for high-frequency tasks, high-priority tasks, and long-term tasks, the preset memory area in the memory management strategy can be set on physical memory with faster read and write speeds, such as SRAM; for low-frequency tasks, low-priority tasks, and short-term tasks, the preset memory area in the memory management strategy can be set on physical memory with relatively slower read and write speeds, such as PSRAM.

[0106] It should be noted that the above method for determining the target memory management strategy is only one example. In actual implementation, the user can actively set the location of each preset memory region, or the terminal device can randomly determine it from multiple physical memory locations. No specific restrictions are imposed here.

[0107] After completing step S620 to determine the target memory management strategy corresponding to the target task, step S210 can be executed to realize memory allocation and memory release.

[0108] The memory management method provided in this application embodiment can obtain the task type of the target task; and determine the target memory management strategy corresponding to the target task based on the task type. By determining the corresponding target memory management strategy based on the task type, the memory management strategy for each task can be determined more accurately, reasonably, and efficiently, improving the rationality of subsequent memory allocation and reducing terminal device failures and lag issues.

[0109] It should be noted that different memory management strategies can be set for different tasks. The following explains two different memory management strategies.

[0110] Figure 7 This is a schematic diagram illustrating the memory management strategy provided in the embodiments of this application. Please refer to... Figure 7 The memory management strategy also includes the start and end addresses of each pre-divided memory region. When the target task corresponds to multiple pre-divided memory regions, the memory management strategy further includes the priority of these pre-divided memory regions.

[0111] It should be noted that, Figure 7 The memory management strategy 1 shown on the left can be the content included when there is only one pre-divided memory region. For example, it can include the task identification information, as well as the start address and end address of the pre-divided memory region. During the memory allocation process, a portion of the region between the start address and the end address can be selected and allocated to the corresponding task.

[0112] Figure 7 The memory management strategy 2 shown on the right can include the following when there are multiple pre-divided memory regions: for example, it can include task identification information, the priority of each pre-divided memory region, and the start and end addresses of each pre-divided memory region.

[0113] It should be noted that, Figure 7 Both memory management strategies shown are based on the division of task implementation. In practical applications, especially for large-scale tasks, there may be multiple subtasks, such as sub-threads and sub-processes. During the task allocation process, corresponding memory management strategies can be set for different subtasks to achieve more granular memory allocation for each task.

[0114] For example, if task A corresponds to a pre-divided memory region A, and task A includes three subtasks, then the pre-divided memory region A can be further subdivided into three different sub-memory regions, which can be allocated to each subtask respectively, thereby realizing memory allocation for these subtasks.

[0115] It should be noted that, Figure 7 The content shown is only one feasible example. In actual implementation, other methods can be adopted. Figure 7 Any of the memory management strategies shown can be used, and additional information can be added based on the memory management strategy. For example, corresponding information can be added according to the user's actual usage needs, without specific restrictions.

[0116] In one embodiment, allocating memory to the target task according to the memory management policy corresponding to the target task includes: allocating memory to the target task from multiple target memory regions in descending order of priority.

[0117] It should be noted that the target memory region is at least one of the pre-divided memory regions.

[0118] The priority of the pre-divided memory regions is used to characterize the order in which multiple pre-divided memory regions are allocated memory, and different pre-divided memory regions correspond to different data access rates.

[0119] It should be noted that the data access rate refers to the speed at which the memory region is read from or written to.

[0120] For example, if the pre-divided memory regions include region 1, region 2, and region 3, with the priority order being region 2, region 3, and region 1, then during the memory allocation process, region 2 will be allocated first, followed by region 3, and finally region 1. If the task requires the allocation of two memory regions, then region 2 and region 3 can be allocated first.

[0121] If only one region needs to be allocated, then that region can be used as the target memory region; if two or more regions need to be allocated, then these allocated regions can be used as the target memory regions.

[0122] The memory management method provided in this application embodiment can allocate memory to a target task from multiple target memory regions in descending order of priority. By dividing multiple target memory regions according to priority, memory allocation can be achieved for tasks requiring multiple memory regions. Furthermore, setting different priorities allows for the allocation of more suitable memory to corresponding tasks, thereby improving the stability of task execution. This method enables more flexible and precise management and configuration of multiple physical memory segments to meet the memory configuration requirements of complex embedded systems.

[0123] The following explains one feasible implementation method for updating the memory management strategy in the embodiments of this application.

[0124] Figure 8 This is a schematic diagram of the memory management policy update process provided in the embodiments of this application. Please refer to... Figure 8 The method also includes:

[0125] S810: Get the execution status of the target task.

[0126] The execution status is used to indicate whether the target task has encountered a failure or a delay during execution.

[0127] It should be noted that the terminal device can determine the execution status of the target task based on its own operating status. For example, if the terminal device encounters problems such as timeout or black screen during the execution of the target task, it can be determined that the target task has encountered a fault or lag during execution.

[0128] The faults may differ for different tasks. For example, a black screen can be considered a fault for video playback; sound interruption can be considered a fault for audio playback; and data timeout failure to update can be considered a fault for displaying a dial or displaying motion data. No specific restrictions are imposed here, and different faults can be set according to the actual task.

[0129] If a fault is identified, the target memory management policy can be updated.

[0130] In the event of a terminal device malfunction or lag, S820: Update the priority of multiple pre-divided memory regions in the target memory management policy, or S830: Update the size of the pre-divided memory regions in the memory management policy.

[0131] It should be noted that during the process of updating the target memory management policy, either of the two methods can be used. For example, the priority of multiple pre-divided memory regions can be adjusted, or the size of the pre-divided memory regions can be adjusted.

[0132] During the priority adjustment process, the priorities of the multiple pre-divided memory regions in the updated target memory management policy are sorted from high to low according to the data access rate corresponding to each pre-divided memory region.

[0133] For example, multiple pre-divided memory regions include Region 1, Region 2, and Region 3. Each region can correspond to different physical memory. For instance, Region 1 could be a memory region on SRAM, Region 2 could be a memory region on PSRAM, and Region 3 could be a memory region on DTCM. If the data access rate of DTCM is greater than the data access rate of SRAM, which is greater than the access rate of PSRAM, then after reordering, the priority order could be Region 3, Region 1, and Region 2.

[0134] Optionally, the size of the memory region can be increased during the process of adjusting the size of the memory region.

[0135] It should be noted that before increasing the size of the memory region, you can first determine the size based on your own memory allocation. If there is spare memory, you can allocate the spare memory first; if there is no spare memory, you can borrow some memory from other memory regions to increase the size of the memory region.

[0136] For example, when changing the size of memory region D, we can first determine whether there is any unallocated memory in memory region D. If there is unallocated memory in memory region D, we can allocate this memory from memory region D to the corresponding task. If there is no unallocated memory in memory region D, we can borrow part of the memory region from other memory regions to increase the memory of memory region D, and then allocate the increased memory to the corresponding task.

[0137] It should be noted that other memory regions can also be one of the pre-allocated memory regions mentioned above, for example, they can be pre-allocated memory regions corresponding to other tasks.

[0138] Optionally, a release check can be performed before increasing the size of the memory region. For example, check if there is any memory that can be released in the memory region, such as memory that does not belong to the current task or memory of a completed task. If such memory exists, it can be released first, and then the released memory can be reallocated to the current task. If the current task no longer experiences failures or freezes, the memory management policy does not need to be updated. If the current task still experiences failures or freezes, the size of the memory region can be increased.

[0139] In one embodiment, during the process of increasing the size of a memory region, a portion of memory can be borrowed from a memory region with a large amount of unallocated memory. During the memory management policy update process, the update can be performed only for the single allocation, and the memory management policy applicable to the borrowed memory region can be updated synchronously.

[0140] If the same task causes the same failure or freeze multiple times, it can be changed to a permanent update, updating the memory management policy of the task, and also updating the memory management policy applicable to the borrowed memory region.

[0141] The memory management method provided in this embodiment can obtain the execution status of the target task; in the event of a terminal device malfunction or lag, it updates the priority of multiple pre-divided memory regions in the target memory management strategy, or updates the size of the pre-divided memory regions in the memory management strategy. During the priority adjustment process, the priorities of the multiple pre-divided memory regions in the updated target memory management strategy are sorted from high to low according to the data access rate corresponding to each pre-divided memory region. After updating the memory management strategy in the above manner, the updated memory management strategy can allocate memory more rationally, thereby enabling the terminal device to better allocate memory during the execution of the corresponding task and avoiding malfunctions or lag.

[0142] The following explains another feasible practical application scenario provided in the embodiments of this application.

[0143] Figure 9 This is a schematic diagram illustrating another application scenario of the terminal device provided in this application embodiment. Please refer to... Figure 9 The terminal equipment includes a first system and a second system, and the first system and the second system have a communication link.

[0144] In this scenario, the terminal device may include: a first system 910 and a second system 920, wherein the first system 910 and the second system 920 may be different types of operating systems. For example, the first system 910 may be a real-time operating system (RTOS) and the second system 920 may be an Android system, or any two different operating systems, without specific restrictions.

[0145] The first system 910 and the second system 920 may have a communication link, for example, they can be connected through a data bus. The processor corresponding to the first system 910 is the first processor, and the processor corresponding to the second system 920 is the second processor. The performance of the second processor may be greater than that of the first processor.

[0146] Optionally, the second system 920 can be a large-core system, and the first system 910 can be a small-core system. The terminal device can be a wearable device, such as a smartwatch, smart bracelet, or smart glasses. In the process of using such terminal devices, the small-core system is usually in running state, while the large-core system is in dormant state. When the large-core system needs to perform a function that only the large-core system can perform, the large-core system can be woken up to complete the corresponding function.

[0147] For example, taking a smart bracelet as an example, a smart bracelet can display information such as time and weather in real time and detect the user's pulse. These functions can be performed by a small core system. However, when the smart bracelet needs to perform functions such as telephone calls and video calls, the small core system cannot support these functions. Therefore, it can wake up the large core system that is in a dormant state and let the large core system perform these functions. After the large core system performs the corresponding functions, it can return to a dormant state.

[0148] It should be noted that during the operation of a terminal device, the large core system may be in a dormant state while the small core system is in an active state, or both the large core system and the small core system may be in an active state; no specific restrictions are imposed here.

[0149] It should be noted that the above method can be applied to the small core system in the big.little core system, namely the first system 910 mentioned above.

[0150] Optionally, the method further includes: receiving a target memory management strategy sent by a second system via a communication link.

[0151] It should be noted that the first system can send the data required to determine the target memory management strategy to the second system, the second system can determine the target memory management strategy and send it to the first system through the above communication link, the first system can store the received target memory management strategy in the memory configuration of the memory management module and call it during the task memory allocation process.

[0152] In one embodiment, the target management strategy can be determined by a first system or a second system. No specific limitation is made here. It can be determined according to actual usage requirements. For example, if the large core system is in a dormant state, it can be determined by the small core system; if both the large core system and the small core system are in a running state, it can be determined by the large core system.

[0153] In the memory management method provided in this application embodiment, a target memory management policy sent by a second system can be received via a communication link. The second system reviews the target memory management policy, and the first system executes the corresponding tasks, which reduces the processing load on the first system and thus improves the efficiency of generating the target memory management policy.

[0154] In another embodiment, the second system is a large-core system and the first system is a small-core system. The processing power of the second system is stronger than that of the first system, so the target memory management strategy can be determined more quickly, thereby further improving the efficiency of generating the target memory management strategy.

[0155] The following is based on Figure 9The example shown illustrates one feasible implementation process for triggering memory allocation in the application scenario.

[0156] Figure 10 This is a schematic diagram of the memory allocation triggering process provided in the embodiments of this application. Please refer to it. Figure 10 The method also includes:

[0157] S1010: When the second system enters a sleep state, or when the display of the terminal device is switched from being controlled by the second system to being controlled by the first system, the target trigger command is obtained.

[0158] It should be noted that each system can exist in corresponding usage states, such as running state and hibernation state. The running state refers to the state where all system functions are available, while the hibernation state refers to the state where most system functions are unavailable. There is some power consumption in the running state, while power consumption is lower in the hibernation state. For big.LITTLE systems, the small cores typically remain in the running state, while the large cores typically remain in the hibernation state. When certain functions of the large cores are needed, the large cores are woken up, that is, the large cores are switched from hibernation to running state.

[0159] It should be noted that the terminal device may include a display, which can be any type of display such as a touch screen display or a digital display, without any specific restrictions.

[0160] Both the first and second systems can control the display. At any given time, the display can only be controlled by one system. For example, the display can be controlled by the second system. If a switch of control over the display is required, the control can be switched from the second system to the first system.

[0161] Optionally, the target trigger command can be obtained when the second system enters a sleep state, or when the display of the terminal device is switched from being controlled by the second system to being controlled by the first system.

[0162] It should be noted that the target trigger instruction is used to allocate memory for the target task, which is the task that runs after the display of the first system control terminal device.

[0163] In this scenario, the target task can be any task that needs to be run first after the first system controls the display, such as the task of displaying the dial or the task of displaying the time, etc., without any specific restrictions.

[0164] After obtaining the target trigger command through the above method, step S210 can be executed according to the target trigger command, as specifically implemented as follows:

[0165] S1020: Upon receiving a target trigger instruction, perform memory management on the target task according to the target memory management strategy corresponding to the target task.

[0166] It should be noted that after receiving the target trigger instruction, memory management can be performed on the target task according to the target memory management strategy corresponding to the target task. That is, the aforementioned step S210 is executed to realize memory allocation and release.

[0167] In the memory management method provided in this application embodiment, a target trigger instruction can be obtained when the second system enters a sleep state or when the display of the terminal device is switched from control by the second system to control by the first system. Upon receiving the target trigger instruction, memory management is performed on the target task according to the target memory management strategy corresponding to the target task. In both of the above situations, when the first system controls the display of the terminal device, the corresponding memory management method can be executed, thereby enabling faster execution of the corresponding task after the first system controls the display of the terminal device, avoiding screen flickering or failure to display content.

[0168] In one embodiment, in addition to configuring a corresponding memory management strategy according to the task, a corresponding memory management strategy can also be established based on other system resources in the terminal device, without specific limitations.

[0169] It should be understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0170] Based on the foregoing embodiments, this application provides a memory management device, which includes various modules and units included in each module, and can be implemented by a processor; of course, it can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), microprocessor (MPU), digital signal processor (DSP) or field programmable gate array (FPGA), etc.

[0171] Figure 11 This is a schematic diagram of the memory management device provided in the embodiments of this application. Please refer to... Figure 11The device includes: a management module 1110;

[0172] The management module is used to manage the memory of the target task according to the target memory management strategy corresponding to the target task when performing memory management on the target task. The target memory management strategy includes: at least one pre-divided memory region corresponding to the target task, each pre-divided memory region being a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks.

[0173] In one embodiment, the management module 1110 is specifically used to allocate memory to the target task according to the memory management policy corresponding to the target task; and / or to release the memory of the target task according to the memory management policy corresponding to the target task.

[0174] In one embodiment, the terminal device pre-stores a mapping relationship between task identification information and memory management policies; the management module 1110 is further configured to determine the target memory management policy corresponding to the target task based on the target task identification information and the mapping relationship when the mapping relationship includes the target task identification information.

[0175] In one embodiment, the management module 1110 is further configured to allocate memory to the target task from a reserved memory area, wherein the reserved memory area is the memory area in all memory areas of the terminal device excluding each pre-divided memory area.

[0176] In one embodiment, the management module 1110 is further configured to obtain the task type of the target task, the task type including at least one of the following: the execution frequency of the task, the execution priority of the task, and the execution duration of the task; and determine the target memory management strategy corresponding to the target task based on the task type of the target task.

[0177] In one embodiment, the memory management strategy further includes: the start address and end address of each pre-divided memory region; when the target task corresponds to multiple pre-divided memory regions, the memory management strategy further includes: the priority of the multiple pre-divided memory regions, the priority of the pre-divided memory regions is used to characterize the order in which the multiple pre-divided memory regions are allocated memory, and different pre-divided memory regions correspond to different data access rates.

[0178] In one embodiment, the management module 1110 is specifically configured to allocate memory to the target task from multiple target memory regions in descending order of priority, wherein the target memory region is at least one of the pre-divided memory regions.

[0179] In one embodiment, the management module 1110 is further configured to obtain the execution status of the target task, which indicates whether the target task has encountered a fault or a lag during execution; in the event of a fault or lag in the terminal device, the priority of multiple pre-divided memory regions in the target memory management strategy is updated, or the size of the pre-divided memory regions in the memory management strategy is updated, wherein the priority of the multiple pre-divided memory regions in the updated target memory management strategy is sorted from high to low according to the data access rate corresponding to each pre-divided memory region.

[0180] In one embodiment, the terminal device includes a first system and a second system, the first system and the second system having a communication link, and the management module 1110 is further configured to receive a target memory management strategy sent by the second system through the communication link.

[0181] In one embodiment, the management module 1110 is further configured to acquire a target trigger instruction when the second system enters a hibernation state or when the display of the terminal device is switched from being controlled by the second system to being controlled by the first system. The target trigger instruction is used to allocate memory for a target task, which is a task that runs after the first system controls the display of the terminal device.

[0182] The memory management device provided in this application embodiment can manage the memory of a target task according to a target memory management strategy corresponding to the target task. The target memory management strategy includes at least one pre-divided memory region corresponding to the target task. Each pre-divided memory region is a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks. By using different memory management strategies, different tasks can be managed, and different tasks can be managed in different memory regions. This avoids memory fragmentation problems, thereby reducing terminal device failures or lag, and improving the stability of the terminal device's system operation. Furthermore, the business layer only needs to implement memory management through an interface, without needing to pay attention to the actual memory management situation, and can also achieve decoupling between the business layer and memory management.

[0183] The descriptions of the above device embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0184] It should be noted that, in the embodiments of this application... Figure 11The module division shown in the memory management device is illustrative and represents only one logical functional division; in actual implementation, other division methods may be used. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, exist as separate physical units, or be integrated into one unit with two or more units. The integrated units can be implemented in hardware, as software functional units, or a combination of both.

[0185] It should be noted that, in the embodiments of this application, if the above-described methods are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0186] Figure 12 This is a schematic diagram of the terminal device provided in the embodiments of this application. Please refer to... Figure 12 This application provides a computer device, which can be the aforementioned terminal device, and its internal structure diagram can be as follows. Figure 12 As shown, the computer device includes a processor 1220, memory, and a network interface 1240 connected via a system bus 1210. The processor 1220 provides computing and control capabilities. The memory includes a non-volatile storage medium 1231 and internal memory 1232. The non-volatile storage medium 1231 stores an operating system, computer programs, and a database. The internal memory 1232 provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium 1231. The database is used to store data. The network interface 1240 is used for communication with external terminals via a network connection. When the computer program is executed by the processor 1220, it implements the aforementioned methods.

[0187] This application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method provided in the above embodiments.

[0188] This application provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the steps in the method provided in the above-described method embodiments.

[0189] Those skilled in the art will understand that Figure 12 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0190] In one embodiment, the memory management device provided in this application can be implemented as a computer program, which can be implemented in, for example... Figure 12 The device operates on the computer device shown. The memory of the computer device can store the various program modules that make up the above-described apparatus. The computer program, composed of the various program modules, causes the processor to execute the steps of the methods in the various embodiments of this application described in this specification.

[0191] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium, storage medium, and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0192] It should be understood that the phrases "one embodiment," "an embodiment," or "some embodiments" mentioned throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment," "in one embodiment," or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. The descriptions of the various embodiments above tend to emphasize the differences between the various embodiments; their similarities or commonalities can be referred to mutually, and for the sake of brevity, they will not be repeated here.

[0193] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three kinds of relationships. For example, object A and / or object B can represent three situations: object A exists alone, object A and object B exist simultaneously, and object B exists alone.

[0194] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0195] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple modules or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or modules can be electrical, mechanical, or other forms.

[0196] The modules described above as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules. They may be located in one place or distributed across multiple network units. Some or all of the modules may be selected to achieve the purpose of this embodiment according to actual needs.

[0197] In addition, each functional module in the various embodiments of this application can be integrated into one processing unit, or each module can be a separate unit, or two or more modules can be integrated into one unit; the integrated modules can be implemented in hardware or in the form of hardware plus software functional units.

[0198] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.

[0199] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0200] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0201] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0202] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.

[0203] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A memory management method, characterized in that, Applied to a terminal device, the method includes: When memory management is performed on a target task, the target task is managed according to the target memory management strategy corresponding to the target task. The target memory management strategy includes at least one pre-divided memory region corresponding to the target task, each of the pre-divided memory regions being a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks.

2. The method according to claim 1, characterized in that, The step of managing the memory of the target task according to the target memory management strategy corresponding to the target task includes: Allocate memory to the target task according to the memory management strategy corresponding to the target task; and / or, Release the memory of the target task according to the memory management policy corresponding to the target task.

3. The method according to claim 2, characterized in that, The terminal device pre-stores a mapping relationship between task identification information and memory management strategies; Before allocating memory to the target task according to the memory management policy corresponding to the target task, the method further includes: If the mapping relationship includes the identification information of the target task, the target memory management strategy corresponding to the target task is determined based on the identification information of the target task and the mapping relationship.

4. The method according to claim 3, characterized in that, If the mapping relationship does not include the identification information of the target task, the method further includes: Memory is allocated to the target task from a reserved memory area, which is the memory area in the total memory area of ​​the terminal device excluding each pre-divided memory area.

5. The method according to claim 1, characterized in that, Before performing memory management on the target task according to the target memory management strategy corresponding to the target task, the method further includes: Obtain the task type of the target task, wherein the task type includes at least one of the following: task execution frequency, task execution priority, and task execution duration; The target memory management strategy corresponding to the target task is determined based on the task type of the target task.

6. The method according to claim 2, characterized in that, The memory management strategy also includes: the start address and end address of each of the pre-divided memory regions; When the target task corresponds to multiple pre-divided memory regions, the memory management strategy further includes: the priority of the multiple pre-divided memory regions, the priority of the pre-divided memory regions is used to characterize the order in which the multiple pre-divided memory regions are allocated memory, and different pre-divided memory regions correspond to different data access rates.

7. The method according to claim 6, characterized in that, The step of allocating memory to the target task according to the memory management policy corresponding to the target task includes: Memory is allocated to the target task from multiple target memory regions in descending order of priority, wherein the target memory region is at least one of the pre-divided memory regions.

8. The method according to claim 6, characterized in that, The method further includes: The execution status of the target task is obtained, and the execution status is used to indicate whether the target task has encountered a fault or a delay during execution. In the event of a malfunction or lag in the terminal device, the priorities of multiple pre-divided memory regions in the target memory management policy are updated, or the size of the pre-divided memory regions in the memory management policy is updated. The priorities of the multiple pre-divided memory regions in the updated target memory management policy are sorted from high to low according to the data access rate corresponding to each pre-divided memory region.

9. The method according to claim 1, characterized in that, The terminal device includes a first system and a second system, the first system and the second system having a communication link, and the method further includes: The target memory management strategy is received from the second system via the communication link.

10. The method according to claim 9, characterized in that, The method further includes: When the second system enters a hibernation state, or when the display of the terminal device is switched from being controlled by the second system to being controlled by the first system, a target trigger instruction is obtained. The target trigger instruction is used to allocate memory for the target task, which is the task that runs after the first system controls the display of the terminal device.

11. A memory management device, characterized in that, The device, applied to terminal equipment, includes: a management module; The management module is used to manage the memory of the target task according to the target memory management strategy corresponding to the target task when performing memory management on the target task. The target memory management strategy includes: at least one pre-divided memory region corresponding to the target task, each of the pre-divided memory regions being a part of the total memory regions of the terminal device. The target memory management strategy is one of multiple memory management strategies, and different memory management strategies correspond to different tasks.

12. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 10.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 10.