System memory release method, device and storage medium

By generating and sending a memory release signal in the system, the problem of being unable to actively release memory in the existing technology is solved, and the system's automatic memory release is realized when the memory is insufficient, thereby improving the user experience.

CN111209114BActive Publication Date: 2024-09-17SHENZHEN TCL NEW-TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911426052.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-31
Publication Date
2024-09-17
Estimated Expiration
2039-12-31

AI Technical Summary

Technical Problem

In the existing technology, the system memory cannot be actively released, which affects the user experience and cannot meet user needs.

Method used

By obtaining the system memory value, if it is less than the preset threshold, a memory release signal is generated and sent to the running process to actively release the memory, including using mechanisms such as signal identifiers, signal processing functions, and command instructions.

Benefits of technology

This enables the system to actively trigger processes to release memory when memory resources are insufficient, improving system performance and avoiding lagging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111209114B
    Figure CN111209114B
Patent Text Reader

Abstract

The present invention discloses a system memory release method. The method comprises: obtaining a system memory value, and if the system memory value is less than a preset threshold, generating a corresponding memory release signal; sending the memory release signal to a process running in the system, so that the process releases memory according to the memory release signal. The present invention also discloses a system memory release device and a computer-readable storage medium. The present invention can enable the system to actively trigger the running process to release memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of memory management technology, and in particular to a system memory release method, device and computer-readable storage medium. Background Art

[0002] At present, with the development of smart devices, the demand for memory by end users is increasing, the operating system is becoming more and more large, and applications also require more memory for storage and corresponding operations than before. Therefore, it is necessary to release system memory in time to meet the resource requirements of the foreground process.

[0003] However, in the prior art, the current memory release scheme can only be triggered by the process itself to release the memory actively. When the process is not actively triggered, the memory cannot be cleaned up, which affects the user experience and cannot meet user needs. Summary of the invention

[0004] The main purpose of the present invention is to provide a system memory release method, device and computer-readable storage medium, aiming to enable the system to actively trigger the running process to release memory.

[0005] To achieve the above object, the present invention provides a system memory release method, the system memory release method comprising the following steps:

[0006] Obtaining a system memory value, and if the system memory value is less than a preset threshold, generating a corresponding memory release signal;

[0007] The memory release signal is sent to a process running in the system, so that the process releases memory according to the memory release signal.

[0008] Optionally, before the step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal, the step includes:

[0009] Obtaining a signal identifier of the memory release signal;

[0010] The signal identifier is added to the signal identifier acquisition module of the signal capture running function in the system, so that the process running in the system can capture the memory release signal through the signal identifier acquisition module of the signal capture running function, and release the memory according to the memory release signal.

[0011] Optionally, the step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal includes:

[0012] The memory release signal is sent to a process running in the system, so that the process calls a signal processing function according to the memory release signal and performs memory release according to the signal processing function.

[0013] Optionally, the step of sending the memory release signal to a process running in the system so that the process calls a signal processing function according to the memory release signal, and performing memory release according to the signal processing function includes:

[0014] The memory release signal is sent to a process running in the system, so that the process calls a signal processing function according to the memory release signal, and controls the signal processing function to traverse the foreground process in the system to release memory.

[0015] Optionally, the step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal further includes:

[0016] Generate a corresponding command instruction according to the memory release signal;

[0017] The command instruction is sent to a process running in the system, so that the process releases memory according to the command instruction.

[0018] Optionally, the step of generating a corresponding memory release signal includes:

[0019] Get the preset memory release script data;

[0020] A corresponding memory release signal is generated through the preset memory release script data.

[0021] Optionally, before the step of generating a corresponding memory release signal by using the preset memory release script data, the method further includes:

[0022] Get the data identifier of system setting startup items and script data;

[0023] The data identifier of the script data is added into the setting startup item, so that the script data can be executed and generate a corresponding memory release signal.

[0024] Optionally, the step of obtaining the system memory value includes:

[0025] Get system memory value at preset intervals.

[0026] In addition, to achieve the above-mentioned purpose, the present invention also provides a system memory release device, which includes: a memory, a processor, and a system memory release program stored in the memory and executable on the processor, and the system memory release program, when executed by the processor, implements the steps of the system memory release method described above.

[0027] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a system memory release program is stored, and when the system memory release program is executed by a processor, the steps of the above-mentioned system memory release method are implemented.

[0028] The present invention obtains the system memory value, and if the system memory value is less than a preset threshold, generates a corresponding memory release signal; the memory release signal is sent to the process running in the system, so that the process releases memory according to the memory release signal. In the above manner, when the system memory resources are insufficient, the present invention can enable the Android system to actively send a signal to the process, so that the running process further releases excess memory according to the signal, and can enable the system to actively trigger the running process to release memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 It is a schematic diagram of the hardware structure of a system memory release device involved in an embodiment of the present invention;

[0030] Figure 2 FIG. 4 is a flow chart of a first embodiment of a method for releasing system memory according to the present invention. DETAILED DESCRIPTION

[0031] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0032] like Figure 1 As shown, Figure 1 It is a hardware structure diagram of a system memory release device involved in an embodiment of the present invention.

[0033] The device in the embodiment of the present invention may be a PC, or may be a terminal device with data processing function such as a smart phone, a tablet computer, or a portable computer.

[0034] like Figure 1As shown, the device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0035] Optionally, the device may further include a camera, a RF (Radio Frequency) circuit, a sensor, an audio circuit, a Wi-Fi module, etc. Among them, the sensor may be a light sensor, a motion sensor, or other sensors.

[0036] Those skilled in the art will understand that Figure 1 The structure of the system memory release device shown in the figure does not constitute a limitation on the system memory release device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0037] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a system memory release program.

[0038] exist Figure 1 In the system memory release device shown, the network interface 1004 is mainly used to connect to the background server and perform data communication with the background server; the user interface 1003 is mainly used to connect to the client (user end) and perform data communication with the client; and the processor 1001 can be used to call the system memory release program stored in the memory 1005 and perform the following operations:

[0039] Obtaining a system memory value, and if the system memory value is less than a preset threshold, generating a corresponding memory release signal;

[0040] The memory release signal is sent to a process running in the system, so that the process releases memory according to the memory release signal.

[0041] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0042] Before the step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal, the method includes:

[0043] Obtaining a signal identifier of the memory release signal;

[0044] The signal identifier is added to the signal identifier acquisition module of the signal capture running function in the system, so that the process running in the system can capture the memory release signal through the signal identifier acquisition module of the signal capture running function, and release the memory according to the memory release signal.

[0045] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0046] The step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal comprises:

[0047] The memory release signal is sent to a process running in the system, so that the process calls a signal processing function according to the memory release signal and performs memory release according to the signal processing function.

[0048] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0049] The step of sending the memory release signal to a process running in the system so that the process calls a signal processing function according to the memory release signal, and performing memory release according to the signal processing function comprises:

[0050] The memory release signal is sent to a process running in the system, so that the process calls a signal processing function according to the memory release signal, and controls the signal processing function to traverse the foreground process in the system to release memory.

[0051] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0052] The step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal further includes:

[0053] Generate a corresponding command instruction according to the memory release signal;

[0054] The command instruction is sent to a process running in the system, so that the process releases memory according to the command instruction.

[0055] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0056] The step of generating a corresponding memory release signal comprises:

[0057] Get the preset memory release script data;

[0058] A corresponding memory release signal is generated through the preset memory release script data.

[0059] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0060] Before the step of generating a corresponding memory release signal by using the preset memory release script data, the method further includes:

[0061] Get the data identifier of system setting startup items and script data;

[0062] The data identifier of the script data is added into the setting startup item, so that the script data can be executed and generate a corresponding memory release signal.

[0063] Further, the processor 1001 may call the system memory release program stored in the memory 1005, and further perform the following operations:

[0064] The step of obtaining the system memory value comprises:

[0065] Get system memory value at preset intervals.

[0066] The specific embodiments of the system memory release device of the present invention are basically the same as the embodiments of the system memory release method described below, and will not be described in detail herein.

[0067] Please refer to Figure 2 , Figure 2 The flowchart of the first embodiment of the system memory release method of the present invention is shown in FIG. 1 . In this embodiment, the method includes:

[0068] Step S10, obtaining a system memory value, and if the system memory value is less than a preset threshold, generating a corresponding memory release signal;

[0069] Step S20: sending the memory release signal to a process running in the system, so that the process releases memory according to the memory release signal.

[0070] In this embodiment, the system memory release method can be applied to the Android system or other systems. The Android system of the smart device will occupy memory when running the process, but it cannot release the occupied memory in time after exiting. The longer the smart device runs, the more memory is occupied, which causes the system to freeze. In order not to affect the normal operation speed of the system, it is necessary to clean up the current system memory, that is, release the system memory. When the system memory occupancy is small, it usually does not cause system freeze. Only when the memory occupancy reaches a certain value, the system freeze phenomenon will occur. Therefore, a preset threshold can be set in advance and the current system memory value can be compared with the preset threshold. Among them, the system memory value is the current available memory size of the system. When the system memory value is greater than the preset threshold, it means that there is still a lot of space in the system memory at this time, and the system freeze phenomenon will not occur, and there is no need to clean up the memory; when the system memory value is less than the preset threshold, it means that the system is running more applications at this time, occupying most of the system memory, and the system memory needs to be released as soon as possible. At this time, a corresponding memory release signal is generated to trigger the system to release the currently occupied memory. Specifically, script data can be written in advance, and the script data is used to release the memory currently occupied by the system. The script includes a signal identifier corresponding to the memory release signal, and a corresponding instruction is set for the memory release signal, that is, memory release. By running the script data, the signal identifier and instruction corresponding to the memory release signal are sent to the process running in the system. The process searches for the memory release signal corresponding to the release signal identifier according to the signal identifier, and executes the instruction after finding the corresponding memory release signal, that is, releasing the memory. Specifically, write a memory release signal in the script data and add a corresponding instruction, that is, memory release, such as a SIGUSR2 signal. First, the process running in the system receives the SIGUSR2 signal identifier and captures the SIGUSR2 signal, that is, searches for the SIGUSR2 signal in the process running in the system, and non-SIGUSR2 signals in the system process can be ignored. After finding the SIGUSR2 signal, memory release is performed.

[0071] In this embodiment, when the system memory resources are insufficient, a memory release signal is automatically generated, and the memory release signal is sent to the process, so that the running process further releases excess memory according to the signal. Through the above method, the present invention can enable the Android system to actively send a signal to the process when the system memory resources are insufficient, so that the running process further releases excess memory according to the signal, and can enable the system to actively trigger the running process to release memory.

[0072] Furthermore, based on the first embodiment of the system memory release method of the present invention, a second embodiment of the system memory release method of the present invention is proposed. In this embodiment, before step S20, the following steps are further included:

[0073] Step S30, obtaining a signal identifier of the memory release signal;

[0074] In this embodiment, the signal identifier of the memory release signal is first obtained. The signal identifier can be customized by the system according to the situation. The signal that needs to be released can be set according to the signal that the process currently running in the system occupies a lot and is useless. Or when the system memory resources are insufficient, in order to create a new process or run a more important process, the old process needs to be removed to reclaim memory. The system may decide to close a process at a certain moment. When deciding which process to terminate, the system will weigh their relative importance to the user, so as to further determine the signal identifier that needs to be released.

[0075] Step S40, adding the signal identifier into the signal identifier acquisition module of the signal capture running function in the system, so that the process running in the system can capture the memory release signal through the signal identifier acquisition module of the signal capture running function, and release the memory according to the memory release signal.

[0076] In this embodiment, when running script data to send a signal identifier to a process running in the system, the signal identifier of the memory release signal must first be obtained, and the signal identifier must be added to the signal identifier acquisition module of the signal capture running function in the system. The signal capture running function will compare the signal identifier of the memory release signal. If it is inconsistent with the added signal identifier, the memory release will be ignored; if it is consistent with the added signal identifier, the memory release signal corresponding to the signal identifier will be captured, and the memory release signal will be further released to automatically release the currently occupied memory.

[0077] Further, based on the first embodiment of the system memory release method of the present invention, a third embodiment of the system memory release method of the present invention is proposed. In this embodiment, step S20 includes:

[0078] Step S21: sending the memory release signal to a process running in the system, so that the process calls a signal processing function according to the memory release signal and performs memory release according to the signal processing function.

[0079] In this embodiment, the memory release signal is sent to the process running in the system by executing the script data. The process calls the signal processing function after receiving the memory release signal, and releases the memory according to the signal calling function. A memory release signal such as SIGUSR2 is pre-set, and the processing function corresponding to the release signal is the HandleSigUsr2 function. For example, the process of the Android system is capturing the SIGUSR2 signal. After capturing the SIGUSR2 signal, the HandleSigUsr2 function is called. The HandleSigUsr2 function triggers memory recovery, thereby releasing the memory.

[0080] Further, step S21 includes:

[0081] Step S211, sending the memory release signal to a process running in the system, so that the process calls a signal processing function according to the memory release signal, and controls the signal processing function to traverse the foreground process in the system to release memory.

[0082] In this embodiment, the memory release signal is sent to the process running in the system by executing the script data. The process calls the signal processing function after receiving the memory release signal, and releases the memory according to the signal calling function. Specifically, the signal processing function is called by the memory release signal, and the signal processing function is controlled to traverse the foreground process in the system to release the memory. The signal to be released can be set according to the signal that the process currently running in the system occupies more and is useless. Or when the system memory resources are insufficient, in order to create a new process or run a more important process, the old process needs to be removed to recycle the memory. The system may decide to close a process at a certain moment. When deciding which process to terminate, the system will weigh their relative importance to the user. For example, the current interface is the WeChat interface, indicating that the user is using WeChat, and the background running process includes WeChat. The signal processing function will traverse all the foreground processes according to the received memory release signal, and will release the memory of other useless processes running except WeChat, thereby reclaiming the memory, and releasing the memory will not affect the user's use.

[0083] Furthermore, based on the first embodiment of the system memory release method of the present invention, a fourth embodiment of the system memory release method of the present invention is proposed. In this embodiment, step S20 further includes:

[0084] Step S220, generating a corresponding command instruction according to the memory release signal;

[0085] Step S230: Send the command instruction to a process running in the system, so that the process releases memory according to the command instruction.

[0086] In this embodiment, the instruction corresponding to the memory release signal is set in the script data, and the signal identifier and the corresponding instruction corresponding to the memory release signal are sent to the process running in the system. After receiving the signal identifier, the process searches for the corresponding release signal, and executes the corresponding instruction when the corresponding release signal is found, that is, the memory release instruction, thereby automatically releasing the currently occupied memory. Specifically, the instruction is set to kill-12pid in the script file, where -12 refers to sending 12 as the signal identifier, which can represent SIGUSR2, and Pid is the id number corresponding to the specific process. By kill-12pid, the process can trigger the signal processing function, thereby releasing the currently occupied memory.

[0087] Further, based on the first embodiment of the system memory release method of the present invention, a fifth embodiment of the system memory release method of the present invention is proposed. In this embodiment, the step of generating a corresponding memory release signal in step S10 includes:

[0088] Step S11, obtaining preset memory release script data;

[0089] Step S12: generating a corresponding memory release signal through the preset memory release script data.

[0090] In this embodiment, preset memory release script data is obtained. The script is actually a series of text commands. When the script program is executed, an interpreter of the system translates it into machine-recognizable instructions. The memory release script data is called to run the script data, and a memory release signal can be sent. The syntax and structure of the script are simple and do not need to be compiled.

[0091] Furthermore, before step S12, the method further includes:

[0092] Step S130, obtaining data identifiers of system setting startup items and script data;

[0093] Step S140, adding the data identifier of the script data into the setting startup item, so that the script data can be executed and generate a corresponding memory release signal.

[0094] In this embodiment, the data identifiers of the system setting startup item and the script data are obtained. The system setting startup item is a list of application startup items in the system setting. Only the applications in the application startup item list can be run and started. The data identifier of the script data can be customized by the system according to the situation, such as being set to Arabic numerals. After obtaining the data identifiers of the system setting startup item and the script data, the data identifier of the script data is added to the setting startup item so that the script data can be run and generate a corresponding memory release signal.

[0095] In this embodiment, the system program is set so that the system allows the script data to start. Specifically, in order to start the script for the Android framework, init.rc can be modified to set a startup attribute for the script.

[0096] Furthermore, based on the first embodiment of the system memory release method of the present invention, a sixth embodiment of the system memory release method of the present invention is proposed. In this embodiment, the step of obtaining the system memory value in step S10 includes:

[0097] Step S150, obtaining the system memory value at preset time intervals.

[0098] In this embodiment, the system memory value is obtained at preset intervals, that is, the system memory is polled, and when the system memory is low, a memory release signal is generated, and the memory release signal is used to control the process to actively trigger the memory recycling mechanism, thereby releasing the memory. Specifically, the polling logic can be added to the system_server process.

[0099] In addition, an embodiment of the present invention further provides a computer-readable storage medium.

[0100] The computer-readable storage medium of the present invention stores a system memory release program, and when the system memory release program is executed by a processor, the steps of the system memory release method described above are implemented.

[0101] Among them, the method implemented when the system memory release program running on the processor is executed can refer to the various embodiments of the system memory release method of the present invention, and will not be repeated here.

[0102] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system 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 system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0103] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0105] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A system memory release method, characterized in that: The system memory release method comprises the following steps: Obtaining a system memory value, and if the system memory value is less than a preset threshold, obtaining preset memory release script data, wherein the script data is a series of text commands; The corresponding memory release signal is generated by the preset memory release script data, and before the step of generating the corresponding memory release signal by the preset memory release script data, the method further includes: Get the data identifier of system setting startup items and script data; Adding the data identifier of the script data into the setting startup item, so that the script data can be run and generate a corresponding memory release signal, wherein the setting startup item is a list of application startup items in the system setting; Sending the memory release signal to a process running in the system, so that the process releases memory according to the memory release signal; Wherein, before the step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal, the step includes: Acquire the signal identifier of the memory release signal, wherein the signal identifier is a signal identifier of a signal that needs to be released according to a signal that is occupied by a large number of processes currently running in the system and is useless; The signal identifier is added into the signal identifier acquisition module of the signal capture running function in the system, so that the process running in the system can capture the memory release signal through the signal identifier acquisition module of the signal capture running function, and release the memory according to the memory release signal, wherein the step of being able to capture the memory release signal through the signal identifier acquisition module of the signal capture running function comprises: the signal capture running function compares the signal identifier of the memory release signal, and if it is consistent with the added signal identifier, then captures the memory release signal corresponding to the signal identifier; The step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal includes: The memory release signal is sent to a process running in the system, so that the process calls a signal processing function according to the memory release signal and performs memory release according to the signal processing function.

2. The system memory release method according to claim 1, characterized in that: The step of sending the memory release signal to a process running in the system so that the process calls a signal processing function according to the memory release signal, and performing memory release according to the signal processing function comprises: The memory release signal is sent to a process running in the system, so that the process calls a signal processing function according to the memory release signal, and controls the signal processing function to traverse the foreground process in the system to release memory.

3. The system memory release method according to claim 1, characterized in that: The step of sending the memory release signal to a process running in the system so that the process releases memory according to the memory release signal further includes: Generate a corresponding command instruction according to the memory release signal; The command instruction is sent to a process running in the system, so that the process releases memory according to the command instruction.

4. The system memory release method according to claim 1, characterized in that: The step of obtaining the system memory value comprises: Get system memory value at preset intervals.

5. A system memory release device, characterized in that: The system memory release device includes: a memory, a processor, and a system memory release program stored in the memory and executable on the processor. When the system memory release program is executed by the processor, the steps of the system memory release method according to any one of claims 1 to 4 are implemented.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a system memory release program, and when the system memory release program is executed by the processor, the steps of the system memory release method according to any one of claims 1 to 4 are implemented.