Method, system and electronic device for self-fusing of java process memory overflow
Through the Java virtual machine memory system, the collection times of the garbage collector are collected and compared, and the Java process is identified and stopped in a timely manner, which solves the problem of timely discovery and processing of the OOM memory overflow problem of the Java process and ensures the stability of the server.
Patent Information
- Application Number
- CN202010705359.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-21
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-07-21
AI Technical Summary
The existing technology makes it difficult to promptly detect and alert operation and maintenance personnel about OOM memory overflow problems when the Java process runs abnormally, causing network abnormalities in the server or non-existent service exceptions.
Through the memory management interface class MemoryMXBean of the Java virtual machine memory system, collect the number of old generation collections collected by the garbage collector PSMarkSweep in each preset time period, compare the number of collections in the current and previous time periods, and add or remove items from the queue. The value will determine the OOM memory overflow problem and stop running the Java process until it reaches the threshold.
Timely discover the OOM memory overflow problem of the Java process, immediately stop running the Java process, and export the overflow memory information to facilitate processing and analysis by operation and maintenance personnel to avoid server exceptions.
Smart Images

Figure CN111831467B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, system and electronic equipment for self-fusing of a java process memory overflow. Background Art
[0002] At present, the memory of each Java process is generally managed through a garbage collection mechanism. When a server is running a Java process, an OOM (Out Of Memory) overflow problem is prone to occur in abnormal scenarios, but the garbage collection mechanism cannot detect and remind the operation and maintenance personnel in time, resulting in network abnormalities or service non-existence abnormalities on the server. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a method, system and electronic device for self-fusing of memory overflow of a java process in view of the deficiencies of the prior art.
[0004] The technical solution of a method for self-fusing of a Java process memory overflow of the present invention is as follows:
[0005] Through the memory management interface class MemoryMXBean of the Java virtual machine memory system, collect the number of times the garbage collector PSMarkSweep recycles the old generation of the running Java process in each preset time period;
[0006] When the number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, a value is added to the preset queue; when the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period, the value at the head of the preset queue is removed;
[0007] When the number of value values in the preset queue is greater than a preset threshold, it is determined that the Java process has an OOM memory overflow problem and the Java process is stopped.
[0008] The beneficial effects of the method for self-fusing of a Java process memory overflow of the present invention are as follows:
[0009] By comparing the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period, and adding or removing the number of value values in the preset queue, the OOM memory overflow problem of the Java process can be discovered in time, and the Java process can be stopped immediately, that is, the running Java process is fuse-broken, so that the operation and maintenance personnel can perform subsequent processing.
[0010] On the basis of the above scheme, the method for self-fusing of a Java process memory overflow of the present invention can also be improved as follows.
[0011] Furthermore, it also includes:
[0012] When it is determined that the Java process has an OOM memory overflow problem, the overflow memory information of the Java process is exported through the tool class sun.tools.jmap.JMap of the Java virtual machine memory system.
[0013] The beneficial effect of adopting the above further solution is: when an OOM memory overflow problem occurs in a running Java process, the overflow memory information of the Java process is exported to facilitate processing and analysis by operation and maintenance personnel.
[0014] Furthermore, the method further includes: when it is determined that the Java process has an OOM memory overflow problem, stopping the operation of the Java virtual machine memory system.
[0015] The technical solution of a java process memory overflow self-fusing system of the present invention is as follows:
[0016] It includes acquisition module, adding and removing module and stopping module;
[0017] The collection module is used to collect the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period through the memory management interface class MemoryMXBean of the Java virtual machine memory system;
[0018] The adding and removing module is used to add a value in the preset queue when the number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, and to remove the value at the head of the preset queue when the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period;
[0019] The stopping module is used to determine that the Java process has an OOM memory overflow problem and stop running the Java process when the number of value values in the preset queue is greater than a preset threshold.
[0020] The beneficial effects of the Java process memory overflow self-fusing system of the present invention are as follows:
[0021] By comparing the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period, and adding or removing the number of value values in the preset queue, the OOM memory overflow problem of the Java process can be discovered in time, and the Java process can be stopped immediately, that is, the running Java process is fuse-broken, so that the operation and maintenance personnel can perform subsequent processing.
[0022] On the basis of the above scheme, the method for self-fusing of a Java process memory overflow of the present invention can also be improved as follows.
[0023] Furthermore, it also includes an export module, which is used to export the overflow memory information of the Java process through the tool class sun.tools.jmap.JMap of the Java virtual machine memory system when it is determined that the Java process has an OOM memory overflow problem.
[0024] The beneficial effect of adopting the above further solution is: when an OOM memory overflow problem occurs in a running Java process, the overflow memory information of the Java process is exported to facilitate processing and analysis by operation and maintenance personnel.
[0025] Furthermore, it also includes a stop operation module, which is used to stop the operation of the Java virtual machine memory system when it is determined that the Java process has an OOM memory overflow problem.
[0026] The technical solution of an electronic device of the present invention is as follows:
[0027] The invention comprises a memory, a processor and a program stored in the memory and running on the processor, wherein when the processor executes the program, the steps of a method for self-fusing of memory overflow of a Java process as described in any one of the above items are implemented.
[0028] The beneficial effects of an electronic device of the present invention are as follows:
[0029] By comparing the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period, and adding or removing the number of value values in the preset queue, the OOM memory overflow problem of the Java process can be discovered in time, and the Java process can be stopped immediately, that is, the running Java process is fuse-broken, so that the operation and maintenance personnel can perform subsequent processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is one of the flow charts of a method for self-fusing of a Java process memory overflow according to an embodiment of the present invention;
[0031] Figure 2 This is a second flow chart of a method for self-fusing of a Java process memory overflow according to an embodiment of the present invention;
[0032] Figure 3 A schematic diagram of the structure of a system for self-fusing of a Java process memory overflow according to an embodiment of the present invention;
[0033] Figure 4 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] like Figure 1 As shown, a method for self-fusing of a Java process memory overflow according to an embodiment of the present invention includes the following steps:
[0035] S1. Using the memory management interface class MemoryMXBean of the Java virtual machine memory system, collect the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period;
[0036] S2. When the number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, add a value value in the preset queue; when the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period, remove the value value at the head of the preset queue;
[0037] S3: When the number of the value values in the preset queue is greater than a preset threshold, it is determined that the Java process has an OOM memory overflow problem, and the Java process is stopped.
[0038] By comparing the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period, and adding or removing the number of value values in the preset queue, the OOM memory overflow problem of the Java process can be discovered in time, and the Java process can be stopped immediately, that is, the running Java process is fuse-broken, so that the operation and maintenance personnel can perform subsequent processing.
[0039] Among them, an agent can be created for the Java virtual machine memory system, and a thread can be created before the Java process of the server runs. The thread is used to collect the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period through the memory management interface class MemoryMXBean of the Java virtual machine memory system;
[0040] The number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, which includes two situations: the number of recycling times in the current preset time period is greater than the number of recycling times in the previous preset time period, and the number of recycling times in the current preset time period is less than the number of recycling times in the previous preset time period. In this case, it can be determined that the Java virtual machine memory system has performed a Full GC operation in the current preset time period, and a value value is added to the preset queue;
[0041] When the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period, it can be determined that the Java virtual machine memory system has not performed a Full GC operation in the current preset time period, and the value at the head position of the preset queue is removed;
[0042] The value can be understood as a symbol such as a string or number used to occupy a place in the preset queue;
[0043] Among them, it can be understood that, assuming that the preset time period is 1 hour, when the current time is 12:30, the current time period is 12:00 to 13:00, then the previous time period is 11:00 to 12:00, when the current time is 13:30, then the previous time period is 12:00 to 13:00, that is, the current time period is constantly changing, when the number of recycling times in multiple consecutive preset time periods is compared in the above manner, until the number of value values of the preset queue is greater than the preset threshold, it is determined that the Java process has an OOM memory overflow problem, and the Java process is stopped; otherwise, it is determined that the Java process does not have an OOM memory overflow problem, that is, the Java process can run normally.
[0044] It is understandable that when an OOM memory overflow problem occurs in a Java process, the Java process is stopped immediately, that is, the running Java process is blown. At this time, the server can automatically detect that the running Java process has been blown, and will send a prompt to the maintenance personnel through a pop-up window, etc., to remind the operation and maintenance personnel that the Java process has an OOM memory overflow problem and has been blown, so that the operation and maintenance personnel can perform subsequent processing; or, when the running Java process is blown, a window containing the information that the Java process has an OOM memory overflow problem and has been blown is popped up by triggering an event, so that the operation and maintenance personnel can perform subsequent processing.
[0045] Preferably, in the above technical solution, if Figure 2 As shown, it also includes:
[0046] S4. When it is determined that the Java process has an OOM memory overflow problem, the overflow memory information of the Java process is exported through the tool class sun.tools.jmap.JMap of the Java virtual machine memory system.
[0047] Among them, the overflow memory information includes heap overflow information, stack overflow information, etc. When an OOM memory overflow problem occurs in a running Java process, the heap overflow information, stack overflow information, etc. of the Java process are exported to facilitate processing and analysis by operation and maintenance personnel.
[0048] Preferably, in the above technical solution, it also includes:
[0049] S40: When it is determined that the Java process has an OOM memory overflow problem, stop running the Java virtual machine memory system.
[0050] The Java virtual machine memory system is stopped by executing the exit function of the Java virtual machine memory system.
[0051] In the above embodiments, although the steps are numbered S1, S2, etc., these are only specific embodiments given in the present application. Those skilled in the art may adjust the execution order of S1, S2, etc. according to actual conditions, which is also within the scope of protection of the present invention.
[0052] like Figure 3 As shown, a system 200 for self-fusing of a Java process memory overflow according to an embodiment of the present invention includes a collection module 210, an addition and removal module 220, and a stop module 230;
[0053] The collection module 210 is used to collect the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period through the memory management interface class MemoryMXBean of the Java virtual machine memory system;
[0054] The adding and removing module 220 is used to add a value in the preset queue when the number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, and to remove the value at the head of the preset queue when the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period;
[0055] The stopping module 230 is used to determine that the Java process has an OOM memory overflow problem and stop running the Java process when the number of value values in the preset queue is greater than a preset threshold.
[0056] By comparing the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period, and adding or removing the number of value values in the preset queue, the OOM memory overflow problem of the Java process can be discovered in time, and the Java process can be stopped immediately, that is, the running Java process is fuse-broken, so that the operation and maintenance personnel can perform subsequent processing.
[0057] Preferably, the above technical solution further includes an export module, which is used to export the overflow memory information of the Java process through the tool class sun.tools.jmap.JMap of the Java virtual machine memory system when it is determined that the Java process has an OOM memory overflow problem.
[0058] When an OOM memory overflow problem occurs in a running Java process, the overflow memory information of the Java process is exported to facilitate processing and analysis by operation and maintenance personnel.
[0059] Preferably, the above technical solution further includes a stop operation module, wherein the stop operation module is used to stop the operation of the Java virtual machine memory system when it is determined that the Java process has an OOM memory overflow problem.
[0060] The above-mentioned parameters and steps of each unit module in the system 200 of a java process memory overflow self-fusing of the present invention to implement corresponding functions can refer to the parameters and steps in the embodiment of the method for a java process memory overflow self-fusing above, and will not be repeated here.
[0061] like Figure 4 As shown, an electronic device 300 of an embodiment of the present invention includes a memory 310, a processor 320, and a program 330 stored in the memory 310 and running on the processor 320. When the processor 320 executes the program 330, it implements any of the steps of the above-mentioned method of self-fusing of a Java process memory overflow.
[0062] By comparing the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period, and adding or removing the number of value values in the preset queue, the OOM memory overflow problem of the Java process can be discovered in time, and the Java process can be stopped immediately, that is, the running Java process is fuse-broken, so that the operation and maintenance personnel can perform subsequent processing.
[0063] Among them, the electronic device 300 can be a computer, a mobile phone, etc. Correspondingly, its program 330 is computer software or a mobile phone APP, etc., and the above-mentioned parameters and steps in an electronic device 300 of the present invention can refer to the parameters and steps in the embodiment of a java process memory overflow self-fusing method mentioned above, which will not be repeated here.
[0064] In the present invention, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0065] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0066] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for self-fusing when a Java process memory overflows, characterized in that: include: Through the memory management interface class MemoryMXBean of the Java virtual machine memory system, collect the number of times the garbage collector PSMarkSweep recycles the old generation of the running Java process in each preset time period; When the number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, a value is added to the preset queue; when the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period, the value at the head of the preset queue is removed; When the number of value values in the preset queue is greater than a preset threshold, it is determined that the Java process has an OOM memory overflow problem and the Java process is stopped.
2. A method for self-fusing of a Java process memory overflow according to claim 1, characterized in that: Also includes: When it is determined that the Java process has an OOM memory overflow problem, the overflow memory information of the Java process is exported through the tool class sun.tools.jmap.JMap of the Java virtual machine memory system.
3. A method for self-fusing of a Java process memory overflow according to claim 1 or 2, characterized in that: Also includes: When it is determined that the Java process has an OOM memory overflow problem, the Java virtual machine memory system is stopped.
4. A system for self-fusing when a Java process memory overflows, characterized in that: It includes acquisition module, adding and removing module and stopping module; The collection module is used to collect the number of times the garbage collector PS MarkSweep recycles the old generation of the running Java process in each preset time period through the memory management interface class MemoryMXBean of the Java virtual machine memory system; The adding and removing module is used to add a value in the preset queue when the number of recycling times in the current preset time period is different from the number of recycling times in the previous preset time period, and to remove the value at the head of the preset queue when the number of recycling times in the current preset time period is the same as the number of recycling times in the previous preset time period; The stopping module is used to determine that the Java process has an OOM memory overflow problem and stop running the Java process when the number of value values in the preset queue is greater than a preset threshold.
5. A Java process memory overflow self-fusing system according to claim 4, characterized in that: It also includes an export module, which is used to export the overflow memory information of the Java process through the tool class sun.tools.jmap.JMap of the Java virtual machine memory system when it is determined that the Java process has an OOM memory overflow problem.
6. A Java process memory overflow self-fusing system according to claim 4 or 5, characterized in that: It also includes a stop operation module, which is used to stop the Java virtual machine memory system when it is determined that the Java process has an OOM memory overflow problem.
7. An electronic device comprising a memory, a processor, and a program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the steps of a method for self-fusing of memory overflow of a Java process as described in any one of claims 1 to 3 are implemented.
