Memory resource allocation method, device, terminal and storage medium

By using the memory resources of the file cleaning function as the reused memory resources of the UI process, the page lag caused by insufficient memory resources of the UI process in Linux system is solved, and the page fluency is improved.

CN113076194BActive Publication Date: 2025-04-04GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110336568.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-29
Publication Date
2025-04-04
Estimated Expiration
2041-03-29

AI Technical Summary

Technical Problem

In Linux systems, the memory resource recycling mechanism of the UI process causes the UI process to occupy less memory resources, causing the UI process to take longer, the page is stuttered, and the page is reduced.

Method used

By determining the memory resources available to the file cleaning function, use them as the multiplexed memory resources of the UI process, responding to the memory resource allocation instructions of the UI process, allocating memory resources to the UI process from the multiplexed memory resources to prevent page stuttering caused by insufficient memory resources.

Benefits of technology

It effectively prevents slow execution speed and page lag caused by insufficient memory resources of UI process, and improves page fluency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113076194B_ABST
    Figure CN113076194B_ABST
Patent Text Reader

Abstract

The present application relates to a memory resource allocation method, device, terminal and storage medium, and belongs to the field of terminal technology. The method includes: determining the memory resources available for the file cleaning function; determining the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process; in response to receiving an instruction to allocate memory resources for any UI process, allocating memory resources for any UI process based on the reused memory resources. Through this solution, it is possible to prevent the slow execution speed of the UI process caused by insufficient memory resources of the UI process, thereby preventing page jams and improving page fluency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of terminal technology, and in particular to a memory resource allocation method, device, terminal and storage medium. Background Art

[0002] At present, a recycling mechanism for recycling memory resources is set up in the Linux (name of an operating system) system. In the process of recycling memory resources, the recycling mechanism is used to recycle memory resources for all processes that meet the recycling conditions. However, for the human-computer interaction interface (UI) process, if this recycling mechanism is used, the memory resources occupied by the UI process will be low, resulting in a longer UI process time, causing page jams and reduced page fluency. Summary of the invention

[0003] The embodiments of the present application provide a memory resource allocation method, device, terminal and storage medium, which can improve page fluency. The technical solution is as follows:

[0004] In one aspect, a method for allocating memory resources is provided, the method comprising:

[0005] Determine the memory resources available to the file cleanup function;

[0006] Determine the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process;

[0007] In response to receiving an instruction to allocate memory resources to any UI process, memory resources are allocated to the any UI process based on the reused memory resources.

[0008] On the other hand, a memory resource allocation device is provided, the device comprising:

[0009] A first determination module, used to determine the memory resources available for the file cleaning function;

[0010] A second determination module is used to determine the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process;

[0011] The resource allocation module is used to allocate memory resources to any UI process based on the reused memory resources in response to receiving an instruction to allocate memory resources to any UI process.

[0012] On the other hand, a terminal is provided, comprising a processor and a memory; the memory stores at least one program code, and the at least one program code is used to be executed by the processor to implement the memory resource allocation method as described in the above aspect.

[0013] On the other hand, a computer-readable storage medium is provided, wherein the storage medium stores at least one program code, and the at least one program code is used to be executed by a processor to implement the memory resource allocation method as described in the above aspects.

[0014] On the other hand, a computer program product is provided. The computer program product stores at least one program code. The at least one program code is loaded and executed by a processor to implement the memory resource allocation method described in the above aspect.

[0015] In an embodiment of the present application, after receiving an instruction to allocate memory resources to any UI process, a file cleaning function is started, and then the memory resources of the file cleaning function are turned on, and the memory resources are used as reused memory resources. Therefore, when the first free memory resources of the reused memory resources are sufficient to meet the target memory resources of any UI process, memory resources are allocated to the any UI process from the first free memory resources, thereby preventing the slow execution speed of the UI process caused by insufficient memory resources of the UI process, thereby preventing page freezes and improving page fluency. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A flowchart of a storage resource allocation method according to an exemplary embodiment of the present application is shown;

[0017] Figure 2 A flowchart of a storage resource allocation method according to an exemplary embodiment of the present application is shown;

[0018] Figure 3 A flowchart of a storage resource allocation method according to an exemplary embodiment of the present application is shown;

[0019] Figure 4 A flowchart of a storage resource allocation method according to an exemplary embodiment of the present application is shown;

[0020] Figure 5 A flowchart of a storage resource allocation method according to an exemplary embodiment of the present application is shown;

[0021] Figure 6 A flowchart of a storage resource allocation method according to an exemplary embodiment of the present application is shown;

[0022] Figure 7 A structural block diagram of a storage resource allocation device shown in an exemplary embodiment of the present application is shown;

[0023] Figure 8 A schematic diagram of the structure of a terminal shown in an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION

[0024] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0025] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0026] At present, in order to ensure the normal operation of the Linux system and the amount of free memory resources, the Linux system has set up a memory resource recycling mechanism. Memory resource recycling means that if data can be saved to disk, when memory resources are insufficient, these data can be saved to disk, and then the memory resources occupied by these data are released as free memory resources for use by other processes in the system.

[0027] In the process of memory resource recycling, the Least Recently Used (LRU) linked list is often used to recycle memory resources. Usually when memory resources are insufficient, the memory resources occupied by the corresponding process will be recycled through the LRU linked list. However, in order to give users a better user experience, the importance of the UI process is generally set higher than other background processes. Among them, the fluency of the UI process will affect the experience of human-computer interaction. Therefore, in the process of memory resource recycling, if the scenario for recycling the UI process is the same as that of other processes, the memory resources used by the UI process may be recycled, which will result in less memory resources occupied by the UI process, causing the foreground to freeze and reduce the fluency of the page.

[0028] In the related art, in order to ensure that the UI process can run normally, a certain amount of memory resources are usually reserved for the UI process in the system memory resources. These reserved memory resources are only used for memory resource allocation of the UI process. In this case, other types of processes cannot use these memory resources. When the system's memory resources are relatively tight, other types of processes cannot use the reserved memory resources, resulting in a waste of the reserved memory resources and making the memory resources even tighter. Therefore, there is an urgent need for a memory resource allocation method to allocate memory resources to the UI process, so as to avoid wasting memory resources while ensuring that the UI process can run normally.

[0029] Figure 1A flowchart of a memory resource allocation method shown in an exemplary embodiment of the present application is shown. The execution subject in the embodiment of the present application may be a terminal, or a processor in the terminal or an operating system in the terminal. This embodiment is described by taking the execution subject as an example. In this embodiment, when the terminal receives an instruction to allocate memory resources for any UI process, it directly allocates memory resources for the any UI process in the reused memory resources. The method includes:

[0030] Step 101: The terminal determines memory resources available for the file cleaning function.

[0031] In this step, the terminal reserves memory resources for a file cleaning function, which is used to clean up cleanable files.

[0032] In some embodiments, the file cleaning function is implemented through the cleancache process. The cache process refers to the process of storing some files that may be accessed during the process running in the memory resources. When it needs to be saved to the disk, the files in the memory are read through the external memory disk. The cleancache process refers to the process of storing the file process corresponding to the process that does not need to interact with the external memory at present. The files stored through the cleancache process can be cleaned directly during cleaning without interacting with the external disk.

[0033] In this implementation, the memory resources occupied by the cleancache process are determined and used as reused memory resources of the UI process. Since the files stored in the memory resources by the cleancache process do not need to interact with the external disk when cleaning, when reusing memory resources, the system's IO load can be reduced, thereby improving system performance.

[0034] Before this step, see Figure 2 The terminal reserves memory resources for the purgeable file. The process of reserving memory resources is implemented by the following steps (1)-(3), including:

[0035] (1) The terminal allocates reserved memory resources from the total memory resources of the system.

[0036] Among them, the reserved memory resources are available memory resources for the file cleaning function. In some embodiments, the reserved memory resources are memory resources composed of multiple discontinuous memory resources. In this implementation, by forming the reserved memory resources with multiple discontinuous memory resources, it is ensured that the memory resources that can be used can be reserved for the file cleaning function. In some embodiments, the reserved memory resources are continuous memory resources. The memory resource reservation process is: the terminal determines continuous memory resources in the total memory resources of the system; and allocates continuous memory resources to the file cleaning function. In this implementation, the reserved memory resources are determined as continuous memory resources, which ensures that the reserved memory resources can meet the situation where the UI process occupies a large amount of memory resources.

[0037] See also Figure 3 In this step, the terminal divides the memory resources for the UI process from the total memory resources of the system. The terminal determines whether the reserved memory resources are saved successfully. If so, the following step (2) is executed; if not, the terminal starts the memory management system and re-divides the reserved memory resources.

[0038] One point that needs to be explained is that the size of the reserved memory resource is set according to needs. In the embodiment of the present application, the size of the reserved memory resource is not specifically limited.

[0039] (2) The terminal determines the function identifier of the file cleaning function.

[0040] Continue to see Figure 3 In this step, the terminal determines the function identifier used to identify whether the file cleaning function is started when the file cleaning function is turned on. For example, the function identifier is Init_clean_cache.

[0041] (3) The terminal binds the function identifier of the file cleaning function to the reserved memory resources.

[0042] In this step, continue to see Figure 3 , the terminal assigns the source stream memory resource to the target function identifier. For example, the reserved memory is assigned to Init_clean_cache.

[0043] In this implementation, by binding the reserved memory resources to the file cleaning function, the reserved memory resources are determined as the memory resources occupied by the cleanable files in the file cleaning function, so that the memory resources can be used as multiplexed memory resources with the UI process, thereby reducing the problem of the UI process not being able to proceed normally due to insufficient memory allocation or allocation failure.

[0044] Step 102: The terminal determines the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process.

[0045] In this step, the terminal allocates the memory resources available for the file cleaning function as reserved memory resources for the UI process. The process is: the terminal sets the start flag of the file cleaning function to the UI process. That is, when the terminal detects that the UI process needs to be executed, the file cleaning function is automatically started, so that the UI process can use the memory resources available for the file cleaning function.

[0046] Step 103: In response to receiving the instruction to allocate memory resources to any UI process, the terminal allocates memory resources to any UI process based on reused memory resources.

[0047] In response to receiving an instruction to allocate memory resources for any UI process, the terminal starts a file cleaning function and enables the file cleaning function and the multiplexing memory resources of the UI process.

[0048] In this step, see Figure 4 When the terminal receives the instruction to allocate memory resources for the process, it determines whether the process is a UI process. If the process is a non-UI process, the terminal allocates memory resources for the process from the free memory resources of the system. At this time, when the free memory resources in the system are insufficient, the terminal can release the occupied memory resources and recycle some memory resources to ensure that the process can continue. If the process is a UI process, the terminal executes step 103.

[0049] The process of allocating memory resources to any UI process based on the reuse of memory resources is implemented by the following steps (1)-(2), including:

[0050] (1) The terminal determines a first idle memory resource from the multiplexed memory resources.

[0051] The first free memory resource is the memory resource in the reused memory resources except the memory resources occupied by the cleanable files and other UI processes. In this step, the terminal determines the memory resources occupied by the cleanable files of the file cleaning function and the memory resources occupied by other UI processes in the reused memory resources, and determines the memory resources in the reused memory resources except the memory resources occupied by the cleanable files and the memory resources occupied by other UI processes as the first free memory resources.

[0052] (2) If the first free memory resources are not less than the target memory resources, the terminal allocates memory resources for any UI process in the first free memory resources.

[0053] The target memory resource is the memory resource required by any UI process. In this step, the terminal predicts the memory resource required when executing any UI process and determines the memory resource as the target memory resource. If the first free memory resource is not less than the target memory resource, the terminal allocates memory resources to the any UI process from the first free memory resource.

[0054] In this implementation, after receiving an instruction to allocate resources to any UI process, the terminal starts the file cleaning function, and then turns on the memory resources of the file cleaning function, and uses the memory resources as reused memory resources. When the first free memory resources of the reused memory resources are sufficient to meet the target memory resources of any UI process, memory resources are allocated to the any UI process from the first free memory resources, thereby preventing the slow execution of the UI process due to insufficient memory resources of the UI process, thereby preventing page freezes and improving page fluency.

[0055] In addition, if the first free memory resource is insufficient, the terminal returns to the system memory resource management and allocates memory resources to the any UI process from the memory resources of the system. The process is: if the first free memory resource is less than the target memory resource, the terminal allocates memory resources to the any UI process based on the fourth free memory resource of the system.

[0056] The fourth idle memory resource is an available memory resource that is not currently occupied in the system's memory resources. If the fourth idle memory resource is not less than the target memory resource, the terminal allocates memory resources to any UI process in the fourth idle memory resource of the system. If the fourth idle memory resource is less than the target memory resource, the terminal releases the occupied memory resources in the system; and allocates memory resources to any UI process in the second idle memory resource of the system, and the second idle memory resource at least includes the memory resources released by the system.

[0057] The second free memory resource also includes a fourth free memory resource. The process of the terminal allocating memory resources for any UI process in the second free memory resource of the system is similar to the process of the terminal allocating memory resources for any UI process in the first free memory resource, which will not be repeated here.

[0058] The process of releasing the occupied memory resources in the system by the terminal is as follows: the terminal determines the process of the memory resources to be reclaimed, saves the process to an external disk, and releases the memory resources occupied by the process.

[0059] In a possible embodiment, the terminal reclaims the currently occupied memory resources according to the ULR linked list. In a possible implementation, the terminal reclaims the memory resources occupied by the process according to the priority of the process occupying the memory resources. The priority of the process is a priority determined based on at least one of the attributes such as the size of the memory resources occupied by the process, the time required for the process to execute, and the recyclability of the process.

[0060] In this implementation, if the available memory resources in the reused memory resources do not meet the resources required to execute the UI process, the terminal continues to allocate resources to the UI process from the system's memory resources, thereby ensuring that the UI process can be allocated available memory resources, thereby ensuring the normal execution of the UI process and ensuring the smoothness of the page.

[0061] If the first free memory resource is insufficient, the terminal can also release the memory resources in the reused memory resource, and allocate memory resources to any UI process according to the released memory resources in the reused memory resource. The process can be: if the first free memory resource is less than the target memory resource, the terminal releases the resources occupied by the file cleaning function in the reused memory resource; and allocates memory resources to any UI process in the third free memory resource in the reused memory resource, and the third free memory resource at least includes the memory resources released by the file cleaning function.

[0062] The process of releasing the memory resources occupied by the purgeable files in the reused memory resources by the terminal is as follows: the terminal deletes the purgeable files in the reused memory resources. In this implementation, the terminal does not need to interact with the reused memory resources and the external disk, thereby improving the IO performance of the system.

[0063] Alternatively, the terminal stores the cleanable files in the reused memory resources in an external disk, and then deletes the cleanable files in the reused memory resources. In this implementation, the terminal first stores the cleanable files in the external disk, thereby preventing the cleanable files from being unable to be obtained when they are called again.

[0064] It should be noted that the process of the terminal reclaiming the memory resources in the reused memory resources is similar to the process of the terminal reclaiming the memory resources of the system, which will not be repeated here.

[0065] Another point that needs to be explained is that before the terminal releases the reused memory resources, it can first determine whether the free memory resources in the reused memory resources are not less than the target memory resources after the memory resources are recycled. If so, the process of releasing the occupied memory resources in the reused memory resources is executed; if so, the process of allocating memory resources from the system's memory resources for any UI process is executed.

[0066] Correspondingly, if the first free memory resources are less than the target memory resources, the terminal first releases the reused memory resources. If the free memory resources after the reused memory resources are released are not less than the target memory resources, memory resources will continue to be allocated from the reused memory resources for any UI process; if the free memory resources after the reused memory resources are released are less than the target memory resources, memory resources will be allocated from the system's memory resources for any UI process.

[0067] In an embodiment of the present application, after receiving an instruction to allocate memory resources to any UI process, a file cleaning function is started, and then the memory resources of the file cleaning function are turned on, and the memory resources are used as reused memory resources. Therefore, when the first free memory resources of the reused memory resources are sufficient to meet the target memory resources of any UI process, memory resources are allocated to the any UI process from the first free memory resources, thereby preventing the slow execution speed of the UI process caused by insufficient memory resources of the UI process, thereby preventing page freezes and improving page fluency.

[0068] Figure 5 A flowchart of a memory resource allocation method shown in an exemplary embodiment of the present application is shown. The execution subject in the embodiment of the present application can be a terminal, or a processor in the terminal or an operating system in the terminal. This embodiment is described by taking the execution subject as an example. In this embodiment, continue to refer to Figure 4 , when the terminal receives an instruction to allocate memory resources for any UI process, it first allocates memory resources for the UI process from the free memory resources of the system. If the free memory resources of the system are insufficient to execute the UI process, memory resources are allocated for the UI process from the reused resources.

[0069] The method includes:

[0070] Step 501: The terminal determines the memory resources available for the file cleaning function.

[0071] This step is similar to step 101 and will not be described again here.

[0072] Step 502: The terminal determines the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process.

[0073] This step is similar to step 102 and will not be described again here.

[0074] Step 503: The terminal determines a second idle memory resource from the memory resources of the system.

[0075] The second free memory resource is a current free memory resource in the system's memory resources.

[0076] One point that needs to be explained is that, at this time, the occupied memory resources in the system are memory resources that cannot be reclaimed.

[0077] The terminal determines whether the second free memory resource is less than the target memory resource. If so, step 504 is performed; if the second free memory resource is not less than the target memory resource, memory resources are allocated to any UI process in the second free memory resource.

[0078] In this implementation, the terminal first allocates memory resources for the UI process from the system's memory resources to avoid the system having excess free memory resources. When reused memory resources are used at this time, the file data stored in the reused memory resources may be deleted, causing the terminal to need to call these file data again from the external disk, thereby preventing waste of memory resources and improving the IO performance of the terminal system.

[0079] Step 504: If the second free memory resources are less than the target memory resources, memory resources are allocated to any UI process based on the reused memory resources.

[0080] The target memory resource is the memory resource required by any UI process.

[0081] This step is similar to step 103 and will not be described again here.

[0082] One thing to note is that, continue to refer to Figure 4 In this implementation, if the free memory resources in the reused memory resources after release are still not less than the target memory resources, the memory resources in the system can be released directly without determining whether the free memory resources in the system are less than the target memory resources.

[0083] In an embodiment of the present application, after receiving an instruction to allocate memory resources to any UI process, a file cleaning function is started, and then the memory resources of the file cleaning function are turned on, and the memory resources are used as reused memory resources. Therefore, when the first free memory resources of the reused memory resources are sufficient to meet the target memory resources of any UI process, memory resources are allocated to the any UI process from the first free memory resources, thereby preventing the slow execution speed of the UI process caused by insufficient memory resources of the UI process, thereby preventing page freezes and improving page fluency.

[0084] In some embodiments, before allocating memory resources to the UI process, the terminal also detects whether the reused memory resources are available, and only executes the process of allocating memory resources to the UI process when the reused memory resources are available. Figure 6 , Figure 6A flowchart of a memory resource allocation method shown in an exemplary embodiment of the present application is shown. The execution subject in the embodiment of the present application may be a terminal, or a processor in the terminal or an operating system in the terminal. This embodiment is described by taking the execution subject as an example. The method includes:

[0085] Step 601: The terminal determines the memory resources available for the file cleaning function.

[0086] This step is similar to step 101 and will not be described again here.

[0087] Step 602: The terminal determines the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process.

[0088] This step is similar to step 102 and will not be described again here.

[0089] Step 603: The terminal determines the resource occupancy ratio in the reused memory resources.

[0090] The resource occupancy ratio is the ratio of memory resources occupied by other UI processes to the reused memory resources.

[0091] In this step, the terminal counts the memory resources in the reused memory resources that have been occupied by other UI processes, and determines the proportion of the memory resources in the reused memory resources. The terminal compares the resource occupation ratio with the first preset ratio. If the resource occupation ratio does not exceed the first preset ratio, the terminal determines that the current reused memory resources are reusable memory resources and executes step 704; if the resource occupation ratio exceeds the first preset ratio, the reused memory resources are set as unavailable memory resources; and the target resources are allocated to the UI process from the system's memory resources.

[0092] The first preset ratio is set as required, and is not specifically limited in the embodiment of the present application. For example, the first preset ratio is 3 / 4 or 4 / 5.

[0093] In addition, after setting the reused memory resource as an unavailable resource, when the terminal receives an instruction to allocate memory resources to the UI process again, it can determine the resource occupancy ratio again. If the resource occupancy ratio does not exceed the second preset ratio, the reused memory resource is set to an available resource again.

[0094] The second preset ratio is set as required, for example, the second preset ratio is 1 / 2.

[0095] In this implementation, whether to deactivate the reused memory resources is determined based on the resource occupancy ratio of the UI process in the reused memory resources to prevent the UI process from using up the memory resources in the reused memory resources, resulting in the inability to store files of the file cleaning function.

[0096] Step 604: If the resource occupancy ratio does not exceed the preset ratio, the terminal allocates memory resources to any UI process based on reused memory resources.

[0097] This step is similar to step 103 and will not be described again here.

[0098] In an embodiment of the present application, after receiving an instruction to allocate memory resources to any UI process, a file cleaning function is started, and then the memory resources of the file cleaning function are turned on, and the memory resources are used as reused memory resources. Therefore, when the first free memory resources of the reused memory resources are sufficient to meet the target memory resources of any UI process, memory resources are allocated to the any UI process from the first free memory resources, thereby preventing the slow execution speed of the UI process caused by insufficient memory resources of the UI process, thereby preventing page freezes and improving page fluency.

[0099] Please refer to Figure 7 , which shows a structural block diagram of a memory resource allocation device provided by an embodiment of the present application. The memory resource allocation device can be implemented as all or part of a processor through software, hardware, or a combination of both. The device includes:

[0100] A first determination module 701 is used to determine the memory resources available for the file cleaning function;

[0101] The second determining module 702 is used to determine the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process;

[0102] The resource allocation module 703 is configured to allocate memory resources to any UI process based on the reused memory resources in response to receiving an instruction to allocate memory resources to any UI process.

[0103] In some embodiments, the resource allocation module 703 includes:

[0104] A first determining unit, configured to determine a first idle memory resource from the multiplexed memory resource;

[0105] The first resource allocation unit is used to allocate memory resources for the any UI process in the first free memory resources if the first free memory resources are not less than the target memory resources, and the target memory resources are the memory resources required by the any UI process.

[0106] In some embodiments, the apparatus further comprises:

[0107] A first releasing module, configured to release the occupied memory resources in the system if the first free memory resources are less than the target memory resources;

[0108] The resource allocation module 703 is further configured to allocate memory resources for any UI process from the second idle memory resources of the system, where the second idle memory resources at least include memory resources released by the system.

[0109] In some embodiments, the apparatus further comprises:

[0110] A second releasing module is used to release the memory resources occupied by the file cleaning function in the reused memory resources if the first free memory resources are less than the target memory resources;

[0111] The resource allocation module 703 is further configured to allocate memory resources to any UI process from a third idle memory resource in the reused memory resource, where the third idle memory resource at least includes memory resources released by a file cleaning function.

[0112] In some embodiments, the apparatus further comprises:

[0113] A third determining module, used to determine a second idle memory resource from the memory resources of the system;

[0114] The resource allocation module 703 is further used to allocate memory resources to any UI process based on the reused memory resources if the second free memory resources are less than the target memory resources, and the target memory resources are the memory resources required by any UI process.

[0115] In some embodiments, the apparatus further comprises:

[0116] The resource allocation module 703 is further configured to allocate memory resources to any UI process in the second free memory resources if the second free memory resources are not less than the target memory resources.

[0117] In some embodiments, the resource allocation module 703 includes:

[0118] A second determining unit is used to determine a resource occupancy ratio in the reused memory resource, where the resource occupancy ratio is a ratio of memory resources occupied by other UI processes in the reused memory resource;

[0119] The second resource allocation unit is further configured to allocate memory resources to any UI process in the reused memory resources if the resource occupancy ratio does not exceed a preset ratio.

[0120] In some embodiments, the apparatus further comprises:

[0121] A setting module, used to set the reused memory resource as an unavailable resource if the resource occupancy ratio exceeds the preset ratio;

[0122] The resource allocation module 703 is also used to allocate memory resources in the system's memory resources for any UI process.

[0123] In some embodiments, the apparatus further comprises:

[0124] A fourth determining module, used to determine continuous memory resources in the total memory resources of the system;

[0125] The fifth determining module is used to allocate the continuous memory resource to the file cleaning function.

[0126] In an embodiment of the present application, after receiving an instruction to allocate memory resources to any UI process, a file cleaning function is started, and then the memory resources of the file cleaning function are turned on, and the memory resources are used as reused memory resources. Therefore, when the first free memory resources of the reused memory resources are sufficient to meet the target memory resources of any UI process, memory resources are allocated to the any UI process from the first free memory resources, thereby preventing the slow execution speed of the UI process caused by insufficient memory resources of the UI process, thereby preventing page freezes and improving page fluency.

[0127] Please refer to Figure 8 , which shows a block diagram of a terminal 800 provided by an exemplary embodiment of the present application. The terminal 800 may be a terminal with communication functions such as a smart phone, a tablet computer, a wearable device, etc. The terminal 800 in the present application may include one or more of the following components: a processor 810, a memory 820, and a UI interaction module 830.

[0128] The processor 810 includes one or more processing cores. The processor 810 uses various interfaces and lines to connect the various parts of the entire terminal 800, and executes various functions and processes data of the terminal 800 by running or executing instructions, programs, code sets or instruction sets stored in the memory 820, and calling data stored in the memory 820. Optionally, the processor 810 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 810 can integrate one or more combinations of a central processing unit (CPU), a graphics processing unit (GPU), a neural network processor (NPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the NPU is used to implement artificial intelligence (AI) functions; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 810, but may be implemented by a separate chip.

[0129] The memory 820 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 820 includes a non-transitory computer-readable storage medium. The memory 820 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 820 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc.; the data storage area may store data (such as audio data, a phone book), etc., created according to the use of the terminal 800.

[0130] The UI interaction module 830 is used to generate a UI interaction process and implement the function of interacting with the user through the terminal 600. For example, a click operation of the user in the terminal 600 is received, and the UI interaction module 830 determines the page display content corresponding to the click operation and displays the page display content.

[0131] The display screen is a display component for displaying a user interface. Optionally, the display screen is a display screen with a touch function, through which the user can use any suitable object such as a finger, a touch pen, etc. to perform touch operations on the display screen.

[0132] The display screen is usually arranged on the front panel of the terminal. The display screen can be designed as a full screen, a curved screen, a special-shaped screen, a double-sided screen or a folding screen. The display screen can also be designed as a combination of a full screen and a curved screen, a combination of a special-shaped screen and a curved screen, etc., which is not limited in this embodiment.

[0133] In addition, those skilled in the art can understand that the structure of the terminal 800 shown in the above drawings does not constitute a limitation on the terminal 800, and the terminal 800 may include more or fewer components than shown, or combine certain components, or arrange the components differently. For example, the terminal 800 also includes a microphone, a speaker, a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (Wireless Fidelity, Wi-Fi) module, a power supply, a Bluetooth module and other components, which are not described in detail here.

[0134] An embodiment of the present application further provides a computer-readable medium, which stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the memory resource allocation method shown in the above embodiments.

[0135] An embodiment of the present application further provides a computer program product, which stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the memory resource allocation method shown in the above embodiments.

[0136] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.

[0137] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A memory resource allocation method, characterized in that: The method comprises: Determine memory resources available for a file cleaning function, where the memory resources are reserved memory resources divided from total memory resources of the system and are used to store cleanable files for the file cleaning function, where the cleanable files are files corresponding to processes that do not need to interact with an external disk; Determine the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process; In response to receiving an instruction to allocate memory resources for any UI process, determining a first free memory resource from the reused memory resources, where the first free memory resource is a memory resource in the reused memory resource excluding the purgeable file and the memory resources occupied by other UI processes; If the first free memory resources are not less than the target memory resources, memory resources are allocated to any UI process in the first free memory resources, and the target memory resources are the memory resources required by any UI process.

2. The method according to claim 1, characterized in that The method further comprises: If the first free memory resources are less than the target memory resources, releasing the occupied memory resources in the system; Memory resources are allocated to any UI process from second idle memory resources of the system, where the second idle memory resources at least include memory resources released by the system.

3. The method according to claim 1, characterized in that The method further comprises: If the first free memory resources are less than the target memory resources, releasing the memory resources occupied by the file cleaning function in the reused memory resources; Memory resources are allocated to any one of the UI processes from third idle memory resources in the reused memory resources, and the third idle memory resources at least include memory resources released by the file cleaning function.

4. The method according to claim 1, characterized in that Before determining the first idle memory resource from the reused memory resource, the method further includes: Determining a second free memory resource from the memory resources of the system; If the second free memory resource is less than the target memory resource, the step of determining the first free memory resource from the reused memory resource is performed.

5. The method according to claim 4, characterized in that The method further comprises: If the second free memory resources are not less than the target memory resources, memory resources are allocated to any UI process in the second free memory resources.

6. The method according to claim 1, characterized in that The determining of the first idle memory resource from the multiplexed memory resources comprises: Determine a resource occupancy ratio in the reused memory resources, where the resource occupancy ratio is a ratio of memory resources occupied by other UI processes in the reused memory resources; If the resource occupancy ratio does not exceed a preset ratio, a first idle memory resource is determined from the reused memory resources.

7. The method according to claim 6, characterized in that The method further comprises: If the resource occupancy ratio exceeds the preset ratio, setting the reused memory resource as an unavailable resource; Allocate memory resources for any UI process in the memory resources of the system.

8. The method according to claim 1, characterized in that The method further comprises: Determining contiguous memory resources among the total memory resources of the system; The contiguous memory resources are allocated to the file cleaning function.

9. A memory resource allocation device, characterized in that: The device comprises: A first determination module is used to determine memory resources available for a file cleaning function, wherein the memory resources are reserved memory resources divided from the total memory resources of the system and are used to store cleanable files of the file cleaning function, wherein the cleanable files are files corresponding to processes that do not need to interact with an external disk; A second determination module is used to determine the memory resources available for the file cleaning function as the reused memory resources of the user interaction interface UI process; A resource allocation module, used to determine a first free memory resource from the reused memory resources in response to receiving an instruction to allocate memory resources for any UI process, the first free memory resource being the memory resources in the reused memory resources excluding the memory resources occupied by the purgeable files and other UI processes; if the first free memory resource is not less than the target memory resource, allocate memory resources for the any UI process in the first free memory resource, the target memory resource being the memory resource required by the any UI process.

10. A terminal, characterized in that: The terminal includes a processor and a memory; the memory stores at least one program code, and the at least one program code is used to be executed by the processor to implement the memory resource allocation method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program code, and the at least one program code is used to be executed by a processor to implement the memory resource allocation method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Equipment control method and device, storage medium and electronic device

    CN110895492A