Memory cleaning method, device and equipment, storage medium and vehicle
By calculating the memory cleaning benefits of the process of killing in the operating system and determining the target process based on the revenue, the problem that the LKMD method of killing in the existing technology cannot ensure the improvement of memory state, achieving more accurate memory release and improving the memory state of the operating system.
Patent Information
- Application Number
- CN202311360818.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-19
- Publication Date
- 2025-04-22
AI Technical Summary
In prior art In operating systems that use memory optimization technologies such as ZRAM, the LKMD method cannot ensure that the memory state of the operating system can be improved when detecting processes, because it only considers the priority of the process, and does not consider whether the actually released memory meets the needs.
By calculating the memory cleaning income of the process before the kill process, if the income indicates that the system's available memory can be increased after the kill process, the process is determined as the target kill process and perform the kill process to free up the memory it occupies.
Ensure the accuracy of process detection and killing, further ensure that the memory state of the operating system can be improved, and avoid the deterioration of memory state caused by uncertain memory release.
Smart Images

Figure CN119862021A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a memory cleaning method, device, equipment, storage medium and vehicle. Background Art
[0002] Memory resources are one of the most important resources in the operating system. The operation of various processes is based on memory resources. Whether the memory resources are sufficient or not directly affects whether the process can run smoothly.
[0003] When the memory is insufficient, some memory can be released by killing the process. In the prior art, low-priority processes are usually killed directly according to certain strategies through the LKMD (low memory killer deamon) method. However, in operating systems that use memory optimization technologies such as ZRAM, LKMD only considers the priority of the process being killed, and does not obtain whether the memory actually released by the killed process can meet the demand, resulting in the fact that killing the process through the LKMD method cannot ensure that the memory status of the operating system can be improved. Summary of the invention
[0004] In order to solve the above technical problems, the present disclosure provides a memory cleaning method, device, equipment, storage medium and vehicle to ensure that the memory state of the operating system can be improved.
[0005] In a first aspect, an embodiment of the present disclosure provides a memory cleaning method, comprising:
[0006] In response to the need to release memory, a candidate process to be killed is selected from a preset process list;
[0007] Calculating the memory cleaning benefit obtained after killing the candidate killing process, wherein the memory cleaning benefit represents the impact of killing the candidate killing process on the system available memory;
[0008] If the memory cleaning benefit indicates that the available memory of the system increases after killing the candidate killing process, determining the candidate killing process as the target killing process;
[0009] The target process is killed to release the memory occupied by the target process.
[0010] In some embodiments, the calculating of the memory cleaning benefit obtained after killing the candidate killing process includes:
[0011] Obtaining the startup memory required for initializing the candidate killing process, the physical memory occupied by the candidate killing process, and the compressed memory occupied by the candidate killing process;
[0012] The physical memory occupied by the candidate killing process and the compressed memory occupied by the candidate killing process are summed to obtain the actual released memory after killing the candidate killing process;
[0013] The actually released memory is compared with the startup memory to obtain the memory cleaning benefit.
[0014] In some embodiments, the comparing the actually released memory with the startup memory to obtain the memory cleanup benefit comprises:
[0015] If the actually released memory is greater than the startup memory, determining that the memory cleanup benefit is a positive benefit;
[0016] If the actually released memory is less than or equal to the startup memory, it is determined that the memory cleanup benefit is a negative benefit.
[0017] In some embodiments, if the memory cleaning benefit indicates that the available memory of the system increases after killing the candidate killing process, before determining that the candidate killing process is the target killing process, the method further includes:
[0018] If the memory cleaning benefit is a positive benefit, then determining that the memory cleaning benefit represents that the system available memory increases after killing the candidate killing process.
[0019] In some embodiments, the method further comprises:
[0020] Obtain the physical memory occupied by the target killing process;
[0021] If the sum of the current available memory value and the physical memory occupied by the target process to be killed is greater than the preset memory threshold, the memory release request received during the process of killing the target process is ignored.
[0022] In some embodiments, selecting a candidate process to be killed from a preset process list includes:
[0023] Traverse the preset process list and determine at least one process with the highest probability of being killed;
[0024] The process that occupies the largest physical memory is selected from the at least one process that has the highest possibility of being killed as the candidate process to be killed.
[0025] In a second aspect, an embodiment of the present disclosure provides a memory cleaning device, comprising:
[0026] A selection module, for selecting a candidate process to be killed from a preset process list in response to a need to release memory;
[0027] A calculation module, used for calculating the memory cleaning benefit obtained after killing the candidate killing process, wherein the memory cleaning benefit represents the impact of killing the candidate killing process on the available memory of the system;
[0028] A determination module, configured to determine the candidate killing process as a target killing process if the memory cleaning benefit indicates that the system available memory increases after the candidate killing process is killed;
[0029] The killing module is used to kill the target killing process to release the memory occupied by the target process.
[0030] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0031] Memory;
[0032] Processor; and
[0033] Computer programs;
[0034] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0035] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.
[0036] In a fifth aspect, an embodiment of the present disclosure provides a vehicle, comprising the device, electronic device or computer-readable storage medium as described above.
[0037] The memory cleaning method, apparatus, device, storage medium and vehicle provided by the embodiments of the present disclosure ensure the accuracy of process killing by calculating the memory cleaning benefit of killing the process before killing the process, and then performing the killing operation after determining that the memory cleaning benefit indicates that killing the process can increase the available memory in the system, thereby ensuring the accuracy of process killing and further ensuring that the memory state of the operating system can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] Figure 1A flow chart of a memory cleaning method provided in an embodiment of the present disclosure;
[0041] Figure 2 A flow chart of a memory cleaning method provided by another embodiment of the present disclosure;
[0042] Figure 3 A flow chart of a memory cleaning method provided by another embodiment of the present disclosure;
[0043] Figure 4 A flow chart of a memory cleaning method provided by another embodiment of the present disclosure;
[0044] Figure 5 A schematic diagram of the structure of a memory cleaning device provided in an embodiment of the present disclosure;
[0045] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0046] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0047] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0048] The present disclosure provides a memory cleaning method, which is described below in conjunction with a specific embodiment.
[0049] Figure 1 A flow chart of a memory cleaning method provided in an embodiment of the present disclosure. The method can be applied to any terminal device with a data processing function, wherein the terminal device can be a car computer, a smart phone, a PDA, a tablet computer, a laptop, an all-in-one machine, an intelligent driving device, etc. It is understandable that the memory cleaning method provided in an embodiment of the present disclosure can also be applied in other scenarios.
[0050] Below Figure 1 The memory cleaning method shown in the figure is introduced. The specific steps of this method are as follows:
[0051] S101. In response to the need to release memory, a candidate process to be killed is selected from a preset process list.
[0052] When memory pressure comes, first determine the current memory waterline in the system. The memory waterline is used to indicate the remaining memory in the current system, and its boundaries are usually divided into high, low, and min. When the remaining memory in the system is above high, the system believes that the current memory usage pressure is not large; when the remaining memory in the system drops to low, the system believes that the current memory is insufficient and will trigger some signals or measures to recycle memory; when the remaining memory in the system is below min, it is considered that the memory pressure is very high.
[0053] When the memory needs to be released, the preset process list is traversed. The preset process list includes every process in the current system, or every process that may be killed in the current system, and at least one process is selected as a candidate killing process according to certain rules. The embodiment of the present disclosure is described by taking a candidate killing process as an example.
[0054] S102: Calculate the memory cleaning benefit obtained after killing the candidate killing process, where the memory cleaning benefit represents the impact of killing the candidate killing process on the system available memory.
[0055] For candidate processes to be killed, the memory they occupy includes the physical memory currently occupied and the memory occupied in ZRAM. The data in the memory can use compression algorithms to reduce the space occupied according to certain compression rules, thereby achieving the purpose of optimizing the system memory usage. ZRAM is a memory optimization technology. Its basic working principle is to define an area and put the compressed hard disk data into the area. When the data in the area needs to be accessed, a certain amount of CPU will be consumed to decompress the compressed memory. Specifically, the data in the memory is compressed according to a certain compression ratio and stored in the ZRAM space. The compression ratio is related to the compression algorithm used. At the same time, the killed process is usually restarted, and the process of restarting the process also requires a certain amount of memory.
[0056] The memory cleaning benefit obtained after killing the candidate killing process is calculated based on the actual memory occupied by the candidate killing process in the system (including the memory occupied in the normal storage space and the memory occupied in the ZRAM space) and the memory required when the candidate killing process is restarted. The memory cleaning benefit represents the impact of killing the candidate killing process on the memory water level in the system.
[0057] S103: If the memory cleaning benefit indicates that the available memory of the system increases after the candidate killing process is killed, the candidate killing process is determined as a target killing process.
[0058] As described above, the effect of killing the candidate process on the memory level in the system can be determined based on the memory cleaning benefit. If killing the candidate process can improve the memory status in the system, that is, increase the remaining memory space in the system, then the memory cleaning benefit of the candidate process is considered to meet the preset conditions, and the candidate process is the target process. Correspondingly, if killing the candidate process cannot improve the memory status in the system or worsens the memory status in the system, that is, cannot increase the remaining memory space in the system, then the memory cleaning benefit of the candidate process does not meet the preset conditions, and it is necessary to reselect the candidate process to calculate the memory cleaning benefit.
[0059] In some embodiments, a specific value of the preset condition can also be specified. For example, when the memory cleaning benefit of killing the candidate killing process is greater than a preset benefit threshold, the memory cleaning benefit is judged to meet the preset condition, etc. The embodiments of the present disclosure are not limited to this.
[0060] For example, a candidate process occupies 1GB of memory, of which 900MB is in ZRAM, with a compression ratio of 3:1. Therefore, the memory occupied by the 900M data after compression is about 300MB. The actual memory occupied by the candidate process in the system is about 100MB+300MB, and the memory space that can be released by killing the candidate process is 400MB. However, if the candidate process needs to occupy 200MB when restarting (i.e., the process initialization memory is 200MB), then after killing the candidate process, the remaining memory space in the system can be increased by at least 200MB. At this time, it is considered that the memory cleaning benefit meets the preset conditions.
[0061] For another example, a candidate process occupies 1GB of memory in total, of which 900MB is in ZRAM, with a compression ratio of 3:1. Therefore, the memory occupied by the 900M data after compression is about 300MB, and the actual memory occupied by the candidate process in the system is about 100MB+300MB. Therefore, the memory space that can be released by killing the candidate process is 400MB. However, if the candidate process needs to occupy 500MB when restarting (i.e., the process initialization memory is 500MB), then after killing the candidate process, the remaining memory space in the system may be reduced by 100MB. At this time, it is considered that the memory cleaning benefit does not meet the preset conditions.
[0062] S104: Kill the target process to release the memory occupied by the target process.
[0063] The disclosed embodiment selects a candidate process to be killed from a preset process list in response to the need to release memory; calculates the memory cleaning benefit obtained after killing the candidate process; if the memory cleaning benefit indicates that killing the candidate process can increase the system available memory, determines the candidate process to be killed as the target process to be killed; kills the target process to release the memory occupied by the target process, calculates the memory cleaning benefit of killing the process before killing the process, and performs the killing operation only after determining that the memory cleaning benefit indicates that killing the process can increase the system available memory, thereby ensuring the accuracy of process killing and further ensuring that the memory status of the operating system can be improved.
[0064] Figure 2 This is a flow chart of a memory cleaning method provided by another embodiment of the present disclosure. Figure 2 As shown, the method includes the following steps:
[0065] S201. In response to the need to release memory, a candidate process to be killed is selected from a preset process list.
[0066] Specifically, the implementation process and principle of S201 and S101 are the same, and will not be repeated here.
[0067] S202: Obtain the startup memory required for initializing the candidate process to be killed, the physical memory occupied by the candidate process to be killed, and the compressed memory occupied by the candidate process to be killed.
[0068] Among them, the startup memory is the memory required for initialization when the candidate killing process is initially started; the physical memory is the memory actually occupied by the candidate killing process in the normal storage space; the compressed memory, namely the ZRAM memory, is the memory occupied by part of the data of the candidate killing process in the ZRAM space after being compressed according to a certain compression algorithm (certain compression ratio).
[0069] Specifically, the ZRAM memory is the quotient of the memory space occupied by the data that the candidate killing process needs to store in the ZRAM space and the compression ratio.
[0070] S203: summing the physical memory occupied by the candidate process to be killed and the compressed memory occupied by the candidate process to be killed, to obtain the actual released memory after the candidate process is killed.
[0071] S204: Compare the actually released memory with the startup memory to obtain the memory cleanup benefit.
[0072] Specifically, if the actually released memory is greater than the startup memory, the memory cleaning benefit is determined to be a positive benefit; if the actually released memory is less than or equal to the startup memory, the memory cleaning benefit is determined to be a negative benefit.
[0073] That is, in the embodiment of the present disclosure, memory cleaning benefit = startup memory - (physical memory + ZRAM memory). When the memory cleaning benefit is a positive value, it is a positive benefit, otherwise the memory cleaning benefit is considered to be a negative benefit.
[0074] S205: If the memory cleaning benefit is a positive benefit, determining that the memory cleaning benefit represents an increase in system available memory after killing the candidate killing process.
[0075] When the memory cleaning benefit is positive, even if the candidate process is restarted after being killed, the memory required is still less than the memory actually released during the killing, and the available memory in the system is still effectively increased.
[0076] S206: Determine the candidate process to be killed as a target process to be killed.
[0077] S207: Kill the target process to release the memory occupied by the target process.
[0078] The disclosed embodiment calculates the memory cleanup benefit of killing a process before killing the process, and determines that even if the killed process is restarted, the effect of increasing the available memory in the system can be achieved, thereby ensuring the accuracy of process killing and further ensuring that the memory status of the operating system can be improved.
[0079] Figure 3 This is a flow chart of a memory cleaning method provided by another embodiment of the present disclosure. Figure 3 As shown, the method includes the following steps:
[0080] S301: In response to the need to release memory, traverse a preset process list to determine at least one process that is most likely to be killed.
[0081] The ADJ (adjuster) value represents the possibility of a process being killed. The higher the ADJ value, the less important the process is, and the higher the priority of being killed. Processes with an ADJ value less than 0 will not be killed. The at least one process with the highest ADJ value is the at least one process with the lowest importance in the preset process list.
[0082] S302: Select the process that occupies the largest physical memory from the at least one process that is most likely to be killed as the candidate process to be killed.
[0083] Specifically, there may be several processes with the same ADJ value in the preset process list, and they are equally important in the system. In order to effectively release the system memory as soon as possible, the process with the largest physical memory (Unique set size, USS) is selected from at least one process with the highest ADJ value as the candidate process to be killed. USS refers to the physical memory occupied by the process alone (excluding the memory occupied by shared libraries). If the process ends, the process will at least release the memory size of this value or above.
[0084] S303: Calculate the memory cleanup benefit obtained after killing the candidate killing process.
[0085] S304: If the memory cleaning benefit indicates that the available memory of the system increases after the candidate killing process is killed, the candidate killing process is determined as the target killing process.
[0086] S305: Kill the target process to release the memory occupied by the target process.
[0087] S306: Obtain the physical memory occupied by the target killing process.
[0088] S307: If the sum of the current available memory value and the physical memory occupied by the target process to be killed is greater than a preset memory threshold, the memory release request received during the process of killing the target process is ignored.
[0089] The action of killing the target process will last for a period of time. During this period of time, the actual available memory of the system may not have reached the ideal state. Therefore, there is still a need to release memory in the system, and a memory release request is generated. If the sum of the physical memory occupied by the target process being killed and the actual available memory of the system (the available memory value) is greater than the preset memory threshold, that is, when the target process is killed, the memory in the system can reach the ideal state. At this time, there is no need to kill other processes, and only need to wait for the target process to be killed. Therefore, the memory release request received during the killing of the target process is ignored.
[0090] The disclosed embodiment ignores the memory release request received during the process of killing the target process, under the premise that the memory in the system can reach an ideal state after the target process is killed, thereby avoiding the waste of computing resources caused by operations such as repeatedly traversing a preset process list, and avoiding the accidental killing of other processes due to the time-consuming process memory release problem, further improving the accuracy of process killing and the rationality of memory cleaning, while increasing the background process residence rate.
[0091] Figure 4 This is a flow chart of a memory cleaning method provided by another embodiment of the present disclosure. Figure 4 As shown, the method includes the following steps:
[0092] S401: Receive a memory release request.
[0093] S402: traverse the preset process list and determine candidate processes to be killed according to the ADJ value.
[0094] S403: Calculate the memory cleaning benefit obtained after killing the candidate killing process.
[0095] S404: Determine whether the memory cleanup benefit is positive. If so, execute S405; if not, execute S402.
[0096] S405: Determine the candidate process to be a target process to be killed, and kill the target process to be killed.
[0097] S406: Determine whether the available memory space in the current system meets the requirement. If yes, execute S407; if no, execute S402.
[0098] S407, end.
[0099] The disclosed embodiment calculates the memory cleaning benefit of killing the process before killing the process, and then performs the killing operation after determining that the memory cleaning benefit indicates that killing the process can increase the available memory in the system, thereby ensuring the accuracy of process killing and further ensuring that the memory state of the operating system can be improved.
[0100] Figure 5 The schematic diagram of the structure of the memory cleaning device provided in the embodiment of the present disclosure. The memory cleaning device may be the terminal device as described in the above embodiment, or the memory cleaning device may be a component or assembly in the terminal device. The memory cleaning device provided in the embodiment of the present disclosure may execute the processing flow provided in the memory cleaning method embodiment, such as Figure 5 As shown, the memory cleaning device 50 includes: a selection module 51, a calculation module 52, a determination module 53, and a killing module 54; the selection module 51 is used to select a candidate killing process from a preset process list in response to the need to release memory; the calculation module 52 is used to calculate the memory cleaning benefit obtained after killing the candidate killing process, and the memory cleaning benefit represents the impact of killing the candidate killing process on the system available memory; the determination module 53 is used to determine that the candidate killing process is a target killing process if the memory cleaning benefit represents an increase in the system available memory after killing the candidate killing process; the killing module 54 is used to kill the target killing process to release the memory occupied by the target process.
[0101] Optionally, the calculation module 52 includes an acquisition unit 521, a calculation unit 522, and a comparison unit 523; the acquisition unit 521 is used to obtain the startup memory required for initializing the candidate killing process, the physical memory occupied by the candidate killing process, and the compressed memory occupied by the candidate killing process; the calculation unit 522 is used to sum the physical memory occupied by the candidate killing process and the compressed memory occupied by the candidate killing process to obtain the actual released memory after killing the candidate killing process; the comparison unit 523 is used to compare the actually released memory with the startup memory to obtain the memory cleanup benefit.
[0102] Optionally, the comparison unit 523 is used to determine that the memory cleaning benefit is a positive benefit if the actually released memory is greater than the startup memory; and to determine that the memory cleaning benefit is a negative benefit if the actually released memory is less than or equal to the startup memory.
[0103] Optionally, the determination module 53 is further configured to determine, if the memory cleaning benefit is a positive benefit, that the memory cleaning benefit represents an increase in system available memory after killing the candidate killing process.
[0104] Optionally, the memory cleaning device 50 also includes an acquisition module 55 and an ignoring module 56; the acquisition module 55 is used to obtain the physical memory occupied by the target killing process; the ignoring module 56 is used to ignore the memory release request received during the killing of the target process if the sum of the current available memory value and the physical memory occupied by the target killing process is greater than a preset memory threshold.
[0105] Optionally, the selection module 51 includes a traversal unit 511 and a selection unit 512; the traversal unit 511 is used to traverse a preset process list to determine at least one process with the highest possibility of being killed; the selection unit 512 is used to select the process that occupies the largest physical memory from the at least one process with the highest possibility of being killed as the candidate process to be killed.
[0106] Figure 5 The memory cleaning device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0107] In addition, an embodiment of the present disclosure also provides a vehicle, which includes the memory cleaning device described in the above embodiment.
[0108] Figure 6 The electronic device provided by the embodiment of the present disclosure may be a terminal device as described in the above embodiment. The electronic device provided by the embodiment of the present disclosure may execute the processing flow provided by the memory cleaning method embodiment, such as Figure 6As shown, the electronic device 60 includes: a memory 61, a processor 62, a computer program and a communication interface 63; wherein the computer program is stored in the memory 61 and is configured so that the processor 62 executes the memory cleaning method as described above.
[0109] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the memory cleaning method described in the above embodiment.
[0110] In addition, an embodiment of the present disclosure also provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the memory cleaning method described above is implemented.
[0111] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0112] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0113] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0114] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0115] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0116] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0117] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A memory cleaning method, characterized in that: The method comprises: In response to the need to release memory, a candidate process to be killed is selected from a preset process list; Calculating the memory cleaning benefit obtained after killing the candidate killing process, wherein the memory cleaning benefit represents the impact of killing the candidate killing process on the system available memory; If the memory cleaning benefit indicates that the available memory of the system increases after killing the candidate killing process, determining the candidate killing process as the target killing process; The target process is killed to release the memory occupied by the target process.
2. The method according to claim 1, characterized in that The calculation of the memory cleaning benefit obtained after killing the candidate killing process includes: Obtaining the startup memory required for initializing the candidate killing process, the physical memory occupied by the candidate killing process, and the compressed memory occupied by the candidate killing process; The physical memory occupied by the candidate killing process and the compressed memory occupied by the candidate killing process are summed to obtain the actual released memory after killing the candidate killing process; The actually released memory is compared with the startup memory to obtain the memory cleanup benefit.
3. The method according to claim 2, characterized in that The comparing the actually released memory with the startup memory to obtain the memory cleaning benefit includes: If the actually released memory is greater than the startup memory, determining that the memory cleanup benefit is a positive benefit; If the actually released memory is less than or equal to the startup memory, it is determined that the memory cleanup benefit is a negative benefit.
4. The method according to claim 3, characterized in that If the memory cleaning benefit indicates that the available memory of the system increases after killing the candidate killing process, before determining that the candidate killing process is the target killing process, the method further includes: If the memory cleaning benefit is a positive benefit, then determining that the memory cleaning benefit represents that the system available memory increases after killing the candidate killing process.
5. The method according to claim 1, characterized in that The method further comprises: Obtain the physical memory occupied by the target killing process; If the sum of the current available memory value and the physical memory occupied by the target process to be killed is greater than the preset memory threshold, the memory release request received during the process of killing the target process is ignored.
6. The method according to claim 1, characterized in that The step of selecting a candidate process to be killed from a preset process list includes: Traverse the preset process list and determine at least one process with the highest probability of being killed; The process that occupies the largest physical memory is selected from the at least one process that has the highest possibility of being killed as the candidate process to be killed.
7. A memory cleaning device, characterized in that: The device comprises: A selection module, for selecting a candidate process to be killed from a preset process list in response to a need to release memory; A calculation module, used for calculating the memory cleaning benefit obtained after killing the candidate killing process, wherein the memory cleaning benefit represents the impact of killing the candidate killing process on the available memory of the system; A determination module, configured to determine the candidate killing process as a target killing process if the memory cleaning benefit indicates that the system available memory increases after the candidate killing process is killed; The killing module is used to kill the target killing process to release the memory occupied by the target process.
8. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A vehicle, characterized in that: include: The memory cleaning device as claimed in claim 7; or the electronic device as claimed in claim 8; Or, the computer readable storage medium of claim 9.