Memory leak processing method, device and equipment and readable storage medium
Through segmented memory capacity analysis and backup process replacement mechanism, the memory leak problem is solved, the accuracy of risk prediction and system stability are improved, and the invisible switching and business continuity are achieved.
Patent Information
- Application Number
- CN202411182286.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-11-29
AI Technical Summary
The existing technology cannot detect and resolve memory leaks in a timely manner, resulting in system resource exhaustion and program crash.
By obtaining memory capacity changes based on segmentation, predicting leakage risk values, and enabling alternate processes to replace the original process when the risk threshold exceeds, freeing up memory, monitoring and adjustments in real time to avoid memory leakage.
Improve the accuracy of memory leak risk prediction, timely adjust memory space, ensure stable system operation, avoid abnormal restarts and business interruptions, and realize invisible switching.
Smart Images

Figure CN119046004A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security, and in particular to a memory leak processing method, device, equipment and readable storage medium. Background Art
[0002] When a program dynamically allocates memory and fails to release it correctly for various reasons, a memory leak will occur. This unreleased memory cannot be reused by the system. Over time, accumulated memory leaks will gradually exhaust system resources and may eventually cause the program or system to crash.
[0003] Therefore, how to detect and solve memory leaks in a timely manner is a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a memory leak processing method, device, equipment and readable storage medium, which solves the problem that the prior art cannot promptly discover and solve memory leaks.
[0005] In order to solve the above technical problems, the present invention provides a memory leak processing method, comprising:
[0006] Based on the segmented acquired memory capacity, the memory capacity change of the process is obtained, and the current leakage risk value is predicted according to the memory capacity change;
[0007] If the leakage risk value is greater than or equal to the risk threshold, the process has a memory leakage risk, a backup process is enabled to replace the process, and the memory of the process is released;
[0008] If the leakage risk value is less than the risk threshold, then there is no memory leakage risk for the process.
[0009] On the one hand, the memory capacity change of the process is obtained based on the segmented memory capacity, and the current leakage risk value is predicted based on the memory capacity change, including:
[0010] Acquire the memory capacity of the process based on a preset time period to obtain the memory capacity status of multiple time nodes;
[0011] The memory capacity of the multiple time nodes is analyzed to predict the leakage risk value.
[0012] On the one hand, the memory capacity of the multiple time nodes is analyzed to predict the leakage risk value, including:
[0013] Calculate the memory capacity difference and memory capacity ratio before and after each time period according to the memory capacity of the multiple time nodes; the memory capacity ratio is the memory capacity ratio of the last time period;
[0014] The leakage risk value is obtained by predicting the memory capacity difference before and after each time period and the memory capacity ratio.
[0015] On the one hand, after calculating the memory capacity difference and the memory capacity ratio before and after each time period according to the memory capacity of the multiple time nodes, it also includes:
[0016] If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the first trend, and the memory capacity ratio reaches the first preset ratio threshold, then the risk level of the process is level one risk;
[0017] If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the second trend, and the memory capacity ratio reaches the second preset ratio threshold, then the risk level of the process is level 2 risk;
[0018] If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the third trend, and the memory capacity ratio reaches the third preset ratio threshold, then the risk level of the process is level three risk;
[0019] The first trend is greater than the second trend, and the second trend is greater than the third trend; the first preset proportion threshold is greater than the second preset proportion threshold, and the second preset proportion threshold is greater than the third preset proportion threshold;
[0020] A corresponding leakage warning is generated according to the risk level and notified to the operation and maintenance personnel, so that the operation and maintenance personnel can perform corresponding actions based on different leakage levels and manually intervene in the memory situation of the process.
[0021] On the one hand, enabling a standby process and releasing the memory of the process includes:
[0022] Starting the standby process and transferring the key business data thread of the process to the standby process;
[0023] When the key business data thread in the standby process is started, a receipt is triggered;
[0024] When the process obtains the receipt information, it triggers a restart to release the memory space of the process.
[0025] On the one hand, after enabling the standby process and releasing the memory of the process, the method further includes:
[0026] Monitor the memory capacity of the standby process in real time, and if it is predicted that the standby process has a memory leak risk, determine whether the process memory release is complete;
[0027] If completed, the process is enabled to replace the standby process, and the memory of the standby process is released;
[0028] If not completed, a secondary standby process is started to replace the standby process and the memory of the standby process is released.
[0029] On the one hand, before enabling the standby process to replace the process and releasing the memory of the process, the method further includes:
[0030] Obtain a process whitelist in advance, wherein the process whitelist includes all valid processes under the same service and process priorities;
[0031] The backup process is determined based on the process whitelist.
[0032] The present invention also provides a memory leak processing device, comprising:
[0033] A leakage risk prediction module is used to obtain the memory capacity change of the process based on the memory capacity obtained in a segmented manner, and predict the current leakage risk value according to the memory capacity change;
[0034] A memory leak processing module, configured to, if the leakage risk value is greater than or equal to a risk threshold, determine that the process has a memory leak risk, enable a standby process to replace the process, and release the memory of the process;
[0035] The normal module is used to determine that if the leakage risk value is less than the risk threshold, then the process does not have a memory leakage risk.
[0036] The present invention also provides a memory leak processing device, comprising:
[0037] Memory for storing computer programs;
[0038] The processor is used to implement the steps of the above-mentioned memory leak processing method when executing the computer program.
[0039] The present invention also provides a readable storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the above-mentioned memory leak processing method are implemented.
[0040] The present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned memory leak processing method when executed by a processor.
[0041] It can be seen from the above technical scheme that the present invention obtains the change of the memory capacity of the process based on the memory capacity obtained in a segmented manner, and predicts the current leakage risk value according to the change of the memory capacity; if the leakage risk value is greater than or equal to the risk threshold, the process has a memory leakage risk, a backup process is enabled to replace the process, and the memory of the process is released; if the leakage risk value is less than the risk threshold, the process does not have a memory leakage risk. The beneficial effects of the present invention are: the present invention adopts a segmented memory capacity acquisition method, and analyzes and predicts whether the process has a leakage risk, thereby improving the accuracy of the leakage risk prediction; and when there is a leakage risk, the original process is adjusted in time and the memory space is released to ensure that the entire system always remains in operation, without abnormal restart, hanging, etc. causing the business to stop, and realizing a senseless switching during the business operation process.
[0042] In addition, the present invention also provides a memory leak processing device, equipment and storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] 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, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0044] Figure 1 A flowchart of a memory leak processing method provided by an embodiment of the present invention;
[0045] Figure 2 A flowchart of a memory leak processing method provided by an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of the structure of a memory leak processing device provided by an embodiment of the present invention;
[0047] Figure 4 A schematic diagram of the structure of a memory leak processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] With the development of the Internet, the demand for servers is getting higher and higher. As a key device, the server takes into account the requirements of data processing, calculation and storage, so the stability of the equipment is particularly important. BMC (Baseboard Manager Controller) is a common monitoring and management system in the server. It monitors and displays the operating status of the entire server, monitors the working status of each device in the server, makes corresponding preset processing for abnormal changes in the server, makes timely adjustments, reports changes in device status, and manages the operation of the entire server, thereby ensuring the normal operation of the server. Real-time monitoring is more convenient for server operation and maintenance. As a single-chip microcomputer, BMC has its own storage space and operating system. It uses case processing to monitor the operation of the server, issue processing actions and instructions, and other operations to ensure the normal operation of the server.
[0050] With the increase in the performance and number of various components of the server, the computing and processing capabilities of the BMC have also ushered in a huge challenge. After the BMC is started, it triggers the start of various functional processes and monitors the operation through the interface. During the process, a large number of memory addresses are occupied, and the memory is released again after stopping. Due to various factors and abnormal conditions, most servers will be in long-term operation after startup. Due to the long-term operation of the server, the BMC monitoring system will also be in continuous operation. The working program will continuously poll to obtain access and continuously apply for memory addresses. The occupied memory will be released after the program is completed or expired, and the memory space will be re-applied in a new round of access. In the process of continuous repetition of the program, if the memory occupied by the program expires or the current memory space is not released after completion, and the occupied address position cannot be re-applied, the memory space occupied by the program that has been used or expired cannot be released in time, and the memory space will continue to leak. If the leak is not handled in time, the BMC system will crash and the programs in the system will not be able to continue running, resulting in the inactivation of the BMC and the cessation of all BMC services. The server will be in a period of no monitoring and no control, affecting the operation of the entire server, and then affecting the entire server business, causing losses, and unable to ensure the stable operation of the server, affecting the business.
[0051] Therefore, timely handling of memory leaks is very necessary, and the current methods for handling memory leaks have limitations, which leads to the failure to timely discover and solve memory leaks. For example, the limitation of time handling: memory leaks can only be handled during non-peak hours, and the peak business hours are more likely to increase the speed of memory leaks for processes with memory leak risks, so emergency handling of memory leaks during peak hours is the top priority; such as the limitations of memory leak detection: judging whether there is a memory leak by adding and reducing programs, it is impossible to effectively deal with a variety of design program situations; such as the limitations of leak handling: the method of closing the process by judging the process PID method cannot effectively close the variable process, and a simple shutdown cannot deal with the situation of continuous program leaks.
[0052] In view of the above problems, the present invention proposes a memory leak processing method, including memory leak detection and memory leak specific processing. Figure 1 , Figure 1 A flowchart of a memory leak processing method provided by an embodiment of the present invention. The method may include:
[0053] S101: deriving a memory capacity change of a process based on the memory capacity obtained in a segmented manner, and predicting a current leakage risk value according to the memory capacity change.
[0054] The executor of this embodiment is BMC. The descriptions of the relevant processes in this embodiment are all BMC processes. It should be noted that this embodiment processes the memory leak of a single process, that is, predicts whether each process has a memory leak risk, and processes each process with a memory leak risk. This embodiment makes a prediction in advance and obtains the memory capacity in segments. For example, the memory capacity of the process in each time period can be obtained, thereby obtaining the change of the memory capacity of a single process, and further predicting the current leakage risk of the process based on the change of the memory capacity.
[0055] Furthermore, in order to improve the accuracy of leakage risk prediction, the above-mentioned process memory capacity change is obtained based on the segmented memory capacity, and the current leakage risk value is predicted according to the memory capacity change, which may include the following steps:
[0056] Step 21: Obtain the memory capacity of the process based on a preset time period to obtain the memory capacity of multiple time nodes;
[0057] Step 22: Analyze the memory capacity of multiple time nodes and predict the leakage risk value.
[0058] This embodiment does not limit the preset time period, and can be set according to actual conditions. For example, a single time period can be 5 minutes, and the memory capacity of the process is checked in each time period, and the memory capacity changes of multiple time nodes are combined to summarize the leakage risk of a single process, and the change size risk value is preset.
[0059] Furthermore, in order to further improve the accuracy of leakage risk prediction, the above analysis of the memory capacity of multiple time nodes and prediction of the current leakage risk value may include the following steps:
[0060] Step 221: Calculate the memory capacity difference before and after each time period and the memory capacity ratio according to the memory capacity of multiple time nodes; the memory capacity ratio is the memory capacity ratio of the last time period;
[0061] Step 222: The leakage risk value is predicted based on the memory capacity difference before and after each time period and the memory capacity ratio.
[0062] This embodiment uses the memory capacity of multiple time periods to calculate the memory capacity difference before and after each time period and the total memory capacity ratio, where the total memory capacity ratio refers to the ratio of the memory capacity of the last time period to the total memory capacity. In this way, the current leakage risk value corresponding to the process is predicted based on the memory capacity difference before and after each time period and the memory capacity ratio. Specifically, the trend change of the memory capacity can be obtained based on the memory capacity difference before and after each time period (referred to as the capacity difference), and then based on the comparison between the memory capacity ratio and the preset ratio threshold, the current risk level of the process and the corresponding leakage risk value can be finally determined.
[0063] Furthermore, in order to promptly notify the user to handle the leak, after calculating the memory capacity difference and the memory capacity ratio before and after each time period according to the memory capacity of multiple time nodes, the following steps may also be included:
[0064] If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend is consistent with the first trend, and the memory capacity ratio reaches the first preset ratio threshold, the risk level of the process is level one risk;
[0065] If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the second trend, and the memory capacity ratio reaches the second preset ratio threshold, the risk level of the process is level 2 risk;
[0066] If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the third trend, and the memory capacity ratio reaches the third preset ratio threshold, the risk level of the process is level three risk;
[0067] Generate corresponding leakage warnings according to the risk level and notify the operation and maintenance personnel so that they can perform corresponding actions based on different leakage levels and manually intervene in the memory situation of the process.
[0068] This embodiment divides the risk level into three levels. This embodiment does not limit the first preset proportion threshold, the second preset proportion threshold and the third preset proportion threshold, as long as the first preset proportion threshold> the second preset proportion threshold> the third preset proportion threshold; nor does it limit the first trend, the second trend and the third trend, as long as they meet the first trend> the second trend> the third trend. Specifically, level one (level one risk): the cycle difference has a positive increase of 100%, and the total memory capacity accounts for 90% of the preset value; level two (level two risk): the cycle difference has a positive increase of 90%, and the total memory capacity accounts for 80% of the preset value; level three (level three risk): the cycle difference has a positive increase of 80%, and the total memory capacity accounts for 70% of the preset value. According to the risk value size / risk level, the process alarm with leakage risk is triggered, and the leakage warning is generated in different levels. The server makes corresponding warnings in the healthy running state, which is convenient for the server operation and maintenance personnel to receive the alarm information, so as to make corresponding external inspection operations and make timely adjustments. For example, by default, automatic processing is only started when the risk level is level one; automatic processing is not started for level two and level three risks; at this time, when the risk level is level two or level three, the operation and maintenance personnel can also intervene or not intervene according to the actual situation, leaving room for control for the operation and maintenance personnel.
[0069] S102: Determine whether the leakage risk value is less than the risk threshold. If not, it indicates that the process has a memory leakage risk, and then execute step S103; if yes, it indicates that the process does not have a memory leakage risk, and then execute step S104.
[0070] In this embodiment, the leakage risk value of the current process is predicted according to step S101, and the leakage risk value is compared with a preset risk threshold to determine whether the current process has leakage risk. This embodiment does not limit the risk threshold, and it can be set according to actual conditions.
[0071] S103: The process has a memory leak risk. A backup process is enabled to replace the process and the memory of the process is released.
[0072] Specifically, when it is found that the process currently has a memory leak risk, a backup process is started to replace the work of the process, and the memory of the process is released. It should be noted that the backup process and the process belong to the same business and there is no substantial difference. That is to say, the present embodiment adopts a multi-process business form, that is, multiple processes simultaneously guarantee the operation of a business, alternate with each other, and do not interfere with each other, such as process A, process B, and process C. Usually, in order to ensure that the business is always running, that is, under normal operation, process A is started first to run the business. The process in this embodiment can be understood as the process with the highest priority in the process whitelist, that is, process A, and the backup process can be understood as process B and process C.
[0073] Furthermore, for the effectiveness and timeliness of memory leak processing, before enabling the standby process to replace the process and releasing the memory of the process, the following steps may be further included:
[0074] Step 31: pre-acquire a process whitelist, which includes all valid processes under the same service and their priorities;
[0075] Step 32: Determine a backup process based on the process whitelist.
[0076] The processes in the process whitelist in this embodiment belong to the same business and are valid, that is, the memory space can meet the current demand. In addition, the valid processes in the process whitelist are set with priorities. For example, among processes A, B and C, process A has a higher priority than process B, and process B has a higher priority than process C. The next standby process can be determined based on the process priority. There are no specific rules for setting the process priority in this embodiment, and it can be set according to actual needs.
[0077] Furthermore, in order to ensure the validity of the processes in the process whitelist and reduce the number of redundant processes, the following steps may also be included:
[0078] If the standby process does not have the risk of memory leakage and the process has completed memory release, the process is added to the process whitelist and the priority of the process is set to the highest level;
[0079] If the standby process has a memory leak risk, the standby process will be removed from the process whitelist. When the standby process completes memory release, it will be added back to the process whitelist.
[0080] The process whitelist in this embodiment will update the process whitelist in time with the memory release of each process, ensuring that there is at least one spare process that can be replaced in the process whitelist. In order to reduce the number of redundant processes, when the process with memory leak or the spare process with memory leak completes memory release, it will be added back to the process whitelist in time and its priority level will be restored.
[0081] Furthermore, in order to solve the memory leak in a timely and effective manner, the above-mentioned enabling of the standby process and releasing the memory of the process may specifically include the following steps:
[0082] Step 41: Start the standby process and transfer the key business data thread of the process to the standby process;
[0083] Step 42: When the key business data thread in the standby process is started, a receipt is triggered;
[0084] Step 43: When the process obtains the receipt information, it triggers a restart to release the memory space of the process.
[0085] The specific process of replacing a process with a standby process in this embodiment is as follows: the key business data thread of the process with a memory leak risk is transferred to the standby process. At this time, the key business data thread in the standby process is started. When the startup is successful, a receipt is triggered, and the process with a memory leak risk starts to restart, that is, the process with a memory leak risk starts to release memory. The key business data thread in this embodiment is the thread required to execute the business of the current process. The receipt can ensure that there is no interruption in the business during the thread replacement process.
[0086] Furthermore, in order to continuously ensure that the memory leak problem is effectively solved during the entire operation process, after the above-mentioned standby process is enabled and the memory of the process is released, the following steps may also be included:
[0087] Step 51: monitor the memory capacity of the standby process in real time. If it is predicted that the standby process has a memory leak risk, determine whether the process memory release is completed. If completed, execute step 52; if not completed, execute step 53;
[0088] Step 52: Activate the process to replace the standby process and release the memory of the standby process;
[0089] Step 53: Start the secondary standby process to replace the standby process and release the memory of the standby process.
[0090] This embodiment monitors the memory capacity of the standby process in real time. The specific process can refer to the memory leakage risk prediction process of the process. In this process, the memory release of the process will also be monitored. If it is predicted that the standby process will also have a memory leakage risk, the priority of the process is higher than other standby processes in the process whitelist. It is prioritized to determine whether the process memory release is completed. If it is completed, the work of the standby process will be handed over to the process again. If it is not completed, the work of the standby process will be handed over to the secondary standby process, and the standby process will start to release memory. In this way, it is ensured that there is no memory leakage problem during the entire operation of the server.
[0091] S104: There is no risk of memory leakage in the process, so the status quo is maintained.
[0092] If the process does not have a memory leak risk, there is no need to perform any other actions. Just maintain the status quo and continue to predict the memory risk of the process so that it can be discovered and handled in a timely manner.
[0093] The memory leak processing method provided in the embodiment of the present invention is applied to obtain the memory capacity change of the process based on the memory capacity obtained in a segmented manner, and predict the current leakage risk value based on the memory capacity change; if the leakage risk value is greater than or equal to the risk threshold, the process is at risk of memory leakage, a backup process is enabled to replace the process, and the memory of the process is released; if the leakage risk value is less than the risk threshold, the process is not at risk of memory leakage. The beneficial effects of the method are as follows: the method adopts a segmented memory capacity acquisition method, and performs analysis and prediction to determine whether the process has a leakage risk, thereby improving the accuracy of leakage risk prediction and being able to timely discover memory leakage risks; and when there is a leakage risk, the original process is adjusted in time and memory space is released to ensure that the entire system always remains in a running state, and a senseless switching during business operation is also achieved; and, the BMC obtains the memory capacity through self-checking, and can itself perform emergency processing for the memory leakage risk; and, in the case of rapid and continuous memory leakage, multiple processes are urgently started after the memory capacity reaches the limit value, and the priorities of multiple processes of the same business are divided. By judging the process release situation, other processes of the same business are started according to the priority, the original process is adjusted, and memory space is released, so as to avoid insufficient memory capacity causing the system to hang up, the BMC system to be inactivated, affecting the entire monitoring and management operation, and being unable to operate the server in time, causing server failure, and affecting business operation; and, corresponding warning operations are made in time according to the risk level, so that operation and maintenance personnel can find the risk of continuous memory leakage and make corresponding adjustment operations in time.
[0094] In order to make the present invention easier to understand, please refer to Figure 2 , Figure 2 A flowchart of a memory leak processing method provided by an embodiment of the present invention may specifically include:
[0095] The continuous memory leakage is handled in a multi-process form, that is, multiple processes simultaneously ensure the operation of a business, which are divided into A, B, and C processes. Multiple processes alternate without interfering with each other. A has the highest priority, and the priority decreases in sequence. Usually, in order to ensure that the business is always running, that is, under normal operation, the A process is started first to run the business. By passing the BMC valid process whitelist, the memory capacity of the memory leakage risk of the A process is monitored in real time, and the leakage risk value of the A process is predicted. When the high-level risk threshold is reached, the B process is started, and the business A process passes the key business data thread to the B process, such as the current duty (duty cycle) value information of the fan. After the key business data thread in the B process is started, a receipt is triggered. After the A process obtains the receipt information, it triggers a restart to ensure successful business delivery and the successful inheritance of the monitoring management policy of the original process to the B process. After the B process is started, the business will not be affected, ensuring the normal operation of the business while keeping the business unchanged. When the B process is in continuous operation, the prediction of the leakage risk of a single process continues. When it is predicted that the B process has a leakage risk, it triggers the determination of whether the memory release of the A process is complete. After the release is completed, the key business data thread is preferentially transmitted to the A process of the same business. When it is determined that the A process has not been released, the C process of the same business is started to receive the key data thread of the B process. If there is a leakage risk in the C process, it is preferentially determined whether the memory of the A process is released. Whether the memory of the B process is released is determined in order of priority, thereby leaving blank time for the original process that cannot be released to restart, and so on. In order to make emergency processing in the scenario of continuous leakage, the whitelist is supplemented effectively to ensure that there is always enough space in the memory space to handle the operation of the program, deal with the continuous leakage of memory in time, ensure the continuous operation of BMC business, warn of abnormal memory space for subsequent processing, and the monitoring management system BMC always keeps running without human intervention, without abnormal restart, hanging and other business suspension; and for servers with large business volume and continuous operation, when memory leaks are found during long-term operation, they can be handled in time to ensure the normal operation of the server.
[0096] The memory leak processing device provided by an embodiment of the present invention is introduced below. The memory leak processing device described below and the memory leak processing method described above can be referred to each other.
[0097] Please refer to Figure 3 , Figure 3 A schematic diagram of a memory leak processing device provided by an embodiment of the present invention may include:
[0098] The leakage risk prediction module 100 is used to obtain the memory capacity change of the process based on the memory capacity obtained in a segmented manner, and predict the current leakage risk value according to the memory capacity change;
[0099] A memory leak processing module 200 is used to, if the leakage risk value is greater than or equal to a risk threshold, determine that the process has a memory leak risk, enable a standby process to replace the process, and release the memory of the process;
[0100] The normal module 300 is used to determine that if the leakage risk value is less than the risk threshold, then the process does not have a memory leakage risk.
[0101] Based on the above embodiment, the leakage risk prediction module 100 may include:
[0102] A memory capacity acquisition unit, used to acquire the memory capacity of the process based on a preset time period, and obtain the memory capacity status of multiple time nodes;
[0103] The leakage risk prediction unit is used to analyze the memory capacity of the multiple time nodes and predict the leakage risk value.
[0104] Based on the above embodiment, the leakage risk prediction unit may include:
[0105] A calculation subunit, configured to calculate the memory capacity difference before and after each time period and the memory capacity ratio according to the memory capacity of the multiple time nodes; the memory capacity ratio is the memory capacity ratio of the last time period;
[0106] The prediction subunit is used to predict the leakage risk value according to the memory capacity difference before and after each time period and the memory capacity ratio.
[0107] Based on the above embodiment, the memory leak processing device may further include:
[0108] A first-level risk module, for determining that if the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the first trend, and the memory capacity ratio reaches a first preset ratio threshold, then the risk level of the process is a first-level risk;
[0109] A secondary risk module, for determining that the risk level of the process is a secondary risk if the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to a second trend, and the memory capacity ratio reaches a second preset ratio threshold;
[0110] A third-level risk module, for if the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to a third trend, and the memory capacity ratio reaches a third preset ratio threshold, then the risk level of the process is a third-level risk; wherein the first trend is greater than the second trend, and the second trend is greater than the third trend; the first preset ratio threshold is greater than the second preset ratio threshold, and the second preset ratio threshold is greater than the third preset ratio threshold;
[0111] The human intervention module is used to generate corresponding leakage warnings according to the risk level and notify the operation and maintenance personnel so that the operation and maintenance personnel can perform corresponding actions based on different leakage levels and perform human intervention on the memory status of the process.
[0112] Based on the above embodiment, the memory leak processing module 200 may include:
[0113] A standby process starting unit, used to start the standby process and transfer the key business data thread of the process to the standby process;
[0114] A receipt unit, used to trigger a receipt when the key business data thread in the standby process is started;
[0115] The memory release unit is used to trigger restart after the process obtains the receipt information, thereby releasing the memory space of the process.
[0116] Based on any of the above embodiments, the memory leak processing device may further include:
[0117] A real-time monitoring module is used to monitor the memory capacity of the standby process in real time after the standby process is enabled and the memory of the process is released. If it is predicted that the standby process has a memory leak risk, it is determined whether the memory release of the process is completed;
[0118] A first result module, configured to enable the process to replace the standby process if the process is completed, and release the memory of the standby process;
[0119] The second result module is used to start a secondary standby process to replace the standby process if it is not completed, and release the memory of the standby process.
[0120] Based on the above embodiment, the memory leak processing device may further include:
[0121] A whitelist acquisition module, used to pre-acquire a process whitelist before enabling a standby process to replace the process and releasing the memory of the process, wherein the process whitelist includes all valid processes under the same service and process priorities;
[0122] The standby process determination module is used to determine the standby process based on the process whitelist.
[0123] It should be noted that the order of the modules and units in the above-mentioned memory leak processing device can be changed without affecting the logic.
[0124] The memory leak processing device provided by the embodiment of the present invention comprises a leakage risk prediction module 100, which is used to obtain the memory capacity change of the process based on the memory capacity obtained in a segmented manner, and predict the current leakage risk value according to the memory capacity change; a memory leak processing module 200, which is used to determine that if the leakage risk value is greater than or equal to a risk threshold, the process has a memory leak risk, enable a backup process to replace the process, and release the memory of the process; and a normal module 300, which is used to determine that if the leakage risk value is less than the risk threshold, the process has no memory leak risk. The beneficial effects of the device are as follows: the device adopts a segmented memory capacity acquisition method, and performs analysis and prediction to determine whether the process has a leakage risk, thereby improving the accuracy of leakage risk prediction and being able to timely discover memory leakage risks; and when there is a leakage risk, the original process is adjusted in time and memory space is released to ensure that the entire system always remains in a running state, and a senseless switching during business operation is also achieved; and, the BMC obtains memory information by self-checking, and can itself perform emergency processing for memory leakage risks; and, in the case of rapid memory leakage, multiple processes are urgently started after the memory capacity reaches the limit value, and the priorities of multiple processes of the same business are divided. By judging the process release situation, other processes of the same business are started according to the priority, the original process is adjusted, and memory space is released to avoid insufficient memory capacity causing the system to hang up, the BMC system to be inactivated, affecting the entire monitoring and management operation, and being unable to operate the server in time, causing server failures, and affecting business operations; and, corresponding warning operations are made in time according to the risk level, so that operation and maintenance personnel can find the risk of continuous memory leakage and make corresponding adjustment operations in time; and for servers with large business volume and continuous operation, when memory leakage is found during long-term operation, it can also be processed in time to ensure the normal operation of the server.
[0125] Figure 4 A schematic diagram of a memory leak processing device provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the memory leak processing device includes:
[0126] A memory 60, for storing computer programs;
[0127] The processor 61 is used to implement the steps of the memory leak processing method in the above embodiment when executing a computer program.
[0128] The memory leak processing device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0129] Among them, the processor 61 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 61 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 61 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 61 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 61 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0130] The memory 60 may include one or more computer-readable storage media, which may be non-transitory. The memory 60 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 60 is at least used to store the following computer program 601, wherein, after the computer program is loaded and executed by the processor 61, it can implement the relevant steps of the memory leak processing method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 60 may also include an operating system 602 and data 603, etc., and the storage method may be short-term storage or permanent storage. Among them, the operating system 602 may include Windows, Unix, Linux, etc. Data 603 may include but is not limited to relevant data for memory leak processing, etc.
[0131] In some embodiments, the memory leak processing device may further include a display screen 62 , an input / output interface 63 , a communication interface 64 , a power supply 65 , and a communication bus 66 .
[0132] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the memory leak processing device, and may include more or fewer components than those shown in the figure.
[0133] It is understandable that if the memory leak processing method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the current technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk and other media that can store program codes.
[0134] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned memory leak processing method are implemented.
[0135] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0136] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0137] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only 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", "comprises" or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes 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.
[0138] The above is a detailed introduction to a memory leak processing method, device, equipment and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A memory leak processing method, characterized in that: include: Based on the segmented acquired memory capacity, the memory capacity change of the process is obtained, and the current leakage risk value is predicted according to the memory capacity change; If the leakage risk value is greater than or equal to the risk threshold, the process has a memory leakage risk, a backup process is enabled to replace the process, and the memory of the process is released; If the leakage risk value is less than the risk threshold, then there is no memory leakage risk for the process.
2. The memory leak processing method according to claim 1, characterized in that: Based on the segmented memory capacity, the memory capacity change of the process is obtained, and the current leakage risk value is predicted based on the memory capacity change, including: Acquire the memory capacity of the process based on a preset time period to obtain the memory capacity status of multiple time nodes; The memory capacity of the multiple time nodes is analyzed to predict the leakage risk value.
3. The memory leak processing method according to claim 2, characterized in that: Analyzing the memory capacity of the multiple time nodes and predicting the leakage risk value includes: Calculate the memory capacity difference and memory capacity ratio before and after each time period according to the memory capacity of the multiple time nodes; the memory capacity ratio is the memory capacity ratio of the last time period; The leakage risk value is obtained by predicting the memory capacity difference before and after each time period and the memory capacity ratio.
4. The memory leak processing method according to claim 3, characterized in that: After calculating the memory capacity difference and the memory capacity ratio before and after each time period according to the memory capacity conditions of the multiple time nodes, the method further includes: If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the first trend, and the memory capacity ratio reaches the first preset ratio threshold, then the risk level of the process is level one risk; If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the second trend, and the memory capacity ratio reaches the second preset ratio threshold, then the risk level of the process is level 2 risk; If the difference in memory capacity before and after each time period shows a positive increasing trend, and the trend conforms to the third trend, and the memory capacity ratio reaches the third preset ratio threshold, then the risk level of the process is level three risk; The first trend is greater than the second trend, and the second trend is greater than the third trend; the first preset proportion threshold is greater than the second preset proportion threshold, and the second preset proportion threshold is greater than the third preset proportion threshold; A corresponding leakage warning is generated according to the risk level and notified to the operation and maintenance personnel, so that the operation and maintenance personnel can perform corresponding actions based on different leakage levels and manually intervene in the memory situation of the process.
5. The memory leak processing method according to claim 1, characterized in that: Enables an alternate process and frees the memory of said process, including: Starting the standby process and transferring the key business data thread of the process to the standby process; When the key business data thread in the standby process is started, a receipt is triggered; When the process obtains the receipt information, it triggers a restart to release the memory space of the process.
6. The memory leak processing method according to any one of claims 1 to 5, characterized in that: After enabling the standby process and releasing the memory of the process, it also includes: Monitor the memory capacity of the standby process in real time, and if it is predicted that the standby process has a memory leak risk, determine whether the process memory release is complete; If completed, the process is enabled to replace the standby process, and the memory of the standby process is released; If not completed, a secondary standby process is started to replace the standby process and the memory of the standby process is released.
7. The memory leak processing method according to claim 1, characterized in that: Before enabling a backup process to replace the process and releasing the memory of the process, the method further includes: Obtain a process whitelist in advance, wherein the process whitelist includes all valid processes under the same service and process priorities; The backup process is determined based on the process whitelist.
8. A memory leak processing device, characterized in that: include: A leakage risk prediction module is used to obtain the memory capacity change of the process based on the memory capacity obtained in a segmented manner, and predict the current leakage risk value according to the memory capacity change; A memory leak processing module, configured to, if the leakage risk value is greater than or equal to a risk threshold, determine that the process has a memory leak risk, enable a standby process to replace the process, and release the memory of the process; The normal module is used to determine that if the leakage risk value is less than the risk threshold, then the process does not have a memory leakage risk.
9. A memory leak processing device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the memory leak processing method according to any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that: The readable storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the steps of the memory leak processing method according to any one of claims 1 to 7 are implemented.
