Electric energy meter memory leakage protection method and system and medium
By automatically monitoring, warning and handling memory leaks in the power meter, performance degradation and system failures caused by memory leaks in the power meter program development are solved, and the program stability and memory usage efficiency are improved.
Patent Information
- Application Number
- CN202411973615.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-30
AI Technical Summary
In the development of power meter programs, memory leaks often occur due to complex code logic, variable program flow, and improper exception handling, resulting in the system memory resources being gradually exhausted, reducing system performance and even causing program crashes.
By starting the power meter, recording memory location and memory information, allocating and monitoring memory based on memory location and memory information, obtaining memory read and write operation information, using code insertion technology to track memory read and write operation information, perform suspected memory leak marks, and automatically release leaked memory that meets the recycling conditions.
It greatly improves the stability, reliability and memory usage efficiency of the program, and reduces adverse effects such as system failure and performance degradation caused by memory leaks.
Smart Images

Figure CN120066940A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of memory leak analysis. Specifically, it relates to a method, system, and medium for protecting the memory of an electric energy meter from leakage. Background Art
[0002] When developing an electric energy meter program, programmers generally manually allocate (such as using functions like malloc) and release memory. However, due to reasons such as complex code logic, variable program flow, and improper exception handling, memory leaks often occur, that is, the allocated memory is not released after it is no longer used, resulting in the gradual depletion of the system's memory resources, reducing system performance and even causing serious consequences such as program crashes. Traditional debugging means are difficult to comprehensively and efficiently detect and solve memory leaks, especially in complex projects like electric energy meters. Summary of the Invention
[0003] The purpose of the embodiments of this application is to provide a method, system, and medium for protecting the memory of an electric energy meter from leakage. By automatically monitoring, warning, and handling memory leak problems during the program running process, the stability, reliability, and memory usage efficiency of the program are greatly improved, and the adverse effects such as system failures and performance degradation caused by memory leaks are reduced.
[0004] The embodiments of this application also provide a method for protecting the memory of an electric energy meter from leakage, including:
[0005] Start the electric energy meter, record the memory location and memory information, allocate and monitor the memory based on the memory location and memory information to obtain allocation information and monitoring information;
[0006] Obtain the read and write operation information of the memory based on the memory allocation information and monitoring information, and track the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information;
[0007] Mark suspected memory leaks based on the memory usage status information, and determine whether the memory meets the recycling conditions based on the suspected memory leak marks;
[0008] If the recycling conditions are met, determine the suspected memory leak mark as leaked memory and automatically release the leaked memory;
[0009] If the recycling conditions are not met, continue to monitor the memory allocation information.
[0010] Optionally, in the method for protecting the memory of an electric energy meter from leakage described in the embodiments of this application, allocating and monitoring the memory based on the memory location and memory information to obtain allocation information and monitoring information specifically includes:
[0011] Obtain the memory location and memory information, and perform overloading or hook function processing on the memory based on the memory allocation function to obtain the processing result;
[0012] Record the relevant information of each memory allocation based on the processing result, where the relevant information includes the allocated address, size, belonging function module, and allocation time;
[0013] Record the allocated address, size, belonging function module, and allocation time into the memory allocation information table based on the relevant information to obtain the allocation information;
[0014] Analyze the memory monitoring status information based on the memory information, and generate monitoring information based on the memory monitoring status information.
[0015] Optionally, in the electric energy meter memory leak protection method described in the embodiments of the present application, track the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information, specifically including:
[0016] Obtain the memory usage status information;
[0017] Judge whether the memory usage status information is in an effective usage state;
[0018] If it is in an effective usage state, regularly scan the allocation information and monitoring information of the memory;
[0019] If it is not in an effective usage state, mark the memory block as leaked to obtain a suspected leaked memory block.
[0020] Optionally, in the electric energy meter memory leak protection method described in the embodiments of the present application, if the recovery condition is met, determine the suspected memory leak mark as a leaked memory, and automatically release the leaked memory, specifically including:
[0021] Obtain the capacity information of the leaked memory, analyze the ratio of the capacity information of the leaked memory to the total memory to obtain the leakage ratio;
[0022] Judge whether the leakage ratio is greater than or equal to the set leakage threshold;
[0023] If it is greater than or equal to, divide the leaked memory into multiple segments to obtain multiple leaked memory segments, and release the multiple leaked memory segments one by one;
[0024] If it is less than, directly release the leaked memory.
[0025] Optionally, in the electric energy meter memory leak protection method described in the embodiments of the present application, after determining the suspected memory leak mark as a leaked memory, it further includes:
[0026] Obtain the leaked memory, and analyze the memory leak information based on the leaked memory;
[0027] Compare the memory leak information with the set leak information to obtain the leak difference information;
[0028] Compare the leakage difference information with the set difference information to obtain a leakage deviation rate;
[0029] Determine whether the leakage deviation rate is greater than or equal to a set leakage deviation rate threshold;
[0030] If it is greater than or equal to, determine that the leakage is serious, generate a warning message, and generate a repair message based on the warning message;
[0031] If it is less than, generate leakage risk information based on the memory leakage information.
[0032] Optionally, in the method for protecting the memory leakage of an electric energy meter described in the embodiments of the present application, after obtaining the leaked memory and analyzing the memory leakage information based on the leaked memory, it further includes:
[0033] Obtain the memory leakage information within the acquisition time period based on the acquisition time window to obtain the memory leakage information at different acquisition time nodes;
[0034] Compare the memory leakage information at adjacent time nodes to obtain a leakage difference;
[0035] Analyze the leakage risk trend information based on the leakage difference, and analyze the risk trend change status information according to the leakage risk trend information;
[0036] Generate a warning message of a corresponding level based on the risk trend change information.
[0037] In a second aspect, an embodiment of the present application provides a system for protecting the memory leakage of an electric energy meter, the system includes: a memory and a processor, the memory includes a program of the method for protecting the memory leakage of an electric energy meter, and when the program of the method for protecting the memory leakage of an electric energy meter is executed by the processor, the following steps are implemented:
[0038] Start the electric energy meter, record the memory location and memory information, allocate and monitor the memory based on the memory location and memory information to obtain allocation information and monitoring information;
[0039] Obtain the read and write operation information of the memory based on the memory allocation information and monitoring information, and track the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information;
[0040] Perform a suspected memory leakage mark based on the memory usage status information, and determine whether the memory meets the recycling condition based on the suspected memory leakage mark;
[0041] If the recycling condition is met, determine the suspected memory leakage mark as the leaked memory and automatically release the leaked memory;
[0042] If the recycling condition is not met, continue to monitor the memory allocation information.
[0043] Optionally, in the electric energy meter memory leakage protection system described in the embodiment of the present application, the memory is allocated and monitored based on the memory position and the memory information to obtain the allocation information and the monitoring information, specifically including:
[0044] Get the memory location and memory information, reload or hook the memory based on the memory allocation function, and get the processing result;
[0045] Record the relevant information of each memory allocation based on the processing result, the relevant information including the allocated address, size, function module, and allocation time;
[0046] Based on the relevant information, the allocated address, size, function module, and allocation time are recorded in the memory allocation information table to obtain the allocation information;
[0047] Analyze memory monitoring status information based on the memory information, and generate monitoring information based on the memory monitoring status information.
[0048] Optionally, in the electric energy meter memory leakage protection system described in the embodiment of the present application, the read and write operation information of the memory is tracked based on the code insertion technology to obtain the memory usage status information, which specifically includes:
[0049] Get memory usage status information;
[0050] Determine whether the memory usage status information is in a valid usage state;
[0051] If it is in effective use, the memory allocation and monitoring information are scanned regularly;
[0052] If it is not in a valid use state, the memory block is marked as leaked to obtain a suspected leaked memory block.
[0053] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a method program for protecting an electric energy meter from memory leakage. When the method program for protecting an electric energy meter from memory leakage is executed by a processor, the steps of the method for protecting an electric energy meter from memory leakage as described in any one of the above items are implemented.
[0054] As can be seen from the above, a method, system and medium for protecting the memory leakage of an electric energy meter provided by the embodiments of the present application start the electric energy meter, record the memory location and memory information, allocate and monitor the memory based on the memory location and memory information to obtain allocation information and monitoring information; obtain the read and write operation information of the memory based on the memory allocation information and monitoring information, track the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information; perform a suspected memory leakage mark based on the memory usage status information, and determine whether the memory meets the recycling condition based on the suspected memory leakage mark; if the recycling condition is met, determine the suspected memory leakage mark as the leaked memory and automatically release the leaked memory; if the recycling condition is not met, continue to monitor the memory allocation information; the present application automatically monitors, warns and processes memory leakage problems during the program operation, greatly improving the stability, reliability and memory usage efficiency of the program, and reducing the adverse effects such as system failures and performance degradation caused by memory leakage. Description of the Drawings
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0056] Figure 1 It is a flowchart of the method for protecting the memory leakage of the electric energy meter provided by the embodiments of the present application;
[0057] Figure 2 It is a flowchart of the method for obtaining the allocation information and monitoring information of the method for protecting the memory leakage of the electric energy meter provided by the embodiments of the present application;
[0058] Figure 3 It is a flowchart of the method for analyzing the memory usage status of the method for protecting the memory leakage of the electric energy meter provided by the embodiments of the present application. Detailed Embodiments
[0059] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and illustrated in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application provided in the following drawings is not intended to limit the scope of the present application to be protected, but only represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0060] It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, terms such as "first" and "second" are only used for differential description and cannot be construed as indicating or implying relative importance.
[0061] Please refer to Figure 1 , Figure 1 which is a flowchart of a method for protecting against memory leakage in an electric energy meter in some embodiments of this application. The method for protecting against memory leakage in the electric energy meter is used in a terminal device. The method for protecting against memory leakage in the electric energy meter includes the following steps:
[0062] S101, start the electric energy meter, record the memory location and memory information, allocate and monitor the memory based on the memory location and memory information, and obtain allocation information and monitoring information;
[0063] S102, obtain the read and write operation information of the memory based on the memory allocation information and monitoring information, and track the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information;
[0064] S103, perform a suspected memory leakage mark based on the memory usage status information, and determine whether the memory meets the recycling condition based on the suspected memory leakage mark;
[0065] S104, if the recycling condition is met, determine the suspected memory leakage mark as leaked memory and automatically release the leaked memory;
[0066] S105, if the recycling condition is not met, continue to monitor the memory allocation information.
[0067] It should be noted that by analyzing the memory usage status information to mark the memory for leakage, the recycling condition of the memory leakage is analyzed to ensure the release effect of the leaked memory.
[0068] Please refer to Figure 2 , Figure 2 which is a flowchart of a method for obtaining allocation information and monitoring information of a method for protecting against memory leakage in an electric energy meter in some embodiments of this application. According to the embodiments of the present invention, the memory is allocated and monitored based on the memory location and memory information to obtain allocation information and monitoring information, which specifically includes:
[0069] S201, obtain the memory location and memory information, and perform overloading or hook function processing on the memory based on the memory allocation function to obtain a processing result;
[0070] S202, record the relevant information of each memory allocation based on the processing result. The relevant information includes the allocated address, size, belonging function module, and allocation time;
[0071] S203, record the allocated address, size, belonging function module, and allocation time into the memory allocation information table based on the relevant information to obtain the allocation information;
[0072] S204, analyze the memory monitoring status information based on the memory information, and generate monitoring information based on the memory monitoring status information.
[0073] It should be noted that by analyzing the relevant information of memory allocation, a comprehensive analysis of the memory monitoring status is carried out to improve the monitoring accuracy of the memory.
[0074] Please refer to Figure 3 , Figure 3 is a flowchart of the memory usage status analysis method of a power meter memory leak prevention method in some embodiments of the present application. According to the embodiments of the present invention, based on the code instrumentation technology, the read and write operation information of the memory is tracked to obtain the memory usage status information, which specifically includes:
[0075] S301, obtain the memory usage status information;
[0076] S302, determine whether the memory usage status information is in an effective usage state;
[0077] S303, if it is in an effective usage state, regularly scan the allocation information and monitoring information of the memory;
[0078] S304, if it is not in an effective usage state, mark the memory block as leaked to obtain a suspected leaked memory block.
[0079] It should be noted that during the program operation, the read and write operations of the memory are tracked through the code instrumentation technology to determine whether the memory is in an effective usage state, and the memory blocks that have not been read or written for a long time and have no reference pointers are marked as suspected leaked memory.
[0080] According to the embodiments of the present invention, if the recycling condition is met, the suspected memory leak mark is determined as a leaked memory, and the leaked memory is automatically released, which specifically includes:
[0081] Obtain the capacity information of the leaked memory, analyze the ratio of the capacity information of the leaked memory to the total memory to obtain the leakage ratio;
[0082] Determine whether the leakage ratio is greater than or equal to the set leakage threshold;
[0083] If it is greater than or equal to, divide the leaked memory into multiple segments to obtain multiple leaked memory segments, and release the multiple leaked memory segments one by one;
[0084] If it is less than, directly release the leaked memory.
[0085] It should be noted that the memory allocation information table and the suspected leaked memory flag are scanned regularly. When the recycling conditions are met (such as the idle period of the program, the cumulative suspected leaked memory exceeds a certain threshold, etc.), the memory determined to be leaked is automatically released, the memory allocation information table is updated, and a recycling log is recorded for subsequent analysis.
[0086] According to the embodiment of the present invention, after determining the suspected memory leak flag as leaked memory, it further includes:
[0087] Obtain the leaked memory and analyze the memory leak information based on the leaked memory;
[0088] Compare the memory leak information with the set leak information to obtain leak difference information;
[0089] Compare the leak difference information with the set difference information to obtain a leak deviation rate;
[0090] Determine whether the leak deviation rate is greater than or equal to the set leak deviation rate threshold;
[0091] If it is greater than or equal to, determine that the leak is serious, generate a warning message, and generate repair information based on the warning message;
[0092] If it is less than, generate leak risk information based on the memory leak information.
[0093] It should be noted that by analyzing the memory leak information and comparing it with the set difference information, the leak degree is analyzed, and different leak degrees are used to give different levels of warnings to the leaked memory, so as to achieve multi-level warnings and improve the flexibility of warnings.
[0094] According to the embodiment of the present invention, after obtaining the leaked memory and analyzing the memory leak information based on the leaked memory, it further includes:
[0095] Based on the acquisition time window, obtain the memory leak information within the acquisition time period to obtain the memory leak information at different acquisition time nodes;
[0096] Compare the memory leak information at adjacent time nodes to obtain a leak difference;
[0097] Analyze the leak risk trend information based on the leak difference, and analyze the risk trend change status information according to the leak risk trend information;
[0098] Generate a warning message of the corresponding level based on the risk trend change information.
[0099] It should be noted that by analyzing the memory leak information at different time nodes, the leakage risk trend is judged, so as to accurately evaluate the leakage risk, and then different levels of early warnings are given for the leakage risk to improve the early warning effect.
[0100] In a second aspect, an embodiment of the present application provides a memory leak protection system for an electric energy meter. The system includes: a memory and a processor. The memory includes a program of the memory leak protection method for the electric energy meter. When the program of the memory leak protection method for the electric energy meter is executed by the processor, the following steps are implemented:
[0101] Start the electric energy meter, record the memory location and memory information, allocate and monitor the memory based on the memory location and memory information to obtain allocation information and monitoring information;
[0102] Obtain the read and write operation information of the memory based on the memory allocation information and monitoring information, and track the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information;
[0103] Mark suspected memory leaks based on the memory usage status information, and judge whether the memory meets the recycling conditions based on the suspected memory leak marks;
[0104] If the recycling conditions are met, the suspected memory leak mark is determined to be leaked memory, and the leaked memory is automatically released;
[0105] If the recycling conditions are not met, continue to monitor the memory allocation information.
[0106] According to an embodiment of the present invention, allocating and monitoring the memory based on the memory location and memory information to obtain allocation information and monitoring information specifically includes:
[0107] Obtain the memory location and memory information, and perform overloading or hook function processing on the memory based on the memory allocation function to obtain a processing result;
[0108] Record the relevant information of each memory allocation based on the processing result. The relevant information includes the allocated address, size, belonging function module, and allocation time;
[0109] Record the allocated address, size, belonging function module, and allocation time to the memory allocation information table based on the relevant information to obtain allocation information;
[0110] Analyze the memory monitoring status information based on the memory information, and generate monitoring information based on the memory monitoring status information.
[0111] According to an embodiment of the present invention, tracking the read and write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information specifically includes:
[0112] Obtain the memory usage status information;
[0113] Determine whether the memory usage status information is in a valid usage state;
[0114] If it is in a valid usage state, periodically scan the allocation information and monitoring information of the memory;
[0115] If it is not in a valid usage state, mark the memory block as leaked to obtain a suspected leaked memory block.
[0116] It should be noted that during the program running process, the read and write operations of the memory are tracked through code instrumentation technology to determine whether the memory is in a valid usage state, and the memory blocks that have not been read or written for a long time and have no reference pointers are marked as suspected leaked memory.
[0117] According to the embodiments of the present invention, if the recycling conditions are met, the suspected memory leak mark is determined as leaked memory, and the leaked memory is automatically released, specifically including:
[0118] Obtain the capacity information of the leaked memory, analyze the ratio of the capacity information of the leaked memory to the total memory to obtain a leakage ratio;
[0119] Determine whether the leakage ratio is greater than or equal to a set leakage threshold;
[0120] If it is greater than or equal to, divide the leaked memory into multiple segments to obtain multiple leaked memory segments, and release the multiple leaked memory segments one by one;
[0121] If it is less than, directly release the leaked memory.
[0122] It should be noted that the memory allocation information table and the suspected leaked memory mark are periodically scanned. When the recycling conditions are met (such as the program idle period, the cumulative suspected leaked memory exceeds a certain threshold, etc.), the memory determined to be leaked is automatically released, and the memory allocation information table is updated. At the same time, a recycling log is recorded for subsequent analysis.
[0123] According to the embodiments of the present invention, after determining the suspected memory leak mark as leaked memory, it further includes:
[0124] Obtain the leaked memory, and analyze the memory leak information based on the leaked memory;
[0125] Compare the memory leak information with the set leak information to obtain leak difference information;
[0126] Compare the leak difference information with the set difference information to obtain a leak deviation rate;
[0127] Determine whether the leak deviation rate is greater than or equal to a set leak deviation rate threshold;
[0128] If it is greater than or equal to, it is determined that the leakage is serious, a warning message is generated, and a repair message is generated based on the warning message;
[0129] If it is less than, leakage risk information is generated based on the memory leakage information.
[0130] It should be noted that by analyzing the difference information between the memory leakage information judgment and the setting, the leakage degree is analyzed, and different levels of warnings are given to the leaked memory for different leakage degrees, so as to achieve multi-level warnings and improve the flexibility of warnings.
[0131] According to an embodiment of the present invention, the leaked memory is obtained, and the memory leakage information is analyzed based on the leaked memory. After that, it further includes:
[0132] Based on the acquisition time window, the memory leakage information within the acquisition time period is obtained, and the memory leakage information at different acquisition time nodes is obtained;
[0133] Compare the memory leakage information at adjacent time nodes to obtain a leakage difference;
[0134] Analyze the leakage risk trend information based on the leakage difference, and analyze the risk trend change status information according to the leakage risk trend information;
[0135] Generate a warning message of the corresponding level based on the risk trend change information.
[0136] It should be noted that by analyzing the memory leakage information at different time nodes, the leakage risk trend is judged, so as to accurately evaluate the leakage risk, and then different levels of warnings are given to the leakage risk, improving the warning effect.
[0137] The third aspect of the present invention provides a computer-readable storage medium, which includes a program for the memory leakage protection method of the electric energy meter. When the program for the memory leakage protection method of the electric energy meter is executed by a processor, the steps of the memory leakage protection method of the electric energy meter as described in any one of the above are realized.
[0138] A method, system and medium for protecting against memory leakage in an electric energy meter. By starting the electric energy meter, recording the memory location and memory information, allocating and monitoring the memory based on the memory location and memory information to obtain allocation information and monitoring information; obtaining the read-write operation information of the memory based on the memory allocation information and monitoring information, and tracking the read-write operation information of the memory based on the code instrumentation technology to obtain the memory usage status information; making a suspected memory leakage mark based on the memory usage status information, and judging whether the memory meets the recycling condition based on the suspected memory leakage mark; if the recycling condition is met, determining the suspected memory leakage mark as leaked memory and automatically releasing the leaked memory; if the recycling condition is not met, continuing to monitor the memory allocation information; this application automatically monitors, warns and processes memory leakage problems during the program operation, greatly improving the stability, reliability and memory usage efficiency of the program, and reducing the adverse effects such as system failures and performance degradation caused by memory leakage.
[0139] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical, or other forms.
[0140] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units; they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0141] In addition, in each embodiment of the present invention, each functional unit can be all integrated in a processing unit, or each unit can be separately used as a unit, or two or more units can be integrated in a unit; the above integrated units can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.
[0142] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a readable storage medium. When the program is executed, it performs the steps including those of the above method embodiments; and the foregoing storage medium includes: various media that can store program codes, such as removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0143] Alternatively, if the above integrated unit of the present invention is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the various embodiments of the present invention. And the foregoing storage medium includes: various media that can store program codes, such as removable storage devices, ROM, RAM, magnetic disks, or optical discs.
Claims
1. A method for preventing memory leakage of an electric energy meter, characterized in that: include: The electric energy meter is started, the memory position and the memory information are recorded, and the memory is allocated and monitored based on the memory position and the memory information to obtain allocation information and monitoring information; Obtain memory read and write operation information based on memory allocation information and monitoring information, track memory read and write operation information based on code instrumentation technology, and obtain memory usage status information; Mark suspected memory leaks based on memory usage status information, and determine whether the memory meets the recycling conditions based on the suspected memory leak marks; If the recycling conditions are met, the suspected memory leak will be marked as leaked memory and the leaked memory will be automatically released; If the recycling conditions are not met, continue to monitor the memory allocation information.
2. The method for preventing memory leakage of electric energy meter according to claim 1, characterized in that: Allocate and monitor memory based on memory location and memory information to obtain allocation information and monitoring information, including: Get the memory location and memory information, reload or hook the memory based on the memory allocation function, and get the processing result; Record the relevant information of each memory allocation based on the processing result, the relevant information including the allocated address, size, function module, and allocation time; Based on the relevant information, the allocated address, size, function module, and allocation time are recorded in the memory allocation information table to obtain the allocation information; Analyze memory monitoring status information based on the memory information, and generate monitoring information based on the memory monitoring status information.
3. The method for preventing memory leakage of electric energy meter according to claim 2, characterized in that: Based on the code instrumentation technology, the read and write operation information of the memory is tracked to obtain the memory usage status information, including: Get memory usage status information; Determine whether the memory usage status information is in a valid usage state; If it is in effective use, the memory allocation and monitoring information are scanned regularly; If it is not in a valid use state, the memory block is marked as leaked to obtain a suspected leaked memory block.
4. The method for preventing memory leakage of electric energy meter according to claim 3, characterized in that: If the recycling conditions are met, the suspected memory leak will be marked as leaked memory and the leaked memory will be automatically released, including: Obtaining the capacity information of the leaked memory, analyzing the ratio of the capacity information of the leaked memory to the total memory, and obtaining the leakage ratio; Determining whether the leakage ratio is greater than or equal to a set leakage threshold; If it is greater than or equal to, the leaked memory is divided into multiple segments to obtain multiple leaked memory segments, and the multiple leaked memory segments are released one by one; If it is less than that, the leaked memory will be released directly.
5. The method for preventing memory leakage of electric energy meter according to claim 1, characterized in that: The suspected memory leak is marked as a memory leak, and then includes: Get leaked memory and analyze memory leak information based on the leaked memory; Compare the memory leak information with the set leak information to obtain leak difference information; Compare the leakage difference information with the set difference information to obtain the leakage deviation rate; Determining whether the leakage deviation rate is greater than or equal to a set leakage deviation rate threshold; If it is greater than or equal to, the leakage is judged to be serious, and an early warning message is generated, and repair information is generated based on the early warning message; If it is less than, leakage risk information is generated based on the memory leakage information.
6. The method for preventing memory leakage of electric energy meter according to claim 5, characterized in that: Get leaked memory, analyze memory leak information based on leaked memory, and then include: Based on the collection time window, the memory leakage information within the collection time period is obtained, and the memory leakage information at different collection time nodes is obtained; Compare the memory leakage information at adjacent time nodes to obtain the leakage difference; Analyze leakage risk trend information based on leakage difference, and analyze risk trend change status information based on leakage risk trend information; Generate warning information of corresponding levels based on risk trend change information.
7. An electric energy meter memory leakage protection system, characterized in that: The system includes: a memory and a processor, wherein the memory includes a program of a method for preventing a memory leakage of an electric energy meter, and when the program of the method for preventing a memory leakage of an electric energy meter is executed by the processor, the following steps are implemented: The electric energy meter is started, the memory position and the memory information are recorded, and the memory is allocated and monitored based on the memory position and the memory information to obtain allocation information and monitoring information; Obtain memory read and write operation information based on memory allocation information and monitoring information, track memory read and write operation information based on code instrumentation technology, and obtain memory usage status information; Mark suspected memory leaks based on memory usage status information, and determine whether the memory meets the recycling conditions based on the suspected memory leak marks; If the recycling conditions are met, the suspected memory leak will be marked as leaked memory and the leaked memory will be automatically released; If the recycling conditions are not met, continue to monitor the memory allocation information.
8. The electric energy meter memory leakage protection system according to claim 7, characterized in that: Allocate and monitor memory based on memory location and memory information to obtain allocation information and monitoring information, including: Get the memory location and memory information, reload or hook the memory based on the memory allocation function, and get the processing result; Record the relevant information of each memory allocation based on the processing result, the relevant information including the allocated address, size, function module, and allocation time; Based on the relevant information, the allocated address, size, function module, and allocation time are recorded in the memory allocation information table to obtain the allocation information; Analyze memory monitoring status information based on the memory information, and generate monitoring information based on the memory monitoring status information.
9. The electric energy meter memory leakage protection system according to claim 8, characterized in that: Based on the code instrumentation technology, the read and write operation information of the memory is tracked to obtain the memory usage status information, including: Get memory usage status information; Determine whether the memory usage status information is in a valid usage state; If it is in effective use, the memory allocation and monitoring information are scanned regularly; If it is not in a valid use state, the memory block is marked as leaked to obtain a suspected leaked memory block.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes an electric energy meter memory leakage protection method program, and when the electric energy meter memory leakage protection method program is executed by a processor, the steps of the electric energy meter memory leakage protection method according to any one of claims 1 to 6 are implemented.