Memory management method, device, equipment and storage medium
By marking and swapping out the UI activity components and image resources of the target application, the problem of insufficient fine-grained management of UI image resources in the prior art is solved, and memory reclamation efficiency and terminal operation stability are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN TCL DIGITAL TECH CO LTD
- Filing Date
- 2026-03-24
- Publication Date
- 2026-06-30
AI Technical Summary
Existing memory management methods cannot perform fine-grained management of interface image resources, resulting in low recycling efficiency, long recycling time, and phenomena such as application interface lag and slow program switching in multi-tasking environments.
By responding to memory management requests, the active UI components and image resource markers of the target application are identified. Based on the active components and image resource markers, memory swapping is performed under memory reclamation conditions, and precise memory reclamation is achieved using the target swapping interface.
It enables refined management of interface image resources, alleviates terminal memory pressure, and improves terminal operation stability and performance.
Smart Images

Figure CN122309148A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and specifically to a memory management method, apparatus, device, and storage medium. Background Technology
[0002] Currently, with the continuous enrichment and complexity of application functions, many large applications such as games, videos, social networking, and camera software often need to load a large number of interface resources in order to improve visual effects and user experience, which leads to a sharp increase in memory usage. Among them, interface image resources (such as Bitmap type images) account for a large proportion of memory usage in such applications. However, existing memory management methods cannot perform fine-grained memory management for these interface image resources, resulting in low recycling efficiency and long recycling time. This leads to phenomena such as application interface lag, slow program switching in multi-tasking environments, and background service killing. Summary of the Invention
[0003] This application provides a memory management method, apparatus, device, and storage medium, aiming to solve the technical problem in the prior art that it is impossible to perform fine-grained management of interface image resources.
[0004] On one hand, embodiments of this application provide a memory management method, which includes the following steps: In response to a memory management request for a target application, determine the UI activity components and UI image resources associated with the target application; Obtain the activity component tag of the interface activity component and the image resource tag of the interface image resource; When the program running information and system memory information of the target application meet the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component marker and the image resource marker. The target image resource is swapped out into memory using the target swap-out interface to obtain the memory management result.
[0005] In one possible implementation of this application, before obtaining the active component tag of the interface active component and the image resource tag of the interface image resource, the method further includes: In response to a component creation request for a target application, create a UI activity component corresponding to the target application, as well as an initial component tag and a root node tag object corresponding to the UI activity component; Create an initial image resource corresponding to the target application, and generate an image resource tag corresponding to the initial image resource based on the memory allocation address and memory length information of the initial image resource; Based on the root node marker object and the resource association module, a mapping relationship is established between the interface activity component and the associated initial image resource to obtain the interface image resource associated with the interface activity component. Record the resource object information corresponding to the interface image resource into the initial component tag to obtain the activity component tag corresponding to the interface activity component.
[0006] In one possible implementation of this application, the step of establishing a mapping relationship between the interface activity component and the associated initial image resource based on the root node marker object and the resource association module, to obtain the interface image resource associated with the interface activity component, includes: Obtain the associated image resources from the initial image resources that are associated with the interface activity component; Image resource information of the associated image resources is recorded based on the root node marker object and the active component marker. Based on the image resource tags, record the activity component information corresponding to the interface activity component; Using the root node marker object, a mapping relationship between the interface active component and the associated initial image resource is established according to the image resource information and the active component information, thereby obtaining the interface image resource associated with the active component marker.
[0007] In one possible implementation of this application, when the program running information and system memory information of the target application meet the memory reclamation conditions, determining the target image resources to be reclaimed from the interface image resources based on the active component marker and the image resource marker includes: Calculate system memory assessment data based on the program execution information and system memory information of the target application; When the system memory assessment data meets the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component tags and the image resource tags.
[0008] In one possible implementation of this application, when the system memory evaluation data meets the memory reclamation conditions, determining the target image resource to be reclaimed from the interface image resources based on the active component marker and the image resource marker includes: Obtain the memory evaluation threshold in the memory reclamation conditions; If the system memory assessment data is greater than the memory assessment threshold, a memory reclamation strategy corresponding to the memory assessment data is generated. The target image resources to be reclaimed in the interface image resources are determined according to the memory reclamation strategy, the active component marker, and the image resource marker.
[0009] In one possible implementation of this application, determining the target image resource to be reclaimed from the interface image resources according to the memory reclamation strategy, the active component marker, and the image resource marker includes: Based on the memory reclamation strategy, determine the active components to be reclaimed in the UI active components of the target application; Based on the activity component tag of the activity component to be recycled and the image resource tag, locate the interface image resource associated with the activity component to be recycled, and determine the interface image resource as the target image resource to be recycled.
[0010] In one possible implementation of this application, the memory management result includes a first memory management result and a second memory management result; The process of performing memory swapping out of the target image resource using the target swapping-out interface to obtain memory management results includes: Obtain the application type corresponding to the target application, where the application type includes frozen application type and active application type; If the application type is a frozen application type, then the single-threaded swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, and the first memory control result is obtained. If the application type is an active application type, then the regular swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, resulting in a second memory management result.
[0011] On the other hand, this application provides a memory management device, the memory management device comprising: The resource determination module is configured to respond to a memory management request for a target application and determine the UI activity components and UI image resources associated with the target application. The tag recognition module is configured to acquire the active component tag of the interface active component and the image resource tag of the interface image resource; The recycling assessment module is configured to determine the target image resources to be recycled in the interface image resources based on the active component marker and the image resource marker when the program running information and system memory information of the target application meet the memory recycling conditions. The memory management module is configured to perform memory swapping on the target image resources using the target swapping interface to obtain memory management results.
[0012] On the other hand, this application also provides a memory management device, the memory management device comprising: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the memory management method.
[0013] On the other hand, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to perform the steps in the memory management method described above.
[0014] This application, in response to a memory management request for a target application, determines the associated UI active components and UI image resources of the target application; obtains the active component marker of the UI active components and the image resource marker of the UI image resources; when the program running information and system memory information of the target application meet the memory reclamation conditions, it determines the target image resources to be reclaimed from the UI image resources based on the active component marker and the image resource marker; and performs memory swapping out processing on the target image resources using the target swapping out interface to obtain the memory management result. This achieves accurate and timely reclamation of bitmap resources to be reclaimed by using the active component marker and image resource marker to reclaim memory from target image resources belonging to the UI active component, thereby alleviating terminal memory pressure and improving terminal operational stability. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a schematic diagram illustrating a scenario of the memory management method according to an embodiment of this application; Figure 2 This is a flowchart illustrating one embodiment of the memory management method in this application. Figure 3 A flowchart illustrating an embodiment of memory reclamation evaluation in the memory management method provided in this application; Figure 4 A flowchart illustrating an embodiment of memory swapping in the memory management method provided in this application; Figure 5 A schematic diagram of one embodiment of the memory management device provided in this application; Figure 6 This is a schematic diagram of one embodiment of the memory management device provided in this application. Detailed Implementation
[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of the stated features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0019] In this application, the term "exemplary" is used to mean "serving as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0020] Currently, with the continuous enrichment and complexity of application functions, many large applications such as games, videos, social networking, and camera software often need to load a large number of interface resources in order to improve visual effects and user experience, which leads to a sharp increase in memory usage. Among them, interface image resources (such as Bitmap type images) account for a large proportion of memory usage in such applications. However, existing memory management methods cannot perform fine-grained memory management for these interface image resources, resulting in low recycling efficiency and long recycling time. This leads to phenomena such as application interface lag, slow program switching in multi-tasking environments, and background service killing.
[0021] Based on this, this application proposes a memory management method, apparatus, device, and computer-readable storage medium to solve the technical problem that the prior art cannot perform fine-grained management of interface image resources.
[0022] The memory management method in this embodiment of the invention is applied to a memory management device, which is configured in a memory management equipment. The memory management equipment includes one or more processors, a memory, and one or more applications. The one or more applications are stored in the memory and configured to be executed by the processor to implement the memory management method. The memory management equipment can be a smart terminal, such as a mobile phone, tablet computer, network device, and smart computer. Optionally, the memory management equipment can also be a server or a service cluster composed of multiple servers.
[0023] like Figure 1 As shown, Figure 1 This is a schematic diagram of a memory management method according to an embodiment of the present application. The memory management scenario in this embodiment includes a memory management device 100 (the memory management device 100 integrates a memory management unit), and the memory management device 100 has a computer-readable storage medium corresponding to the memory management method running in order to execute the steps of the memory management method.
[0024] Understandable Figure 1 The memory management device in the memory management method scenario shown, or the device included in the memory management device, does not constitute a limitation on the embodiments of the present invention. That is, the number or type of the memory management device included in the memory management method scenario, or the number or type of the device included in each device, does not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be considered as equivalent substitutions or derivatives of the technical solutions claimed in the embodiments of the present invention.
[0025] In this embodiment of the invention, the memory management device 100 is mainly used to: respond to a memory management request for a target application and determine the interface activity components and interface image resources associated with the target application; Obtain the activity component tag of the interface activity component and the image resource tag of the interface image resource; When the program running information and system memory information of the target application meet the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component marker and the image resource marker. The target image resource is swapped out into memory using the target swap-out interface to obtain the memory management result.
[0026] The memory management device 100 in this embodiment of the invention can be an independent memory management device, such as a mobile phone, tablet computer, network device, server and smart computer, or a memory management network or memory management cluster composed of multiple memory management devices.
[0027] This application provides a memory management method, apparatus, device, and computer-readable storage medium, which will be described in detail below.
[0028] It will be understood by those skilled in the art that Figure 1 The application environment shown is only one application scenario related to the solution of this application and does not constitute a limitation on the application scenario of this application. Other application environments may include more than one application scenario. Figure 1 The number of memory management devices shown, or the memory management network connections, for example... Figure 1 Only one memory management device is shown in the figure. It can be understood that the scenario of this memory management method may also include one or more memory management devices, which are not limited here. The memory management device 100 may also include a memory for storing component marking information and other data.
[0029] It should be noted that, Figure 1 The schematic diagram of the memory management method shown is merely an example. The scenarios of the memory management method described in the embodiments of the present invention are intended to more clearly illustrate the technical solutions of the embodiments of the present invention and do not constitute a limitation on the technical solutions provided in the embodiments of the present invention.
[0030] Based on the scenarios described above regarding memory management methods, various embodiments of the memory management method disclosed in this invention are proposed.
[0031] like Figure 2 As shown, Figure 2 This is a flowchart illustrating one embodiment of the memory management method in this application. The memory management method includes the following steps 201 to 204: 201. In response to a memory management request for the target application, determine the UI activity components and UI image resources associated with the target application; The memory management method in this embodiment is applied to a memory management device. The type and number of memory management devices are not specifically limited. That is, the memory management device can be one or more smart terminals or servers. In a specific embodiment, the memory management device is any smart terminal such as a smart TV, smartphone, smart wearable device, and smart computer.
[0032] Optionally, the target application is an application running or installed on a memory management device, used to implement specific business logic and functions at runtime. This target application hosts visual interactive components of the user interface and interface image resources through at least one active interface component.
[0033] Optionally, the memory management request is a memory management event that drives the memory management device to accurately identify the target image resources of the interface image resources to be swapped out in each target application within the terminal, and to perform memory swapping on the target image resources. This enables fine-grained memory swapping of the interface image resources belonging to the interface active components as groups, alleviating the problem of excessive memory consumption of the corresponding user interface images of the target application, thereby optimizing terminal performance. Optionally, this memory management request can be triggered actively by the user or automatically by the memory management device based on the terminal's memory status.
[0034] Optionally, the UI activity component is a container unit component corresponding to the target application's user interface, used to generate a window to display the view corresponding to the target application's user interface. Optionally, in a specific embodiment, the UI activity component is an Activity component. The view corresponding to the user interface is a view, which exists in bitmap image format during the drawing process.
[0035] Optionally, the UI activity component can associate and manage the image resource objects associated with the view control, so as to perform memory reclamation on a per-UI activity component basis in subsequent steps.
[0036] Optionally, the interface image resource is an image resource object corresponding to the user interface in the target application, used to load and display the corresponding image resource during the operation of the user interface. Optionally, in a specific embodiment, the interface image resource is a bitmap image resource. This interface image resource can be a bitmap image obtained through file loading, network downloading, and decoding / conversion during the drawing process.
[0037] Optionally, during the operation of the target application, in order to provide visual display effects and user experience, a large number of interface resources need to be loaded into the user interface. These interface resources include multiple interface image resources, and the interface image resources account for a large proportion of the memory usage of the user interface. Therefore, during the operation of the memory management device, the memory management device needs to manage the memory of the interface image resources to alleviate the problem of excessive memory usage of image resources.
[0038] Optionally, after receiving a memory management request, the memory management device obtains the target application in the operating system corresponding to the memory management device, and reads the UI activity components and UI image resources associated with the target application. That is, after determining the target application, the memory management device also reads the UI activity components and UI image resources of the user interface corresponding to the target application, and maps and associates the UI image resources with the corresponding UI activity components in subsequent steps, so that the UI activity components can perform grouped memory management on their respective UI image resources.
[0039] 202. Obtain the activity component tag of the interface activity component and the image resource tag of the interface image resource; Optionally, after acquiring the active interface component and the interface image resource, the memory management device also reads the active component tag of the active interface component and the image resource tag of the interface image resource.
[0040] Optionally, the active component is marked to record the marking information of the interface image resources belonging to the active component. That is, the memory management device records the interface image resources associated with the active component through the active component marking, thereby merging the interface image resources used in the user interface display process into the active component for organization and management.
[0041] Optionally, the image resource tag records the memory allocation information of the interface image resource and the tagging information of the interface active components. That is, each interface image resource is assigned an image resource tag to record the memory information of the interface image resource and the interface active component to which the interface image resource belongs.
[0042] Optionally, in one specific embodiment, the memory management device responds to a component creation request for a target application, creating a UI activity component corresponding to the target application, as well as an initial component tag and a root node tag object corresponding to the UI activity component. The initial component tag is used to record tag information of UI image resources associated with the UI activity component during its display changes. The root node tag object is a tag object used to record tag information of subordinate UI image resources. Optionally, in one specific embodiment, the root node tag object is a ViewRootTagInfo object.
[0043] Optionally, during the execution of the target application, the memory management device creates an initial image resource corresponding to the target application based on the application's requirements, and generates an image resource tag corresponding to the initial image resource based on the memory allocation address and memory length information of the initial image resource. That is, the memory management device obtains the memory allocation address and memory length information representing the memory usage of the initial image resource to generate the image resource tag corresponding to the initial image resource. For example, during the display loading phase and drawing operation process, the display interface generates an initial image resource in bitmap format. Furthermore, various interface elements (such as JPG, PNG, WEBP, etc.) are decoded into initial image resources in bitmap format during the layout loading phase when generating the display view.
[0044] Optionally, after generating the root node marker object, the memory management device further establishes a mapping relationship between the interface activity component and its associated initial image resource based on the root node marker object and the resource association module, thereby obtaining the interface image resource associated with the interface activity component. That is, the memory management device identifies the initial image resource associated with each interface activity component based on the root node marker object and the resource association module, establishes a mapping relationship between the interface activity component and its associated initial image resource, and determines the initial image resource as the interface image resource associated with the interface activity component.
[0045] Optionally, the memory management device acquires the associated image resources from the initial image resources that are associated with the active interface component. The associated image resources are those specifically linked to the active interface component.
[0046] Optionally, the memory management device records the image resource information of the associated image resource based on the root node marker object and the active component marker, records the active component information corresponding to the interface active component based on the image resource marker, and uses the root node marker object to establish a mapping relationship between the interface active component and the associated initial image resource according to the image resource information and the active component information, thereby obtaining the interface image resource associated with the active component marker.
[0047] Optionally, after establishing the mapping relationship between the active interface component and the associated initial image resource, the memory management device records the resource object information corresponding to the interface image resource in the initial component tag, thus obtaining the active component tag corresponding to the active interface component. Furthermore, the memory management device also updates the active component information of the associated active interface component in the image resource tag.
[0048] Optionally, when a UI activity component is destroyed during its lifecycle, the memory management device removes the dependency information of that associated UI activity component from the image resource tag. When a UI image resource is destroyed during its lifecycle, the memory management device removes the association information corresponding to that UI image resource from the activity component information.
[0049] Optionally, after mapping the interface image resources to their respective interface activity components to obtain the corresponding activity component tags and image resource tags, the memory management device also performs grouped memory swapping of the interface image resources associated with each interface activity component based on the activity component tags and image resource tags, so as to achieve fine-grained memory management of the interface image resources of the target application.
[0050] 203. When the program running information and system memory information of the target application meet the memory reclamation conditions, determine the target image resources to be reclaimed in the interface image resources based on the active component marker and the image resource marker; Optionally, after mapping the interface image resources to their respective interface active components to obtain the corresponding active component markers and image resource markers, the memory management device also determines the target image resources to be reclaimed in the interface image resources based on the active component markers and image resource markers when the target application and system memory information meet the memory reclamation conditions and memory reclamation is to be performed. In subsequent steps, the target image resources are swapped out of memory to achieve fine-grained memory management of the interface image resources of the target application.
[0051] Optionally, during operation, the memory management device also determines whether memory reclamation is required based on the target application, system memory information, and memory reclamation conditions. When it is determined that memory reclamation is required, the device promptly identifies the target image resource to be reclaimed in the interface image resource based on the active component tag and image resource tag, and performs memory swapping out of the target image resource in subsequent steps.
[0052] Optionally, program running information refers to indicators that characterize the running status of the target application in the memory management device, such as the foreground / background switching status of the target application's interface, whether it is frozen, and whether it is a whitelisted application.
[0053] Optionally, system memory information refers to memory usage information within the operating system of the memory management device. This system memory information includes application memory usage information and system memory level information. The application memory usage information represents the memory usage of each target application within the memory management device. The system memory level information is a quantitative indicator representing the degree of memory strain within the system of the memory management device, used to determine the current sufficiency or shortage of system memory resources.
[0054] Optionally, the memory reclamation criteria are the evaluation conditions used to determine whether or not to perform memory reclamation.
[0055] Optionally, the memory management device calculates system memory assessment data based on the target application's program execution information and system memory information. Optionally, this memory assessment data is used to comprehensively assess the current system memory pressure. Optionally, in one specific embodiment, the memory assessment data can be onTrimMemoryLevel data. Optionally, in other embodiments, the memory assessment data can also be a quantitative assessment parameter calculated by inputting program execution information and system memory information into a memory reclamation model to determine whether memory reclamation is needed and to prioritize memory reclamation for a specific target application.
[0056] Optionally, when the memory management device determines that the system memory assessment data meets the memory reclamation conditions, it determines that memory reclamation processing needs to be performed on the target application, and determines the target image resource to be reclaimed in the interface image resource based on the active component tag and the image resource tag.
[0057] Optionally, the memory management device can filter UI active components to be reclaimed based on the program running information of the target application, determine the UI image resources mapped to the UI active components through the active component tags and image resource tags corresponding to the UI active components, and obtain the target image resources to be reclaimed from the UI image resources. Optionally, the memory management device can determine some or all of the UI active resources in a specified UI active component as target image resources to be reclaimed according to the corresponding memory reclamation strategy, and perform memory swapping out of the target image resources in each UI active component to achieve fine-grained memory management of the UI image resources of the target application. Optionally, in a specific embodiment, the memory management device can determine the activity level of each UI active component through program running information, and then determine the UI active components with an activity level lower than a preset activity level threshold as UI active components to be reclaimed, thereby retaining the UI active components with higher activity levels in the target application and avoiding abnormal operation of the target application.
[0058] 204. Use the target swap-out interface to perform memory swap-out processing on the target image resources to obtain memory management results.
[0059] Optionally, after determining the target image resource to be reclaimed in the interface image resources based on the active component marker and the image resource marker, the memory management device also obtains the target swap-out interface corresponding to the target image resource, and uses the target swap-out interface to perform memory swap-out processing on the target image resource of the interface active component to be reclaimed, thereby obtaining the memory management result.
[0060] The target swap interface is the swap interface used to perform the swap operation.
[0061] In one specific embodiment, the memory management device can select different target swap-out interfaces to perform memory swap-out processing on target image resources according to the program type corresponding to the target application, so as to release the memory occupied by the interface resources of the interface activity components in the target application that are to be reclaimed, thereby relieving the terminal memory pressure and improving the terminal operation stability.
[0062] In this embodiment, the memory management device, in response to a memory management request for a target application, determines the associated UI active components and UI image resources of the target application; obtains the active component marker of the UI active components and the image resource marker of the UI image resources; when the program running information and system memory information of the target application meet the memory reclamation conditions, it determines the target image resources to be reclaimed from the UI image resources based on the active component marker and the image resource marker; and performs memory swapping out processing on the target image resources using the target swapping out interface to obtain the memory management result. This achieves memory reclamation of target image resources belonging to a UI active component by using the active component marker and image resource marker, thereby accurately and promptly reclaiming bitmap resources to be reclaimed, alleviating terminal memory pressure, and improving terminal operational stability.
[0063] like Figure 3 As shown, Figure 3 This is a flowchart illustrating an embodiment of the memory reclamation evaluation performed in the memory management method provided in this application. Figure 3 In the illustrated embodiment, the memory management method further includes steps 301 to 303: 301. Obtain the memory evaluation threshold in the memory reclamation conditions; 302. If the system memory assessment data is greater than the memory assessment threshold, generate a memory reclamation strategy corresponding to the memory assessment data; 303. Determine the target image resources to be reclaimed from the interface image resources according to the memory reclamation strategy, the active component marker, and the image resource marker.
[0064] Based on the above embodiments, in this embodiment, the memory management device determines whether memory reclamation is required by the target application, system memory information and memory reclamation conditions. When it is determined that memory reclamation is required, the device promptly determines the target image resource to be reclaimed in the interface image resource based on the active component tag and image resource tag, and performs memory swapping out of the target image resource in subsequent steps.
[0065] Optionally, the memory evaluation threshold is a quantitative threshold parameter set in the memory reclamation conditions to evaluate whether to perform memory reclamation. The memory management device obtains the memory evaluation threshold in the memory reclamation conditions and compares the memory evaluation data with the memory evaluation threshold to determine whether to perform memory reclamation.
[0066] Optionally, if the memory management device determines that the system's memory assessment data exceeds the memory assessment threshold, it determines that memory reclamation is required and generates a memory reclamation strategy corresponding to the memory assessment data. This memory reclamation strategy is a control strategy for reclamation of memory for a specified target application. Optionally, the memory reclamation strategy can instruct the reclamation of memory for some or all of the interface image resources in a specified target application. For example, the memory reclamation strategy can identify non-whitelisted applications with low activity as applications to be reclaimed, and perform memory swapping out of the target image resources in these applications to release the memory occupied by the interface resources of the active components in the target application, thereby alleviating terminal memory pressure and improving terminal operational stability. Here, the application to be reclaimed is the target application for which memory reclamation is required.
[0067] Optionally, the memory management device determines the target image resources to be reclaimed from the interface image resources according to the memory reclamation strategy, the active component marker, and the image resource marker. That is, the memory management device can determine some or all of the interface active resources belonging to a specified interface active component in the application to be reclaimed as target image resources to be reclaimed according to the corresponding memory reclamation strategy, and perform memory swapping out of the target image resources in each interface active component, so as to achieve fine-grained memory management of the interface image resources of the target application.
[0068] In this embodiment, the memory management device obtains a memory evaluation threshold from the memory reclamation conditions; if the system memory evaluation data is greater than the memory evaluation threshold, a memory reclamation strategy corresponding to the memory evaluation data is generated; and the target image resources to be reclaimed from the interface image resources are determined according to the memory reclamation strategy, the active component marker, and the image resource marker. This enables fine-grained memory management of the interface image resources of the target application during the memory reclamation process.
[0069] like Figure 4 As shown, Figure 4 This is a flowchart illustrating an embodiment of memory swapping in the memory management method provided in this application. Figure 4 In the illustrated embodiment, the memory management method further includes steps 401 to 403: 401. Obtain the application type corresponding to the target application; 402. If the application type is a frozen application type, then the single-threaded swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource to obtain the first memory control result. 403. If the application type is an active application type, then the regular swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, and a second memory management result is obtained.
[0070] Based on the above embodiments, in this embodiment, the memory management device can select different target swap-out interfaces to perform memory swap-out processing on the target image resources through the program type corresponding to the target application, so as to release the memory occupied by the interface resources of the interface activity components in the target application that are to be reclaimed, thereby relieving the terminal memory pressure and improving the terminal operation stability.
[0071] Here, the application type is a program type that indicates whether the target application is in a frozen state. Optionally, in a specific embodiment, the application type includes a frozen application type and an active application type. The frozen application type indicates that the target application is in a frozen state. The active application type indicates that the target application is in an unfrozen state.
[0072] Optionally, if the memory management device determines that the application type is a frozen application, then the single-threaded swapout interface is used as the target swapout interface to perform memory swapping on the target image resource, obtaining a first memory management result, so as to release the memory resources of the frozen process in a timely manner. Here, the first memory management result represents the memory management result of performing memory swapping on an application of the frozen application type.
[0073] Optionally, if the memory management device determines that the application type is an active application, it uses the regular swap-out interface as the target swap-out interface to perform memory swapping on the target image resource, obtaining a second memory management result. That is, when the memory management device performs memory swapping on an active target application, it sends a memory swapping command to the target application through the regular swap-out interface to control the target application to perform memory swapping. This second memory management result is the memory management result used for memory swapping on active application types.
[0074] In this embodiment, the memory management device obtains the application type corresponding to the target application, which includes frozen application types and active application types. If the application type is a frozen application type, the single-threaded swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, resulting in a first memory management result. If the application type is an active application type, the regular swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, resulting in a second memory management result. This achieves different memory swap-out processing for applications in different running states, thereby improving the timeliness of memory swap-out processing.
[0075] To better implement the memory management method in the embodiments of this application, a memory management device is also provided in the embodiments of this application, such as... Figure 5 As shown, Figure 5 This is a schematic diagram of one embodiment of the memory management device provided in this application. Specifically, the memory management device 500 includes: The resource determination module 501 is configured to respond to a memory management request for a target application and determine the interface activity components and interface image resources associated with the target application. The tag recognition module 502 is configured to acquire the active component tag of the interface active component and the image resource tag of the interface image resource; The recycling evaluation module 503 is configured to determine the target image resources to be recycled in the interface image resources based on the active component marker and the image resource marker when the program running information and system memory information of the target application meet the memory recycling conditions. The memory management module 504 is configured to perform memory swapping processing on the target image resources using the target swapping interface to obtain memory management results.
[0076] In one possible implementation of this embodiment, before the memory management device obtains the active component tag of the interface active component and the image resource tag of the interface image resource, it further includes: In response to a component creation request for a target application, create a UI activity component corresponding to the target application, as well as an initial component tag and a root node tag object corresponding to the UI activity component; Create an initial image resource corresponding to the target application, and generate an image resource tag corresponding to the initial image resource based on the memory allocation address and memory length information of the initial image resource; Based on the root node marker object and the resource association module, a mapping relationship is established between the interface activity component and the associated initial image resource to obtain the interface image resource associated with the interface activity component. Record the resource object information corresponding to the interface image resource into the initial component tag to obtain the activity component tag corresponding to the interface activity component.
[0077] In one possible implementation of this embodiment, the memory management device establishes a mapping relationship between the interface activity component and the associated initial image resource based on the root node marker object and the resource association module, thereby obtaining the interface image resource associated with the interface activity component, including: Obtain the associated image resources from the initial image resources that are associated with the interface activity component; Image resource information of the associated image resources is recorded based on the root node marker object and the active component marker. Based on the image resource tags, record the activity component information corresponding to the interface activity component; Using the root node marker object, a mapping relationship between the interface active component and the associated initial image resource is established according to the image resource information and the active component information, thereby obtaining the interface image resource associated with the active component marker.
[0078] In one possible implementation of this embodiment, when the program execution information and system memory information of the target application meet the memory reclamation conditions, the memory management device determines the target image resources to be reclaimed from the interface image resources based on the active component marker and the image resource marker, including: Calculate system memory assessment data based on the program execution information and system memory information of the target application; When the system memory assessment data meets the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component tags and the image resource tags.
[0079] In one possible implementation of this embodiment, when the system memory evaluation data meets the memory reclamation conditions, the memory management device determines the target image resource to be reclaimed from the interface image resources based on the active component marker and the image resource marker, including: Obtain the memory evaluation threshold in the memory reclamation conditions; If the system memory assessment data is greater than the memory assessment threshold, a memory reclamation strategy corresponding to the memory assessment data is generated. The target image resources to be reclaimed in the interface image resources are determined according to the memory reclamation strategy, the active component marker, and the image resource marker.
[0080] In one possible implementation of this embodiment, the memory management device determines the target image resources to be reclaimed from the interface image resources according to the memory reclamation strategy, the active component marker, and the image resource marker, including: Based on the memory reclamation strategy, determine the active components to be reclaimed in the UI active components of the target application; Based on the activity component tag of the activity component to be recycled and the image resource tag, locate the interface image resource associated with the activity component to be recycled, and determine the interface image resource as the target image resource to be recycled.
[0081] In one possible implementation of this embodiment, the memory management result in the memory management device includes a first memory management result and a second memory management result; The memory management device uses the target swapping interface to perform memory swapping on the target image resources, obtaining memory management results, including: Obtain the application type corresponding to the target application, where the application type includes frozen application type and active application type; If the application type is a frozen application type, then the single-threaded swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, and the first memory control result is obtained. If the application type is an active application type, then the regular swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, resulting in a second memory management result.
[0082] In this embodiment, the memory management device, in response to a memory management request for a target application, determines the associated UI active components and UI image resources of the target application; obtains the active component marker of the UI active components and the image resource marker of the UI image resources; when the program running information and system memory information of the target application meet the memory reclamation conditions, it determines the target image resources to be reclaimed from the UI image resources based on the active component marker and the image resource marker; and performs memory swapping out processing on the target image resources using the target swapping out interface to obtain the memory management result. This achieves memory reclamation of target image resources belonging to a UI active component by using the active component marker and image resource marker, thereby accurately and promptly reclaiming bitmap resources to be reclaimed, alleviating terminal memory pressure, and improving terminal operational stability.
[0083] This invention also provides a memory management device, such as... Figure 6 As shown, Figure 6 This is a schematic diagram of an embodiment of the memory management device provided in this application.
[0084] The memory management device integrates any of the memory management devices provided in the embodiments of the present invention, and the memory management device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor from the steps of the memory management method described in any of the above-described memory management method embodiments.
[0085] Specifically, the memory management device may include components such as a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, a power supply 603, and an input unit 604. Those skilled in the art will understand that... Figure 6 The memory management device structure shown does not constitute a limitation on the memory management device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 601 is the control center of the memory management device. It connects to various parts of the memory management device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 602, and by calling data stored in the memory 602, it performs various functions and processes data, thereby providing overall monitoring of the memory management device. Optionally, the processor 601 may include one or more processing cores; preferably, the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 601.
[0086] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and memory management by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the memory management device, etc. In addition, the memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.
[0087] The memory management device also includes a power supply 603 that supplies power to the various components. Preferably, the power supply 603 can be logically connected to the processor 601 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 603 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0088] The memory management device may also include an input unit 604, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0089] Although not shown, the memory management device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 601 in the memory management device loads the executable files corresponding to the processes of one or more applications into the memory 602 according to the following instructions, and the processor 601 runs the applications stored in the memory 602 to realize various functions, as follows: In response to a memory management request for a target application, determine the UI activity components and UI image resources associated with the target application; Obtain the activity component tag of the interface activity component and the image resource tag of the interface image resource; When the program running information and system memory information of the target application meet the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component marker and the image resource marker. The target image resource is swapped out into memory using the target swap-out interface to obtain the memory management result.
[0090] Therefore, embodiments of the present invention provide a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk, etc. A computer program is stored thereon, which is loaded by a processor to execute the steps in any of the memory management methods provided in the embodiments of the present invention. For example, the computer program loaded by the processor may execute the following steps: In response to a memory management request for a target application, determine the UI activity components and UI image resources associated with the target application; Obtain the activity component tag of the interface activity component and the image resource tag of the interface image resource; When the program running information and system memory information of the target application meet the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component marker and the image resource marker. The target image resource is swapped out into memory using the target swap-out interface to obtain the memory management result.
[0091] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed descriptions of other embodiments above, which will not be repeated here.
[0092] In practice, each of the above units or structures can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units or structures, please refer to the previous method embodiments, which will not be repeated here.
[0093] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0094] The above provides a detailed description of a memory management method provided by the embodiments of this application. Specific embodiments have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A memory management method, characterized in that, The memory management method includes: In response to a memory management request for a target application, determine the UI activity components and UI image resources associated with the target application; Obtain the activity component tag of the interface activity component and the image resource tag of the interface image resource; When the program running information and system memory information of the target application meet the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component marker and the image resource marker. The target image resource is swapped out into memory using the target swap-out interface to obtain the memory management result.
2. The memory management method according to claim 1, characterized in that, Before obtaining the activity component tag of the interface activity component and the image resource tag of the interface image resource, the method further includes: In response to a component creation request for a target application, create a UI activity component corresponding to the target application, as well as an initial component tag and a root node tag object corresponding to the UI activity component; Create an initial image resource corresponding to the target application, and generate an image resource tag corresponding to the initial image resource based on the memory allocation address and memory length information of the initial image resource; Based on the root node marker object and the resource association module, a mapping relationship is established between the interface activity component and the associated initial image resource to obtain the interface image resource associated with the interface activity component. Record the resource object information corresponding to the interface image resource into the initial component tag to obtain the activity component tag corresponding to the interface activity component.
3. The memory management method according to claim 2, characterized in that, The step of establishing a mapping relationship between the interface activity component and the associated initial image resource based on the root node marker object and resource association module, and obtaining the interface image resource associated with the interface activity component, includes: Obtain the associated image resources from the initial image resources that are associated with the interface activity component; Image resource information of the associated image resources is recorded based on the root node marker object and the active component marker. Based on the image resource tags, record the activity component information corresponding to the interface activity component; Using the root node marker object, a mapping relationship between the interface active component and the associated initial image resource is established according to the image resource information and the active component information, thereby obtaining the interface image resource associated with the active component marker.
4. The memory management method according to claim 1, characterized in that, When the program execution information and system memory information of the target application meet the memory reclamation conditions, the step of determining the target image resources to be reclaimed in the interface image resources based on the active component marker and the image resource marker includes: Calculate system memory assessment data based on the program execution information and system memory information of the target application; When the system memory assessment data meets the memory reclamation conditions, the target image resources to be reclaimed in the interface image resources are determined based on the active component tags and the image resource tags.
5. The memory management method according to claim 4, characterized in that, When the system memory assessment data meets the memory reclamation conditions, the process of determining the target image resources to be reclaimed from the interface image resources based on the active component marker and the image resource marker includes: Obtain the memory evaluation threshold in the memory reclamation conditions; If the system memory assessment data is greater than the memory assessment threshold, a memory reclamation strategy corresponding to the memory assessment data is generated. The target image resources to be reclaimed in the interface image resources are determined according to the memory reclamation strategy, the active component marker, and the image resource marker.
6. The memory management method according to claim 5, characterized in that, The step of determining the target image resources to be reclaimed from the interface image resources according to the memory reclamation strategy, the active component marker, and the image resource marker includes: Based on the memory reclamation strategy, determine the active components to be reclaimed in the UI active components of the target application; Based on the activity component tag of the activity component to be recycled and the image resource tag, locate the interface image resource associated with the activity component to be recycled, and determine the interface image resource as the target image resource to be recycled.
7. The memory management method according to any one of claims 1-6, characterized in that, The memory management results include a first memory management result and a second memory management result; The process of performing memory swapping out of the target image resource using the target swapping-out interface to obtain memory management results includes: Obtain the application type corresponding to the target application, where the application type includes frozen application type and active application type; If the application type is a frozen application type, then the single-threaded swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, and the first memory control result is obtained. If the application type is an active application type, then the regular swap-out interface is used as the target swap-out interface to perform memory swap-out processing on the target image resource, resulting in a second memory management result.
8. A memory management device, characterized in that, The memory management device includes: The resource determination module is configured to respond to a memory management request for a target application and determine the UI activity components and UI image resources associated with the target application. The tag recognition module is configured to acquire the active component tag of the interface active component and the image resource tag of the interface image resource; The recycling assessment module is configured to determine the target image resources to be recycled in the interface image resources based on the active component marker and the image resource marker when the program running information and system memory information of the target application meet the memory recycling conditions. The memory management module is configured to perform memory swapping on the target image resources using the target swapping interface to obtain memory management results.
9. A memory management device, characterized in that, The memory management device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the memory management method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to execute the steps of the memory management method according to any one of claims 1 to 7.