Memory overflow detection method, apparatus, device, medium and product
By filtering and analyzing heap dump files, generating reference chains, and determining the cause of memory overflow, the problem of low detection efficiency and accuracy in existing technologies is solved, achieving more efficient memory overflow detection.
Patent Information
- Application Number
- CN202410830615.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-06-25
AI Technical Summary
The existing technology analyzes all objects in the heap dump file, resulting in low efficiency and accuracy in detecting memory overflows.
At preset intervals, the memory data of the target business application is converted into a heap dump file, historical detection data is obtained, business objects are parsed and filtered, a reference relationship chain is generated, and the cause of memory overflow is determined by combining class name and object quantity.
It improves the accuracy and efficiency of memory overflow detection, enabling timely detection and repair of memory overflow issues.
Smart Images

Figure CN118838816B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and in particular to a memory overflow detection method, device, equipment, medium and product. BACKGROUND
[0002] In the running of a business application, the business application applies for the allocation of memory by an operating system, and the operating system allocates memory from a heap to store objects and arrays generated by the business application. The memory allocated from the heap needs to be released subsequently, and if it is not released, as the business application continuously applies for the allocation of memory, the available memory will become less and less, and the business application will have a memory overflow problem. When the business application has a memory overflow problem, if the memory overflow is not detected in time, the business application will not be able to be used normally.
[0003] In the prior art, for the detection of memory overflow, the heap dump file obtained is usually analyzed to determine the relevant data of all objects in the business application, and then it is analyzed and determined which classes of objects are the cause of the memory overflow.
[0004] To sum up, the existing memory overflow detection method analyzes all objects in the heap dump file, resulting in low detection efficiency and accuracy. SUMMARY
[0005] The present application provides a memory overflow detection method, device, equipment, medium and product to solve the problem of low detection efficiency and accuracy caused by analyzing all objects in the heap dump file in the prior art.
[0006] In a first aspect, the present application provides a memory overflow detection method, comprising:
[0007] Every interval of a preset time length, the data in the memory corresponding to the target business application is converted into a heap dump file, and historical detection data is obtained, the historical detection data comprising the number of first objects corresponding to each preset business filtering class name;
[0008] The heap dump file is parsed to obtain parsed data, the parsed data comprising object data of a plurality of second objects, and the object data of each second object comprising a class name of the second object and an inter-object reference relationship;
[0009] According to the business filtering class name and the class name of each second object, the plurality of second objects are filtered to obtain third objects;
[0010] At least one reference relationship chain is generated according to the inter-object reference relationship of each third object;
[0011] According to the class name of each third object, the number of first objects corresponding to each business filtering class name, and the at least one reference relationship chain, a detection result is determined, and the detection result includes a target class name causing the memory overflow.
[0012] In a possible design, according to the class name of each third object, the number of first objects corresponding to each business filtering class name, and the at least one reference relationship chain, the detection result is determined, and the detection result includes:
[0013] According to the class name of each third object, the number of third objects corresponding to each business filtering class name is determined.
[0014] According to the preconfigured overflow threshold corresponding to each business filtering class name and the number of third objects corresponding to each business filtering class name, a first class name is determined.
[0015] According to the number of third objects corresponding to each business filtering class name and the number of first objects corresponding to each business filtering class name, a second class name is determined.
[0016] According to the at least one reference relationship chain, a root node object of third objects corresponding to each first class name and each second class name is determined.
[0017] The first class name, the second class name, and the class name of each root node object are taken as the target class name, and the detection result is generated.
[0018] In a possible design, the first class name is determined according to the preconfigured overflow threshold corresponding to each business filtering class name and the number of third objects corresponding to each business filtering class name, and the determination includes:
[0019] For each business filtering class name, if the number of third objects corresponding to the business filtering class name is greater than the preconfigured overflow threshold corresponding to the business filtering class name, the business filtering class name is taken as the first class name.
[0020] In a possible design, the second class name is determined according to the number of third objects corresponding to each business filtering class name and the number of first objects corresponding to each business filtering class name, and the determination includes:
[0021] For each business filtering class name, the difference between the number of third objects corresponding to the business filtering class name and the number of first objects corresponding to the business filtering class name is calculated to obtain an object growth amount of the business filtering class name.
[0022] For each business filter class name, if an object growth amount of the business filter class name is greater than a preset growth amount threshold, the business filter class name is taken as the second class name.
[0023] In a possible design, the second class name is determined according to a number of third objects corresponding to each business filter class name and a number of first objects corresponding to each business filter class name.
[0024] For each business filter class name, a difference between a number of third objects corresponding to the business filter class name and a number of first objects corresponding to the business filter class name is calculated, to obtain an object growth amount of the business filter class name.
[0025] For each business filter class name, a ratio between an object growth amount corresponding to the business filter class name and a number of first objects corresponding to the business filter class name is calculated, to obtain an object growth rate of the business filter class name.
[0026] For each business filter class name, if an object growth rate of the business filter class name is greater than a preset growth rate threshold, the business filter class name is taken as the second class name.
[0027] In a possible design, the data in the memory corresponding to the target business application is converted into the heap dump file, including:
[0028] The data in the memory corresponding to the target business application is converted into the heap dump file by using a Java diagnostic tool.
[0029] In a second aspect, the present application provides a memory overflow detection apparatus, including:
[0030] a processing module, configured to:
[0031] every interval of a preset time length, convert data in the memory corresponding to the target business application into a heap dump file, and acquire historical detection data, the historical detection data including a number of first objects corresponding to each preset business filter class name;
[0032] analyze the heap dump file to obtain analysis data, the analysis data including object data of a plurality of second objects, and the object data of each second object including a class name of the second object and an inter-object reference relationship;
[0033] filter the plurality of second objects according to the business filter class name and the class name of each second object, to obtain third objects;
[0034] generate at least one reference relationship chain according to the inter-object reference relationship of each third object.
[0035] The detection module is configured to determine a detection result according to the class name of each third object, the number of first objects corresponding to each business filtering class name, and the at least one reference relationship chain, wherein the detection result includes a target class name causing the memory overflow.
[0036] In a third aspect, the present application provides an electronic device, comprising:
[0037] a processor, a memory, and a communication interface;
[0038] The memory is configured to store executable instructions of the processor.
[0039] The processor is configured to execute the memory overflow detection method according to any one of the first aspect by executing the executable instructions.
[0040] In a fourth aspect, the present application provides a readable storage medium having a computer program stored thereon, wherein the computer program is configured to implement the memory overflow detection method according to any one of the first aspect when executed by a processor.
[0041] In a fifth aspect, the present application provides a computer program product comprising a computer program, wherein the computer program is configured to implement the memory overflow detection method according to any one of the first aspect when executed by a processor.
[0042] The memory overflow detection method, device, equipment, medium and product provided by the present application convert the data in the memory corresponding to the target business application into a heap dump file every interval of a preset time length, and obtain historical detection data. Then, the heap dump file is parsed to obtain parsing data, and then a plurality of second objects are filtered according to the business filtering class name and the class name of each second object in the parsing data, to obtain third objects. Then, at least one reference relationship chain is generated according to the inter-object reference relationship of each third object in the parsing data. Finally, a detection result including a target class name causing the memory overflow is determined according to the class name of each third object, the number of first objects corresponding to each business filtering class name in the historical detection data, and the at least one reference relationship chain. The present application effectively improves the detection accuracy and efficiency by combining the historical detection data and determining the detection result according to the class name and the reference relationship chain of the third object filtered. BRIEF DESCRIPTION OF DRAWINGS
[0043] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate one embodiment consistent with the present application and, together with the description, serve to explain the principles of the application.
[0044] Figure 1a A flowchart of the memory overflow detection method provided by the present application is shown in the following figure.
[0045] Figure 1bThe reference relationship provided for the present application is shown in the schematic diagram;
[0046] Figure 2 The flow schematic diagram of the memory overflow detection method embodiment two provided for the present application is shown in the schematic diagram;
[0047] Figure 3 The structure schematic diagram of the memory overflow detection device embodiment provided for the present application is shown in the schematic diagram;
[0048] Figure 4 The structure schematic diagram of the electronic device provided for the present application is shown in the schematic diagram.
[0049] Through the above-mentioned drawings, the explicit embodiments of the present application have been shown, and will be described in more detail hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application by any means, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0050] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, the same numbers are used to indicate the same or similar components. The embodiments described in the following exemplary embodiments are not meant to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.
[0051] The terms "first", "second", "third", "fourth" and the like in the description and the claims of the present application and the above-mentioned drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of these terms herein is to be construed to cover the possibility where alternative selection could be used other than those explicitly described herein. Further, the terms "comprise" and "have", and any variations thereof, are intended to cover a non-exclusive inclusion, such that processes, methods, systems, products, or apparatuses that comprise, have, or are otherwise including a list of steps or units are not necessarily limited to those steps or units explicitly listed, but can include additional steps or units not expressly listed or inherent to such processes, methods, products, or apparatuses.
[0052] A business application is a Java program, which includes classes and objects, and the objects are instances of the classes. When the business application runs, it applies for memory allocation to the operating system, and the operating system allocates memory from the heap to store the objects and arrays generated by the business application. The memory allocated from the heap needs to be released subsequently. If it is not released, as the business application continuously applies for memory allocation, the available memory will become less and less, and the business application will have a memory overflow problem. When the business application has a memory overflow problem, if the memory overflow is not detected in time, the business application will not be able to be used normally.
[0053] In the prior art, for the detection of memory overflow, the obtained heap dump file is usually analyzed to determine the related data of all objects in the business application, and then it is determined which class of object causes the memory overflow. Analyzing all objects in the heap file will cause the problems of low detection efficiency and accuracy.
[0054] In view of the problems in the prior art, the inventors found in the research on the memory overflow detection method that the objects in the heap dump file can be divided into system objects and business objects. The system objects generally do not increase, and the business objects increase in the running process of the business application because they are related to the business, and are the cause of the memory overflow. Therefore, in order to improve the detection accuracy and efficiency, the objects in the heap dump file can be screened to determine the business objects, and then the class name of the business object causing the memory overflow is determined in combination with the historical detection data. Based on the above inventive concept, the memory overflow detection scheme in the present application is designed.
[0055] The execution subject of the memory overflow detection method in the present application can be a server, and can also be a computer, a terminal device or the like, which is not limited in the present application, and the following will be described taking the server as an example.
[0056] The application scenario of the memory overflow detection method provided in the present application will be described by way of example.
[0057] For example, in this application scenario, a target business application runs on the server, and the target business application applies for memory from the operating system to store the objects and arrays of the target business application in the running process. In order to detect whether the target business application has a memory overflow problem in time, the server converts the data in the memory corresponding to the target business application into a heap dump file every interval of a preset time length, and obtains historical detection data.
[0058] Then, the heap dump file is parsed to obtain parsing data. Then, according to the business filtering class name and the class name of each second object in the parsing data, the plurality of second objects are filtered to obtain third objects.
[0059] According to the inter-object reference relationship of each third object in the analysis data, at least one reference relationship chain is generated.
[0060] Further, according to the class name of each third object, the number of the first objects corresponding to each business filtering class name in the historical detection data, and the at least one reference relationship chain, a detection result is determined, and the detection result includes a target class name causing the memory overflow.
[0061] If the detection result is not empty, it means that there is a memory overflow situation, and the target class name in the detection result is the cause of the memory overflow. The server can send the detection result to the terminal device of the staff, and the staff can check and repair the class corresponding to the target class name in the target business application after checking the detection result, so as to reduce the occurrence of the memory overflow situation.
[0062] It should be noted that the above scenario is only an example of an application scenario provided by the embodiments of the present application, and the actual form of various devices included in the scenario is not limited, nor is the interaction mode between the devices limited. In the specific application of the scheme, the actual needs can be set according to the actual needs.
[0063] In the following, the technical scheme of the present application is described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in detail in some embodiments.
[0064] Figure 1a The flowchart of the memory overflow detection method embodiment provided by the present application is shown in the figure, and the server filters the objects in the heap dump file, and completes the memory overflow detection in combination with the historical detection data. The method in this embodiment can be realized by software, hardware or a combination of software and hardware. As shown in the figure, the memory overflow detection method specifically includes the following steps: Figure 1a
[0065] S101: Every interval of a preset time length, the data in the memory corresponding to the target business application is converted into a heap dump file, and the historical detection data is obtained.
[0066] In this step, in order to detect whether the target business application has a memory overflow situation in time, the server detects once every interval of a preset time length. First, every interval of a preset time length, the data in the memory corresponding to the target business application is converted into a heap dump file, and the historical detection data is obtained.
[0067] The historical detection data includes the number of first objects corresponding to each preset business filtering class name. The business filtering class name is the name of a class related to a business. For example, the business filtering class names are business01, business02, business03, and the like. The embodiments of the present application do not limit the business filtering class names, which can be set according to actual conditions.
[0068] Specifically, the server converts the data in the memory corresponding to the target business application into a heap dump file through a Java diagnostic tool. The Java diagnostic tool can be Arthas, jmap, jcmd, and the like. The embodiments of the present application do not limit the Java diagnostic tool, which can be determined according to actual conditions.
[0069] It should be noted that the preset time length can be 3 seconds, 10 seconds, 1 minute, 5 minutes, 30 minutes, 1 hour, 2 hours, and the like. The embodiments of the present application do not limit the preset time length, which can be set according to actual conditions.
[0070] S102: Analyzing the heap dump file to obtain analysis data.
[0071] In this step, the server obtains the heap dump file and analyzes it to obtain analysis data. The analysis data includes object data of a plurality of second objects. The object data of each second object includes the class name of the second object and the inter-object reference relationship.
[0072] The server can use Hprof-parser to analyze the heap dump file and extract the analysis data therefrom.
[0073] S103: Filtering the plurality of second objects according to the business filtering class name and the class name of each second object to obtain third objects.
[0074] In this step, after the server obtains the analysis data, the second objects in the analysis data include both business objects and system objects. Only the business objects can cause memory overflow. Therefore, the server needs to filter the business objects from the second objects. The server filters the plurality of second objects according to the business filtering class name and the class name of each second object to obtain third objects.
[0075] For each second object, if the class name of the second object belongs to the business filtering class name, the second object is taken as a third object. If the class name of the second object does not belong to the business filtering class name, the second object is discarded.
[0076] S104: Generating at least one reference relationship chain according to the inter-object reference relationship of each third object.
[0077] In this step, after the server obtains the parsed data, in order to determine the class causing the memory overflow in a deeper level, the server needs to generate at least one reference relationship chain according to the inter-object reference relationship of each third object.
[0078] Exemplarily, Figure 1b The reference relationship diagram provided in this application is shown in FIG. 1. Figure 1b As shown in FIG. 1, there are two reference relationship chains in the diagram. There are eleven third objects, which are object A-object K. The inter-object reference relationship of object A is empty. The inter-object reference relationship of object B is that object B references object A. The inter-object reference relationship of object C is that object C references object A. The inter-object reference relationship of object D is that object D references object B. The inter-object reference relationship of object E is that object E references object C. The inter-object reference relationship of object F is empty. The inter-object reference relationship of object G is that object G references object D, object E and object F. The inter-object reference relationship of object H is that object H references object F. The inter-object reference relationship of object I is empty. The inter-object reference relationship of object J is that object J references object I. The inter-object reference relationship of object K is that object K references object J. According to the inter-object reference relationship of object A-object K, two reference relationship chains shown in FIG. 2 are generated. Figure 1b
[0079] It should be noted that the execution sequence of step S103 and step S104 can be that step S103 is executed first and then step S104 is executed. The execution sequence of step S104 can be that step S104 is executed first and then step S103 is executed. The execution sequence of step S103 and step S104 can also be that step S103 and step S104 are executed simultaneously. The execution sequence of step S103 and step S104 is not limited in the embodiments of the present application, and can be determined according to actual conditions.
[0080] S105: determining a detection result according to the class name of each third object, the number of first objects corresponding to each business filtering class name and the at least one reference relationship chain.
[0081] In this step, after the server obtains the reference relationship chain and the third object, the server needs to determine the class causing the memory overflow from the classes of the third objects. The server determines a detection result according to the class name of each third object, the number of first objects corresponding to each business filtering class name and the at least one reference relationship chain. The detection result includes the target class name causing the memory overflow.
[0082] The server determines the class name of which the number of third objects is larger, the class name of which the object growth amount or growth rate is larger, and then determines the root node object of the determined class name in combination with the reference relationship chain, and determines the class name of the root node object. These determined class names are the target class names.
[0083] The memory overflow detection method provided in the embodiment converts data in the memory corresponding to the target service application into a heap dump file every interval of a preset time length, and acquires historical detection data. Then, the heap dump file is parsed to obtain parsing data, and according to the service filter class name and the class name of each second object in the parsing data, the plurality of second objects are filtered to obtain third objects; according to the inter-object reference relationship of each third object in the parsing data, at least one reference relationship chain is generated; and finally, according to the class name of each third object, the number of first objects corresponding to each service filter class name in the historical detection data, and the at least one reference relationship chain, a detection result including the target class name causing the memory overflow is determined. Compared with the prior art in which all objects in the heap dump file are analyzed, the scheme effectively improves the detection accuracy and detection efficiency by combining the historical detection data and determining the detection result according to the class name of the third object filtered and the reference relationship chain.
[0084] Figure 2 The flowchart of the memory overflow detection method embodiment two provided in the application is based on the above-mentioned embodiments, and the application embodiment describes the case where the server determines the detection result according to the class name of each third object, the number of first objects corresponding to each service filter class name, and the at least one reference relationship chain. As shown in the figure, Figure 2 The memory overflow detection method specifically includes the following steps:
[0085] S201: Determine the number of third objects corresponding to each service filter class name according to the class name of each third object.
[0086] In this step, after the server obtains the reference relationship chain and the third object, since the cause of the memory overflow is that the object occupies a large amount of memory, the amount of memory occupied by the object can be measured by the number of objects, so it is necessary to determine the number of third objects corresponding to each service filter class name.
[0087] Since the third object is obtained by filtering according to the service filter class name, the class name of each third object belongs to the service filter class name, so the number of third objects corresponding to each service filter class name can be determined according to the class name of each third object.
[0088] S202: Determine the first class name according to the pre-configured overflow threshold value corresponding to each service filter class name and the number of third objects corresponding to each service filter class name.
[0089] In this step, after the server obtains the number of third objects corresponding to each service filtering class name, the server can select the class name with a larger number of objects, and determine the first class name according to the preconfigured overflow threshold corresponding to each service filtering class name and the number of third objects corresponding to each service filtering class name.
[0090] Specifically, for each service filtering class name, if the number of third objects corresponding to the service filtering class name is greater than the preconfigured overflow threshold corresponding to the service filtering class name, it indicates that the service filtering class name is the name of a class that causes memory overflow, and the service filtering class name is taken as the first class name.
[0091] It should be noted that the preconfigured overflow thresholds corresponding to different service filtering class names can be the same or different. The smaller the memory occupied by the objects corresponding to a service filtering class name, the greater the overflow threshold corresponding to the service filtering class name. The overflow threshold can be 1000, 2000, 5000, etc., and the present embodiment is not limited to the overflow threshold, which can be set according to actual conditions.
[0092] S203: Determine the second class name according to the number of third objects corresponding to each service filtering class name and the number of first objects corresponding to each service filtering class name.
[0093] In this step, after the server obtains the number of third objects corresponding to each service filtering class name, if the number of objects of a class increases rapidly, it indicates that the class is also a cause of memory overflow. The server determines the second class name according to the number of third objects corresponding to each service filtering class name and the number of first objects corresponding to each service filtering class name.
[0094] In one implementation manner, for each service filtering class name, the difference between the number of third objects corresponding to the service filtering class name and the number of first objects corresponding to the service filtering class name is calculated to obtain the object growth of the service filtering class name.
[0095] Further, for each service filtering class name, if the object growth of the service filtering class name is greater than a preset growth threshold, it indicates that the number of objects corresponding to the service filtering class name increases rapidly, and the service filtering class name is taken as the second class name.
[0096] It should be noted that the preset growth threshold can be 500, 800, 1000, etc., and the present embodiment is not limited to the preset growth threshold, which can be set according to actual conditions.
[0097] In another implementation, for each business filter class name, a difference between the number of the third objects corresponding to the business filter class name and the number of the first objects corresponding to the business filter class name is calculated, to obtain an object growth amount of the business filter class name.
[0098] Further, for each business filter class name, a ratio between the object growth amount corresponding to the business filter class name and the number of the first objects corresponding to the business filter class name is calculated, to obtain an object growth rate of the business filter class name.
[0099] Finally, for each business filter class name, if the object growth rate of the business filter class name is greater than a preset growth rate threshold, it is indicated that the number of the objects corresponding to the business filter class name increases rapidly, and the business filter class name is taken as the second class name.
[0100] It should be noted that the preset growth rate threshold can be 30%, 50%, 70%, etc., and the embodiment of the present application does not limit the preset growth rate threshold, which can be set according to actual conditions.
[0101] It should be noted that the execution order of step S202 and step S203 can be: first executing step S202, and then executing step S203; or first executing step S203, and then executing step S202; or step S202 and step S203 are executed simultaneously. The embodiment of the present application does not limit the execution order of step S202 and step S203, which can be determined according to actual conditions.
[0102] S204: determining the root node object of the third object corresponding to each first class name and each second class name according to at least one reference relationship chain.
[0103] In this step, after the server obtains the first class name and the second class name, in order to determine the class causing the memory overflow more deeply, the server determines the root node object of the third object corresponding to each first class name and each second class name according to at least one reference relationship chain.
[0104] For example, based on the above, Figure 1b the third object corresponding to the first class name is object G, object B and object J, it can be determined that the root node object of object G is object A and object F, the root node object of object B is object A, and the root node object of object J is object I.
[0105] S205: taking the first class name, the second class name, and the class name of each root node object as a target class name, to generate a detection result.
[0106] In this step, after the server determines the root node object, the first type of name, the second type of name, and the type of name of each root node object are generated as target type of name, and a detection result is generated.
[0107] It should be noted that after the server determines the number of third objects corresponding to each service filtering type of name, for each service filtering type of name, the service filtering type of name and the number of third objects corresponding thereto are taken as a first data, and then the first data is sorted in descending order of the number of third objects, to obtain a first sequence, and the first sequence is added to the detection result.
[0108] It should be noted that after the server obtains the object growth of each service filtering type of name, for each service filtering type of name, the service filtering type of name and the object growth corresponding thereto are taken as a second data, and then the second data is sorted in descending order of the object growth, to obtain a second sequence, and the second sequence is added to the detection result.
[0109] It should be noted that after the server obtains the object growth rate of each service filtering type of name, for each service filtering type of name, the service filtering type of name and the object growth rate corresponding thereto are taken as a third data, and then the third data is sorted in descending order of the object growth, to obtain a third sequence, and the third sequence is added to the detection result.
[0110] It should be noted that the server can add each reference relationship chain obtained to the detection result.
[0111] The memory overflow detection method provided in this embodiment accurately determines the type of name causing memory overflow by taking the type of name with a large number of objects, the type of name with a large object growth or growth rate, and the type of name of the root node object as the target type of name, thereby improving the detection accuracy.
[0112] The following is an apparatus embodiment of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the apparatus embodiments of the present application, please refer to the method embodiments of the present application.
[0113] Figure 3 The structure diagram of the memory overflow detection apparatus embodiment provided in the present application is shown in FIG. 3. Figure 3 As shown in FIG. 3, the memory overflow detection apparatus 30 includes:
[0114] The processing module 31 is configured to:
[0115] Every interval of a preset time length, the data in the memory corresponding to the target service application is converted into a heap dump file, and historical detection data is obtained, the historical detection data including the number of first objects corresponding to each preset service filtering type of name;
[0116] parsing the heap dump file to obtain parsed data, the parsed data including object data of a plurality of second objects, the object data of each second object including a class name of the second object and an inter-object reference relationship;
[0117] filtering the plurality of second objects according to the service filtering class names and the class name of each second object to obtain third objects;
[0118] generating at least one reference relationship chain according to the inter-object reference relationship of each third object;
[0119] detecting module 32, configured to determine a detection result according to the class name of each third object, the number of first objects corresponding to each service filtering class name, and the at least one reference relationship chain, the detection result including a target class name causing a memory overflow.
[0120] Further, the detecting module 32 is specifically configured to:
[0121] determine the number of third objects corresponding to each service filtering class name according to the class name of each third object;
[0122] determine a first class name according to the preconfigured overflow threshold corresponding to each service filtering class name and the number of third objects corresponding to each service filtering class name;
[0123] determine a second class name according to the number of third objects corresponding to each service filtering class name and the number of first objects corresponding to each service filtering class name;
[0124] determine a root node object of third objects corresponding to each first class name and each second class name according to the at least one reference relationship chain;
[0125] generate the detection result by taking the first class name, the second class name, and the class name of each root node object as the target class name.
[0126] Further, the detecting module 32 is specifically configured to:
[0127] for each service filtering class name, if the number of third objects corresponding to the service filtering class name is greater than the preconfigured overflow threshold corresponding to the service filtering class name, taking the service filtering class name as the first class name.
[0128] Further, the detecting module 32 is specifically configured to:
[0129] For each business filtering class name, calculate the difference between the number of third objects corresponding to the business filtering class name and the number of first objects corresponding to the business filtering class name, to obtain the object growth of the business filtering class name;
[0130] For each business filtering class name, if the object growth of the business filtering class name is greater than a preset growth threshold, the business filtering class name is taken as the second class name.
[0131] Further, the detection module 32 is specifically configured to:
[0132] For each business filtering class name, calculate the difference between the number of third objects corresponding to the business filtering class name and the number of first objects corresponding to the business filtering class name, to obtain the object growth of the business filtering class name;
[0133] For each business filtering class name, calculate the ratio of the object growth corresponding to the business filtering class name to the number of first objects corresponding to the business filtering class name, to obtain the object growth rate of the business filtering class name;
[0134] For each business filtering class name, if the object growth rate of the business filtering class name is greater than a preset growth rate threshold, the business filtering class name is taken as the second class name.
[0135] Further, the processing module 31 is specifically configured to:
[0136] The data corresponding to the target business application in the memory is converted into a heap dump file through a Java diagnostic tool.
[0137] The memory overflow detection apparatus provided in the embodiment is used to execute the technical solutions in any of the method embodiments, and has similar implementation principles and technical effects, which will not be described herein again.
[0138] Figure 4 A structural schematic diagram of an electronic device is provided in the present application. As shown in the figure, Figure 4 The electronic device 40 includes:
[0139] a processor 41, a memory 42, and a communication interface 43;
[0140] The memory 42 is used to store executable instructions of the processor 41;
[0141] The processor 41 is configured to execute the technical solutions in any of the method embodiments by executing the executable instructions.
[0142] Optionally, the memory 42 can be independent or integrated with the processor 41.
[0143] Optionally, when the memory 42 is a device independent of the processor 41, the electronic device 40 can further include:
[0144] The bus 44, the memory 42 and the communication interface 43 are connected with the processor 41 through the bus 44 and complete communication with each other, and the communication interface 43 is used for communication with other devices.
[0145] Optionally, the communication interface 43 can be implemented by a transceiver. The communication interface is used for communication between the database access device and other devices (for example, a client, a read-write library and a read-only library). The memory can include a random access memory (RAM) and can also include a non-volatile memory, for example, at least one disk memory.
[0146] The bus 44 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0147] The processor described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0148] The electronic device is used for executing the technical solutions in any of the preceding method embodiments, and the implementation principles and technical effects are similar, which will not be described here.
[0149] The embodiment of the present application further provides a readable storage medium, which has a computer program stored thereon, and the computer program is executed by a processor to implement the technical solutions provided by any of the preceding method embodiments.
[0150] The embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is executed by a processor to implement the technical solutions provided by any of the preceding method embodiments.
[0151] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware. The foregoing program can be stored in a computer readable storage medium. The program executes to perform the steps of the above-mentioned method embodiments; and the foregoing storage medium includes various storage media that can store program codes, such as ROM, RAM, magnetic disk or optical disk.
[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A memory overflow detection method, characterized by, The method comprises the following steps: Converting data in the memory corresponding to the target service application into a heap dump file every preset time interval, and obtaining historical detection data, wherein the historical detection data comprises the number of first objects corresponding to each preset service filtering class name; Analyzing the heap dump file to obtain analysis data, wherein the analysis data comprises object data of a plurality of second objects, and the object data of each second object comprises a class name of the second object and an inter-object reference relationship; Filtering the plurality of second objects according to the service filtering class name and the class name of each second object to obtain third objects; Generating at least one reference relationship chain according to the inter-object reference relationship of each third object; Determining the number of third objects corresponding to each service filtering class name according to the class name of each third object; Determining a first class name according to a pre-configured overflow threshold value corresponding to each service filtering class name and the number of third objects corresponding to each service filtering class name; Determining a second class name according to the number of third objects corresponding to each service filtering class name and the number of first objects corresponding to each service filtering class name; Determining root node objects of third objects corresponding to each first class name and each second class name according to the at least one reference relationship chain; Generating a detection result by taking the first class name, the second class name, and the class name of each root node object as target class names causing memory overflow.
2. The method of claim 1, wherein, The method of determining the first class name according to the pre-configured overflow threshold value corresponding to each service filtering class name and the number of third objects corresponding to each service filtering class name comprises the following steps: For each service filtering class name, if the number of third objects corresponding to the service filtering class name is greater than the pre-configured overflow threshold value corresponding to the service filtering class name, the service filtering class name is taken as the first class name.
3. The method of claim 1, wherein, The method of determining the second class name according to the number of third objects corresponding to each service filtering class name and the number of first objects corresponding to each service filtering class name comprises the following steps: For each service filtering class name, calculating the difference between the number of third objects corresponding to the service filtering class name and the number of first objects corresponding to the service filtering class name to obtain the object growth of the service filtering class name; For each service filtering class name, if the object growth of the service filtering class name is greater than a preset growth threshold value, the service filtering class name is taken as the second class name.
4. The method of claim 1, wherein, The method of determining the second class name according to the number of third objects corresponding to each service filtering class name and the number of first objects corresponding to each service filtering class name comprises the following steps: For each service filtering class name, calculating the difference between the number of third objects corresponding to the service filtering class name and the number of first objects corresponding to the service filtering class name to obtain the object growth of the service filtering class name; For each service filtering class name, calculating the ratio of the object growth corresponding to the service filtering class name to the number of first objects corresponding to the service filtering class name to obtain the object growth rate of the service filtering class name; For each business filtering class name, if an object growth rate of the business filtering class name is greater than a preset growth rate threshold, the business filtering class name is taken as the second class name.
5. The method of claim 1, wherein, The converting the data in the memory corresponding to the target business application into a heap dump file comprises: The data in the memory corresponding to the target business application is converted into a heap dump file by a Java diagnostic tool.
6. A memory overflow detection apparatus, characterized by comprising: The method comprises: The processing module is configured to: Every interval preset duration, the data in the memory corresponding to the target business application is converted into a heap dump file, and historical detection data is obtained, the historical detection data comprising a first object quantity corresponding to each preset business filtering class name; The heap dump file is parsed to obtain parsed data, the parsed data comprising object data of a plurality of second objects, the object data of each second object comprising a class name of the second object and an inter-object reference relationship; The plurality of second objects are filtered according to the business filtering class name and the class name of each second object to obtain third objects; At least one reference relationship chain is generated according to the inter-object reference relationship of each third object. The detection module is configured to: The quantity of third objects corresponding to each business filtering class name is determined according to the class name of each third object; A first class name is determined according to a preconfigured overflow threshold corresponding to each business filtering class name and the quantity of third objects corresponding to each business filtering class name; A second class name is determined according to the quantity of third objects corresponding to each business filtering class name and the quantity of first objects corresponding to each business filtering class name; Root node objects of third objects corresponding to each first class name and each second class name are determined according to the at least one reference relationship chain; The first class name, the second class name, and the class name of each root node object are taken as target class names causing memory overflow, and a detection result is generated.
7. An electronic device, comprising: The method comprises: A processor, a memory, and a communication interface; The memory is configured to store executable instructions of the processor; The processor is configured to execute the executable instructions to perform the memory overflow detection method according to any one of claims 1 to 5.
8. A readable storage medium, having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the memory overflow detection method according to any one of claims 1 to 5.
9. A computer program product, characterised in that, The computer program is executed by the processor to implement the memory overflow detection method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Memory leak processing method, apparatus and device, and storage medium
CN110851279A
Memory leak detection method and device and memory analysis and diagnosis method and system
CN117573557A