Movatterモバイル変換


[0]ホーム

URL:


CN118132379A - A memory overflow event monitoring method, device, equipment and medium - Google Patents

A memory overflow event monitoring method, device, equipment and medium
Download PDF

Info

Publication number
CN118132379A
CN118132379ACN202410265603.8ACN202410265603ACN118132379ACN 118132379 ACN118132379 ACN 118132379ACN 202410265603 ACN202410265603 ACN 202410265603ACN 118132379 ACN118132379 ACN 118132379A
Authority
CN
China
Prior art keywords
memory overflow
event
function
time period
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410265603.8A
Other languages
Chinese (zh)
Inventor
孟曦东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Bo Hongyuan Data Polytron Technologies Inc
Original Assignee
Beijing Bo Hongyuan Data Polytron Technologies Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Bo Hongyuan Data Polytron Technologies IncfiledCriticalBeijing Bo Hongyuan Data Polytron Technologies Inc
Priority to CN202410265603.8ApriorityCriticalpatent/CN118132379A/en
Publication of CN118132379ApublicationCriticalpatent/CN118132379A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明公开了一种内存溢出事件的监测方法、装置、设备及介质,涉及内存溢出监测技术领域。该方法包括:在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。本技术方案,提高了对内存溢出事件的监测效率。

The present invention discloses a method, device, equipment and medium for monitoring memory overflow events, and relates to the technical field of memory overflow monitoring. The method comprises: in the operation process of a virtual machine, for each time period, obtaining the operation parameters of the virtual machine in the time period, and the operation parameters of the host to which the virtual machine belongs in the time period; according to the operation parameters of the virtual machine in the time period and the operation parameters of the host in the time period, determining at least one target memory overflow monitoring function in the time period from candidate memory overflow monitoring functions, and determining the callback function corresponding to each target memory overflow monitoring function; calling each target memory overflow function and each callback function, so as to monitor the memory overflow event occurring in the virtual machine in the time period through each target memory overflow function, and collecting the event information of the memory overflow event monitored in the time period through each callback function. This technical scheme improves the monitoring efficiency of memory overflow events.

Description

Translated fromChinese
一种内存溢出事件的监测方法、装置、设备及介质A memory overflow event monitoring method, device, equipment and medium

技术领域Technical Field

本发明涉及内存溢出监测技术领域,尤其涉及一种内存溢出事件的监测方法、装置、设备及介质。The present invention relates to the technical field of memory overflow monitoring, and in particular to a method, device, equipment and medium for monitoring a memory overflow event.

背景技术Background technique

在java软件开发中可以通过编写异常捕获代码的方式进行异常事件的捕获。当程序中编写有异常捕获代码,可以在程序发生异常时,捕获异常并在捕获代码中处理异常。In Java software development, you can capture abnormal events by writing exception capture code. When an exception capture code is written in the program, you can capture the exception when an exception occurs in the program and handle the exception in the capture code.

通常情况下,异常捕获代码只能捕获其所在位置发生的异常,无法捕获其他位置发生的异常,若在程序中的每个位置都编写异常捕获代码,则会导致程序的运行效率较低,占用资源较多。Normally, exception catching code can only catch exceptions that occur at its location, and cannot catch exceptions that occur at other locations. If exception catching code is written at every location in the program, the program will run inefficiently and occupy more resources.

发明内容Summary of the invention

本发明提供了一种内存溢出事件的监测方法、装置、设备及介质,以提监测内存溢出事件的效率。The present invention provides a method, device, equipment and medium for monitoring a memory overflow event, so as to improve the efficiency of monitoring the memory overflow event.

第一方面,本发明提供了一种内存溢出事件的监测方法,包括:In a first aspect, the present invention provides a method for monitoring a memory overflow event, comprising:

在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;During the operation of the virtual machine, for each time period, the operation parameters of the virtual machine in the time period and the operation parameters of the host to which the virtual machine belongs in the time period are obtained;

根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机中预置的函数;According to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, at least one target memory overflow monitoring function within the time period is determined from the candidate memory overflow monitoring functions, and a callback function corresponding to each target memory overflow monitoring function is determined; wherein the candidate memory overflow monitoring function is a function preset in the virtual machine;

调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。Each target memory overflow function and each callback function are called to monitor memory overflow events occurring in the virtual machine within a time period through each target memory overflow function, and event information of the memory overflow events monitored within the time period is collected through each callback function.

第二方面,本发明还提供了一种内存溢出事件的监测装置,包括:In a second aspect, the present invention further provides a monitoring device for a memory overflow event, comprising:

参数获取模块,用于在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;The parameter acquisition module is used to acquire the operating parameters of the virtual machine in each time period and the operating parameters of the host to which the virtual machine belongs in the time period during the operation of the virtual machine;

函数确定模块,用于根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机提供的开发调试函数;A function determination module, used to determine at least one target memory overflow monitoring function within a time period from candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, and determine the callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a development and debugging function provided by the virtual machine;

函数调用模块,用于调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。The function calling module is used to call each target memory overflow function and each callback function to monitor the memory overflow events occurring in the virtual machine within a time period through each target memory overflow function, and to collect event information of the memory overflow events monitored within the time period through each callback function.

第三方面,本发明实施例还提供了一种电子设备,包括:In a third aspect, an embodiment of the present invention further provides an electronic device, including:

至少一个处理器;以及at least one processor; and

与至少一个处理器通信连接的存储器;其中a memory communicatively coupled to at least one processor; wherein

存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行本发明任一实施例所提供的内存溢出事件的监测方法。The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute the memory overflow event monitoring method provided by any embodiment of the present invention.

第四方面,本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机指令,计算机指令用于使处理器执行时实现本发明任一实施例的内存溢出事件的监测方法。In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for monitoring a memory overflow event of any embodiment of the present invention when executing the computer instructions.

本发明实施例通过在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机中预置的函数;调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息,相较于现有技术仅能监测到异常捕获代码对应位置处的内存溢出事件的技术方案,本发明实施例的技术方案通过调用虚拟机中预置的目标内存溢出函数与对应的回调函数,无需插入异常捕获代码,也可对多个位置处的内存溢出事件进行监测,提高了监测效率;并且通过部署在虚拟机中的探针,与虚拟机中的程序并行执行,能够周期性的根据虚拟机运行函数和主机运行参数,确定对应时间周期的目标内存溢出监测函数,实现对目标内存溢出监测函数的周期性调整,避免在任意时间周期中均调用全部的候选内存溢出监测函数导致资源浪费,从而进一步提高对内存溢出事件的监测效率。The embodiment of the present invention obtains, for each time period during the operation of the virtual machine, the operating parameters of the virtual machine within the time period and the operating parameters of the host to which the virtual machine belongs within the time period; determines at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, and determines a callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a function preset in the virtual machine; calls each target memory overflow function and each callback function to monitor the memory overflow event occurring in the virtual machine within the time period through each target memory overflow function, and collects event information of the memory overflow event monitored within the time period through each callback function, Compared with the technical solutions in the prior art that can only monitor memory overflow events at the position corresponding to the exception capture code, the technical solution of the embodiment of the present invention can monitor memory overflow events at multiple positions by calling the target memory overflow function and the corresponding callback function preset in the virtual machine, without inserting the exception capture code, thereby improving the monitoring efficiency; and by deploying the probe in the virtual machine, it is executed in parallel with the program in the virtual machine, and can periodically determine the target memory overflow monitoring function of the corresponding time period according to the virtual machine running function and the host running parameters, thereby realizing periodic adjustment of the target memory overflow monitoring function, avoiding calling all candidate memory overflow monitoring functions in any time period to cause waste of resources, thereby further improving the monitoring efficiency of memory overflow events.

应当理解,本部分所描述的内容并非旨在标识本发明的实施例的关键或重要特征,也不用于限制本发明的范围。本发明的其它特征将通过以下的说明书而变得容易理解。It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

图1是根据本发明实施例一提供的一种内存溢出事件的监测方法的流程图;FIG1 is a flow chart of a method for monitoring a memory overflow event according to a first embodiment of the present invention;

图2是根据本发明实施例二提供的一种内存溢出事件的监测方法的流程图;FIG2 is a flow chart of a method for monitoring a memory overflow event according to a second embodiment of the present invention;

图3是根据本发明实施例三提供的一种内存溢出事件的监测方法的流程图;3 is a flow chart of a method for monitoring a memory overflow event according to a third embodiment of the present invention;

图4是根据本发明实施例四提供的一种内存溢出事件的监测装置的结构示意图;FIG4 is a schematic diagram of the structure of a monitoring device for memory overflow events provided according to a fourth embodiment of the present invention;

图5是实现本发明实施例的内存溢出事件的监测方法的电子设备的结构示意图。FIG. 5 is a schematic diagram of the structure of an electronic device that implements the method for monitoring a memory overflow event according to an embodiment of the present invention.

具体实施方式Detailed ways

为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”和“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first" and "second" and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

本发明实施例的技术方案中,所涉及的运行参数等的获取、存储和应用等,均符合相关法律法规的规定,且不违背公序良俗。In the technical solution of the embodiment of the present invention, the acquisition, storage and application of the operating parameters involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

实施例一Embodiment 1

图1为本发明实施例一提供的一种内存溢出事件的监测方法的流程图,本实施例可适用于对内存溢出事件的进行监测的情况,该方法可以由一种内存溢出事件的监测装置来执行,该内存溢出事件的监测装置可以采用硬件和/或软件的形式实现,并具体配置于电子设备中,例如服务器中。Figure 1 is a flow chart of a method for monitoring a memory overflow event provided in Example 1 of the present invention. This embodiment is applicable to the situation of monitoring a memory overflow event. The method can be executed by a device for monitoring a memory overflow event. The device for monitoring a memory overflow event can be implemented in the form of hardware and/or software and specifically configured in an electronic device, such as a server.

参见图1所示的内存溢出事件的监测方法,由部署在虚拟机中的探针执行,包括:Referring to the memory overflow event monitoring method shown in FIG1 , the method is executed by a probe deployed in a virtual machine and includes:

S101、在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数。S101. During the operation of the virtual machine, for each time period, obtaining the operation parameters of the virtual machine in the time period and the operation parameters of the host to which the virtual machine belongs in the time period.

本实施例中,虚拟机可以是Java虚拟机(Java Virtual Machine,JVM)用于将Java源代码编译成字节码并执行。虚拟机的运行参数可以用于表征虚拟机的运行状态;虚拟机的运行参数可以包括但不限于堆内存使用率、垃圾回收处理器使用率、最大线程数和运行线程数等中的至少一种。虚拟机所属主机可以是运行虚拟机的设备;虚拟机所属主机的运行参数可以用于表征主机的运行状态;主机的运行参数可以包括但不限于内存使用率、处理器使用率和最大进程数等。In this embodiment, the virtual machine may be a Java Virtual Machine (JVM) for compiling Java source code into bytecode and executing it. The operating parameters of the virtual machine may be used to characterize the operating state of the virtual machine; the operating parameters of the virtual machine may include but are not limited to at least one of heap memory usage, garbage collection processor usage, maximum number of threads, and number of running threads. The host to which the virtual machine belongs may be a device running the virtual machine; the operating parameters of the host to which the virtual machine belongs may be used to characterize the operating state of the host; the operating parameters of the host may include but are not limited to memory usage, processor usage, and maximum number of processes.

其中,垃圾回收处理器使用率可以理解为虚拟机的垃圾回收(GarbageCollection)操作对处理器的使用率;运行线程数可以理解为虚拟机中正在运行的线程的数量。需要说明的是,时间周期的时长可以由技术人员根据实际需求或实践经验自主设定,本发明对此不做限定。The garbage collection processor utilization rate can be understood as the utilization rate of the processor by the garbage collection (Garbage Collection) operation of the virtual machine; the number of running threads can be understood as the number of threads running in the virtual machine. It should be noted that the duration of the time period can be independently set by the technician according to actual needs or practical experience, and the present invention does not limit this.

S102、根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机中预置的函数。S102. According to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, determine at least one target memory overflow monitoring function within the time period from the candidate memory overflow monitoring functions, and determine the callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a pre-set function in the virtual machine.

本实施例中,目标内存溢出监测函数可以是时间周期内需调用的候选内存溢出监测函数。候选内存溢出监测函数可以是虚拟机中内置的,用于监测并生成内存溢出事件的函数;回调函数可以是用于采集内存溢出事件的事件信息的函数。内存溢出事件(Out ofMemory,OOM)可以是指内存溢出或耗尽的事件。事件信息可以是内存溢出事件的属性信息,事件信息可以包括但不限于产生内存溢出事件的时间和发生内存溢出事件的线程标识等信息;其中,线程标识可以用于唯一标识对应的线程。In this embodiment, the target memory overflow monitoring function may be a candidate memory overflow monitoring function that needs to be called within a time period. The candidate memory overflow monitoring function may be a function built into the virtual machine for monitoring and generating memory overflow events; the callback function may be a function for collecting event information of memory overflow events. A memory overflow event (Out of Memory, OOM) may refer to an event of memory overflow or exhaustion. The event information may be attribute information of the memory overflow event, and the event information may include but is not limited to information such as the time when the memory overflow event was generated and the thread identifier of the memory overflow event; wherein, the thread identifier may be used to uniquely identify the corresponding thread.

具体的,采用一定的算法,根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数;针对每一目标内存溢出监测函数,从预设的回调函数配置信息中,查找该目标内存溢出监测函数对应的回调函数。Specifically, a certain algorithm is adopted to determine at least one target memory overflow monitoring function within the time period from the candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period; for each target memory overflow monitoring function, the callback function corresponding to the target memory overflow monitoring function is searched from the preset callback function configuration information.

S103、调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。S103, calling each target memory overflow function and each callback function, so as to monitor the memory overflow event of the virtual machine within the time period through each target memory overflow function, and collecting the event information of the memory overflow event monitored within the time period through each callback function.

在一个可选实施例中,调用各目标内存溢出函数,并设置内存溢出事件的事件通知函数,以在目标内存溢出函数监测到内存溢出事件时,调用回调函数采集监测到的内存溢出事件的事件信息。In an optional embodiment, each target memory overflow function is called, and an event notification function of the memory overflow event is set, so that when the target memory overflow function detects a memory overflow event, the callback function is called to collect event information of the monitored memory overflow event.

在一个可选实施例中,本发明实施例的探针可以是JVMTI Agent(Java VirtualMachine Tool Interface Agent,虚拟机工具接口代理程序)。在虚拟机的程序启动命令中包括探针的存储路径,以在虚拟机启动程序时初始化探针,从而使探针与程序并行运行。In an optional embodiment, the probe of the embodiment of the present invention can be a JVMTI Agent (Java Virtual Machine Tool Interface Agent). The storage path of the probe is included in the program startup command of the virtual machine to initialize the probe when the virtual machine starts the program, so that the probe and the program run in parallel.

在一个可选实施例后,探针还可以针对每一时间周期,在该时间周期中检测是否接收到监测停止信息;若未接收到监测停止信息,则检测是否采集到内存溢出事件的事件信息;若采集到内存溢出事件的事件信息,则将事件信息到并将采集到的事件信息发送到事件监控端,并将探针端的事件信息删除,以腾出存储空间用于存储该时间周期之后的时间周期中采集到的事件信;若未采集到内存溢出事件信息,则不进行发送操作;In an optional embodiment, the probe can also detect whether the monitoring stop information is received in each time period; if the monitoring stop information is not received, detect whether the event information of the memory overflow event is collected; if the event information of the memory overflow event is collected, the event information is sent to the event monitoring end, and the event information on the probe end is deleted to free up storage space for storing the event information collected in the time period after the time period; if the memory overflow event information is not collected, the sending operation is not performed;

若接收到监测停止信息,则检测是否采集到内存溢出事件的事件信息;若采集到内存溢出事件的事件信息,则将事件信息到并将采集到的事件信息发送到事件监控端,并将探针端的事件信息删除,以腾出存储空间用于存储该时间周期之后的时间周期中采集到的事件信;若未采集到内存溢出事件信息,则停止对目标内存溢出监测函数的调用,并结束对内存溢出事件的监测操作。If the monitoring stop information is received, it is checked whether the event information of the memory overflow event is collected; if the event information of the memory overflow event is collected, the event information is sent to the event monitoring end, and the event information on the probe end is deleted to free up storage space for storing the event information collected in the time period after this time period; if the memory overflow event information is not collected, the call to the target memory overflow monitoring function is stopped, and the monitoring operation of the memory overflow event is ended.

可以理解的是,采用上述技术方案,探针在虚拟机的运行过程中,并行的确定并调用目标内存溢出监测函数,以及发送事件信息,相较于现有技术中插入异常捕获代码的方式,探针不占用虚拟机的内存,而是占用虚拟机所属主机的内存,能够避免因占用虚拟机内存对内存溢出事件进行捕获,导致虚拟机内存严重不足崩溃,进而导致内存溢出事件捕获失败的情况发生,提高了监测内存溢出事件以及发送内存溢出事件的事件信息的成功率。It can be understood that by adopting the above-mentioned technical scheme, the probe determines and calls the target memory overflow monitoring function and sends event information in parallel during the operation of the virtual machine. Compared with the method of inserting exception capture code in the prior art, the probe does not occupy the memory of the virtual machine, but occupies the memory of the host to which the virtual machine belongs. This can avoid the capture of memory overflow events due to occupying the virtual machine's memory, causing the virtual machine to crash due to severe lack of memory, and then causing the failure of memory overflow event capture, thereby improving the success rate of monitoring memory overflow events and sending event information of memory overflow events.

本发明实施例通过在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机中预置的函数;调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息,相较于现有技术仅能监测到异常捕获代码对应位置处的内存溢出事件的技术方案,本发明实施例的技术方案通过调用虚拟机中预置的目标内存溢出函数与对应的回调函数,虚拟机内部存在多个埋点,无需插入异常捕获代码,也可通过探针对多个位置处的内存溢出事件进行监测,提高了监测效率;并且通过部署在虚拟机中的探针,与虚拟机中的程序并行执行,能够周期性的根据虚拟机运行函数和主机运行参数,确定对应时间周期的目标内存溢出监测函数,实现对目标内存溢出监测函数的周期性调整,避免在任意时间周期中均调用全部的候选内存溢出监测函数导致资源浪费,从而进一步提高对内存溢出事件的监测效率。The embodiment of the present invention obtains, for each time period during the operation of the virtual machine, the operating parameters of the virtual machine within the time period and the operating parameters of the host to which the virtual machine belongs within the time period; determines at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, and determines a callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a function preset in the virtual machine; calls each target memory overflow function and each callback function to monitor the memory overflow event occurring in the virtual machine within the time period through each target memory overflow function, and collects event information of the memory overflow event monitored within the time period through each callback function. Compared with the prior art which can only A technical solution for monitoring memory overflow events at positions corresponding to exception capture codes. The technical solution of an embodiment of the present invention calls a target memory overflow function and a corresponding callback function preset in a virtual machine. There are multiple embedding points inside the virtual machine, and there is no need to insert an exception capture code. Memory overflow events at multiple positions can also be monitored by probes, thereby improving monitoring efficiency. Moreover, by deploying the probe in the virtual machine and executing it in parallel with the program in the virtual machine, the target memory overflow monitoring function of the corresponding time period can be periodically determined according to the virtual machine running function and the host running parameters, thereby realizing periodic adjustment of the target memory overflow monitoring function, thereby avoiding calling all candidate memory overflow monitoring functions in any time period and causing waste of resources, thereby further improving the monitoring efficiency of memory overflow events.

实施例二Embodiment 2

图2为本发明实施例二提供的一种内存溢出事件的监测方法的流程图,本发明实施例在上述实施例的技术方案的基础上,对目标内存溢出监测函数的确定操作进行了优化改进。FIG2 is a flow chart of a method for monitoring a memory overflow event provided in a second embodiment of the present invention. The embodiment of the present invention optimizes and improves the determination operation of the target memory overflow monitoring function based on the technical solution of the above embodiment.

进一步地,将“根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数”细化为“根据虚拟机的运行参数和主机的运行参数,确定至少一个资源枯竭关联参数,以及至少一个异常错误关联参数;确定各资源枯竭关联参数与对应的第一阈值之间的比较结果,以及确定各异常错误关联参数与第二阈值之间的比较结果;根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数”,以完善目标内存溢出监测函数的确定操作。Further, "determine at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions based on the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period" is refined into "determine at least one resource exhaustion associated parameter and at least one abnormal error associated parameter based on the operating parameters of the virtual machine and the operating parameters of the host; determine the comparison result between each resource exhaustion associated parameter and the corresponding first threshold, and determine the comparison result between each abnormal error associated parameter and the second threshold; determine at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions based on the comparison result of each resource exhaustion associated parameter and the comparison result of each abnormal error associated parameter" to improve the determination operation of the target memory overflow monitoring function.

需要说明的是,在本发明实施例中未详述部分,可参见前述实施例的表述。It should be noted that, for the parts not described in detail in the embodiments of the present invention, reference may be made to the descriptions in the aforementioned embodiments.

参见图2所示的内存溢出事件的监测方法,包括:Referring to the memory overflow event monitoring method shown in FIG2 , the method includes:

S201、在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数。S201. During the operation of the virtual machine, for each time period, obtain the operation parameters of the virtual machine in the time period and the operation parameters of the host to which the virtual machine belongs in the time period.

S202、根据虚拟机的运行参数和主机的运行参数,确定至少一个资源枯竭关联参数,以及至少一个异常错误关联参数。S202: Determine at least one resource exhaustion-related parameter and at least one abnormal error-related parameter according to the operating parameters of the virtual machine and the operating parameters of the host.

本实施例中,资源枯竭关联参数可以是能够导致虚拟机和/或主机出现资源枯竭的运行参数;其中,资源枯竭可以理解为未被占用的空闲资源无法满足虚拟机或主机申请的需求资源的情况;异常错误关联参数可以是能够导致虚拟机或主机出现运行错误的运行参数。In this embodiment, the resource exhaustion associated parameters may be operating parameters that may cause resource exhaustion in the virtual machine and/or the host; wherein resource exhaustion may be understood as a situation where unoccupied idle resources cannot meet the required resources requested by the virtual machine or the host; the abnormal error associated parameters may be operating parameters that may cause operating errors in the virtual machine or the host.

具体的,将最大线程数与最大进程数之间的最小值确定为目标线程数,并确定运行线程数与目标线程数之间的比值,并将确定的比值作为线程使用率;将线程使用率和堆内存使用率作为资源枯竭关联参数;将所述垃圾回收处理器使用率、所述内存使用率和所述处理器使用率确定为异常错误关联参数。Specifically, the minimum value between the maximum number of threads and the maximum number of processes is determined as the target number of threads, and the ratio between the number of running threads and the target number of threads is determined, and the determined ratio is used as the thread utilization rate; the thread utilization rate and the heap memory utilization rate are used as resource exhaustion associated parameters; the garbage collection processor utilization rate, the memory utilization rate and the processor utilization rate are determined as abnormal error associated parameters.

S203、确定各资源枯竭关联参数与对应的第一阈值之间的比较结果,以及确定各异常错误关联参数与第二阈值之间的比较结果。S203: Determine a comparison result between each resource exhaustion-related parameter and a corresponding first threshold, and determine a comparison result between each abnormal error-related parameter and a second threshold.

需要说明的是,各资源枯竭关联参数对应的第一阈值,以及第二阈值可以由技术人员根据实际需求或实践经验自主设定。It should be noted that the first threshold and the second threshold corresponding to each resource exhaustion associated parameter can be independently set by technical personnel according to actual needs or practical experience.

S204、根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机中预置的函数。S204. According to the comparison results of each resource exhaustion associated parameter and the comparison results of each abnormal error associated parameter, determine at least one target memory overflow monitoring function within a time period from the candidate memory overflow monitoring functions, and determine the callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a pre-set function in the virtual machine.

具体的,采用一定的算法,根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数。Specifically, a certain algorithm is used to determine at least one target memory overflow monitoring function within a time period from candidate memory overflow monitoring functions according to comparison results of various resource exhaustion associated parameters and comparison results of various abnormal error associated parameters.

可选的,候选内存溢出监测函数包括至少一个资源枯竭监测函数和异常监测函数;根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,包括:针对每一资源枯竭关联参数的比较结果,若资源枯竭关联参数的比较结果为资源枯竭关联参数大于或等于资源枯竭关联参数对应的第一阈值,则将资源枯竭关联参数对应的资源枯竭监测函数确定为目标内存溢出监测函数;若存在至少一个异常错误关联参数的比较结果为异常错误关联参数大于或等于第二阈值,则将异常监测函数确定为目标内存溢出监测函数。Optionally, the candidate memory overflow monitoring function includes at least one resource depletion monitoring function and an abnormal monitoring function; based on the comparison results of each resource depletion associated parameter and the comparison results of each abnormal error associated parameter, at least one target memory overflow monitoring function within a time period is determined from the candidate memory overflow monitoring function, including: for each resource depletion associated parameter comparison result, if the resource depletion associated parameter comparison result is that the resource depletion associated parameter is greater than or equal to a first threshold corresponding to the resource depletion associated parameter, then the resource depletion monitoring function corresponding to the resource depletion associated parameter is determined as the target memory overflow monitoring function; if there is at least one abnormal error associated parameter comparison result that the abnormal error associated parameter is greater than or equal to a second threshold, then the abnormal monitoring function is determined as the target memory overflow monitoring function.

其中,资源枯竭监测函数可以是对因资源枯竭导致的内存溢出事件进行监测的函数;资源枯竭监测函数包括堆内存资源枯竭监测函数和线程资源枯竭监测函数。异常监测函数可以是对因异常错误导致的内存溢出事件进行监测的函数;具体的,异常监测函数为can_generate_exception_events函数。线程使用率对应的资源枯竭监测函数可以是线程资源枯竭监测函数(can_generate_resource_exhaustion_threads_events函数);堆内存使用率对应的资源枯竭函数可以是堆内存资源枯竭监测函数(can_generate_resource_exhaustion_heap_events函数)。Among them, the resource exhaustion monitoring function can be a function for monitoring memory overflow events caused by resource exhaustion; the resource exhaustion monitoring function includes a heap memory resource exhaustion monitoring function and a thread resource exhaustion monitoring function. The exception monitoring function can be a function for monitoring memory overflow events caused by abnormal errors; specifically, the exception monitoring function is the can_generate_exception_events function. The resource exhaustion monitoring function corresponding to the thread utilization rate can be a thread resource exhaustion monitoring function (can_generate_resource_exhaustion_threads_events function); the resource exhaustion function corresponding to the heap memory utilization rate can be a heap memory resource exhaustion monitoring function (can_generate_resource_exhaustion_heap_events function).

具体的,若线程使用率大于或等于线程使用率对应的第一阈值,则将线程资源枯竭监测函数确定为目标内存溢出监测函数;若堆内存使用率大于或等于堆内存使用率对应的第一阈值,则将堆内存资源枯竭监测函数确定为目标内存溢出监测函数。Specifically, if the thread usage rate is greater than or equal to the first threshold corresponding to the thread usage rate, the thread resource exhaustion monitoring function is determined as the target memory overflow monitoring function; if the heap memory usage rate is greater than or equal to the first threshold corresponding to the heap memory usage rate, the heap memory resource exhaustion monitoring function is determined as the target memory overflow monitoring function.

可以理解的是,采用上述技术方案,能够将超出阈值的资源枯竭关联参数对应的资源枯竭监测函数作为目标内存溢出监测函数,以及在存在至少一个异常错误关联参数的比较结果为异常错误关联参数大于或等于第二阈值的情况下,将异常监测函数确定为目标内存溢出监测函数,提高了目标内存溢出监测函数的准确率。It can be understood that by adopting the above-mentioned technical scheme, the resource depletion monitoring function corresponding to the resource depletion associated parameter exceeding the threshold can be used as the target memory overflow monitoring function, and when the comparison result of at least one abnormal error associated parameter is that the abnormal error associated parameter is greater than or equal to the second threshold, the abnormal monitoring function is determined as the target memory overflow monitoring function, thereby improving the accuracy of the target memory overflow monitoring function.

S205、调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。S205, calling each target memory overflow function and each callback function, so as to monitor the memory overflow event of the virtual machine within the time period through each target memory overflow function, and collect the event information of the memory overflow event monitored within the time period through each callback function.

本发明实施例的技术方案,根据虚拟机的运行参数和主机的运行参数,确定至少一个资源枯竭关联参数,以及至少一个异常错误关联参数;确定各资源枯竭关联参数与对应的第一阈值之间的比较结果,以及确定各异常错误关联参数与第二阈值之间的比较结果;根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,能够避免在任意时间周期中均调用全部的候选内存溢出监测函数,从而导致资源浪费,进一步提高了对内存溢出事件的监测效率。The technical solution of the embodiment of the present invention determines at least one resource exhaustion associated parameter and at least one abnormal error associated parameter according to the operating parameters of the virtual machine and the operating parameters of the host; determines the comparison result between each resource exhaustion associated parameter and the corresponding first threshold, and determines the comparison result between each abnormal error associated parameter and the second threshold; according to the comparison result of each resource exhaustion associated parameter and the comparison result of each abnormal error associated parameter, determines at least one target memory overflow monitoring function within a time period from the candidate memory overflow monitoring functions, which can avoid calling all candidate memory overflow monitoring functions in any time period, thereby causing resource waste, and further improves the monitoring efficiency of memory overflow events.

实施例三Embodiment 3

图3为本发明实施例三提供的一种内存溢出事件的监测方法的流程图,本发明实施例在上述实施例的技术方案的基础上,进行了追加优化。FIG3 is a flow chart of a method for monitoring a memory overflow event provided in a third embodiment of the present invention. The embodiment of the present invention makes additional optimizations based on the technical solutions of the above embodiments.

进一步地,追加“若在时间周期中监测到内存溢出事件,则根据采集到的内存溢出事件的事件信息,确定内存溢出事件的事件类型;根据内存溢出事件的事件类型和事件信息,确定内存溢出事件的异常描述信息;将虚拟机的运行参数和主机的运行参数作为运行环境信息;对异常描述信息和运行环境信息进行拼接,得到补充信息”,以实现补充信息的确定操作。Furthermore, it is added that "if a memory overflow event is monitored during a time period, the event type of the memory overflow event is determined based on the collected event information of the memory overflow event; the exception description information of the memory overflow event is determined based on the event type and event information of the memory overflow event; the operating parameters of the virtual machine and the operating parameters of the host are used as the operating environment information; the exception description information and the operating environment information are spliced to obtain supplementary information" to implement the operation of determining the supplementary information.

需要说明的是,在本发明实施例中未详述部分,可参见前述实施例的表述。It should be noted that, for the parts not described in detail in the embodiments of the present invention, reference may be made to the descriptions in the aforementioned embodiments.

参见图3所示的内存溢出事件的监测方法,包括:Referring to FIG. 3 , the method for monitoring a memory overflow event includes:

S301、在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数。S301. During the operation of the virtual machine, for each time period, obtain the operation parameters of the virtual machine in the time period and the operation parameters of the host to which the virtual machine belongs in the time period.

S302、根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机中预置的函数。S302. According to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, determine at least one target memory overflow monitoring function within the time period from the candidate memory overflow monitoring functions, and determine the callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a pre-set function in the virtual machine.

S303、调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。S303, calling each target memory overflow function and each callback function, so as to monitor the memory overflow event of the virtual machine within the time period through each target memory overflow function, and collect the event information of the memory overflow event monitored within the time period through each callback function.

S304、若在时间周期中监测到内存溢出事件,则根据采集到的内存溢出事件的事件信息,确定内存溢出事件的事件类型。S304: If a memory overflow event is detected during the time period, determine the event type of the memory overflow event according to the collected event information of the memory overflow event.

本实施例中,内存溢出事件的事件类型可以包括但不限于堆内存资源枯竭类型、线程资源枯竭类型和异常类型。事件信息可以包括但不限于事件发生时间、事件类型标识、指向发生内存溢出事件的线程的指针地址和指向发生内存溢出事件的函数的指针地址等。具体的,在预设的事件类型标识配置信息中,查询事件类型标识对应的事件类型。In this embodiment, the event type of the memory overflow event may include but is not limited to the heap memory resource exhaustion type, the thread resource exhaustion type and the exception type. The event information may include but is not limited to the event occurrence time, the event type identifier, the pointer address pointing to the thread where the memory overflow event occurs and the pointer address pointing to the function where the memory overflow event occurs. Specifically, in the preset event type identifier configuration information, the event type corresponding to the event type identifier is queried.

S305、根据内存溢出事件的事件类型和事件信息,确定内存溢出事件的异常描述信息。S305: Determine abnormal description information of the memory overflow event according to the event type and event information of the memory overflow event.

本实施例中,异常描述信息可以是可能导致内存溢出事件产生的对象的信息。具体的,采用一定的算法,根据内存溢出事件的事件类型和事件信息,确定内存溢出事件的异常描述信息。In this embodiment, the abnormal description information may be information about an object that may cause a memory overflow event. Specifically, a certain algorithm is used to determine the abnormal description information of the memory overflow event according to the event type and event information of the memory overflow event.

可选的,所述根据所述内存溢出事件的事件类型和事件信息,确定所述内存溢出事件的异常描述信息,包括:若事件类型为异常类型,则对内存溢出事件的事件信息进行解析,得到故障类型、异常线程名和异常线程的堆栈栈帧数量;对故障类型和异常线程名进行拼接,得到第一辅助信息;将堆栈栈帧数量和预设栈帧阈值之间的最小值确定为目标栈帧数量;从异常线程的调用堆栈中,获取目标栈帧数量的栈帧调用函数的属性信息,并对属性信息进行拼接,得到第二辅助信息;将第一辅助信息和第二辅助信息进行拼接,得到异常描述信息。Optionally, the abnormal description information of the memory overflow event is determined based on the event type and event information of the memory overflow event, including: if the event type is an abnormal type, parsing the event information of the memory overflow event to obtain the fault type, the abnormal thread name and the number of stack frames of the abnormal thread; splicing the fault type and the abnormal thread name to obtain first auxiliary information; determining the minimum value between the number of stack frames and a preset stack frame threshold as the target number of stack frames; obtaining attribute information of the stack frame calling function of the target number of stack frames from the call stack of the abnormal thread, and splicing the attribute information to obtain second auxiliary information; splicing the first auxiliary information and the second auxiliary information to obtain exception description information.

其中,堆栈栈帧数量可以是异常线程所调用堆栈中的栈帧的数量。栈帧可以理解为线程执行过程中用于存储调用的函数的属性信息的一种数据结构,每当线程调用一个函数,都会在线程调用的堆栈中创建一个对应的栈帧。栈帧调用函数即是栈帧对应调用的函数。属性信息可以包括但不限于栈帧调用函数的函数名、所属类名和类签名等。故障类型可以理解为导致存溢出事件产生的故障的类型,包括但不限于内存耗尽类型、堆内存耗尽类型和线程耗尽类型等。需要说明的是,故障类型和内存溢出事件的事件类型并不唯一对应,例如线程耗尽类型的故障可以引发堆内存资源枯竭类型的内存溢出事件。Among them, the number of stack frames can be the number of stack frames in the stack called by the abnormal thread. The stack frame can be understood as a data structure used to store the attribute information of the called function during the execution of the thread. Whenever a thread calls a function, a corresponding stack frame will be created in the stack called by the thread. The stack frame calling function is the function called by the stack frame. The attribute information may include but is not limited to the function name, class name and class signature of the stack frame calling function. The fault type can be understood as the type of fault that causes the memory overflow event, including but not limited to the memory exhaustion type, the heap memory exhaustion type and the thread exhaustion type. It should be noted that the fault type and the event type of the memory overflow event are not uniquely corresponding. For example, a thread exhaustion type fault can trigger a memory overflow event of the heap memory resource exhaustion type.

可以理解的是,采用上述技术方案,在事件类型为异常类型的情况下,将故障类型和异常线程名进行拼接,得到第一辅助信息,以及将目标栈帧数量的栈帧调用函数的属性信息拼接为第二辅助信息;将第一辅助信息和第二辅助信息拼接为异常描述信息,能够使异常描述信息中包括异常类型、异常线程名、以及异常线程调用的各函数的函数名等信息,提高异常描述信息的信息丰富程度,进而能够使技术人员根据异常描述信息准确的处理内存溢出事件,提高内存溢出事件的处理效率。It can be understood that, by adopting the above-mentioned technical scheme, when the event type is an exception type, the fault type and the exception thread name are spliced to obtain the first auxiliary information, and the attribute information of the stack frame calling function of the target stack frame number is spliced into the second auxiliary information; the first auxiliary information and the second auxiliary information are spliced into exception description information, which can make the exception description information include information such as the exception type, the exception thread name, and the function names of each function called by the exception thread, thereby improving the information richness of the exception description information, and then enabling technical personnel to accurately handle memory overflow events according to the exception description information, thereby improving the processing efficiency of memory overflow events.

在一个可选实施例中,还可以检测事件信息中是否包括捕获状态标识;其中,捕获状态标识可以用于标识内存溢出事件被异常捕获函数捕获;若事件信息中不包括捕获状态标识,则生成未捕获描述信息;将未捕获描述信息与异常描述信息进行拼接,并将异常描述信息更新为未捕获描述信息与异常描述信息之间的拼接结果。In an optional embodiment, it is also possible to detect whether the event information includes a capture status identifier; wherein the capture status identifier can be used to identify that the memory overflow event is captured by the exception capture function; if the event information does not include the capture status identifier, uncaught description information is generated; the uncaught description information is spliced with the exception description information, and the exception description information is updated to the spliced result between the uncaught description information and the exception description information.

可选的,在调用各目标内存溢出函数和各回调函数之后,还包括:若目标内存溢出函数为异常监测函数,则调用文件名采集函数和行号采集函数;相应的,在从异常线程的调用堆栈中,获取目标栈帧数量的栈帧调用函数的属性信息之后,还包括:通过文件名采集函数,获取各栈帧调用函数所属的文件名,并将文件名添加到对应栈帧调用函数的属性信息中;通过行号采集函数,获取各栈帧调用函数所属的行号,并将行号添加到对应栈帧调用函数的属性信息中。Optionally, after calling each target memory overflow function and each callback function, it also includes: if the target memory overflow function is an exception monitoring function, calling the file name collection function and the line number collection function; accordingly, after obtaining the attribute information of the stack frame calling function of the target stack frame number from the call stack of the exception thread, it also includes: obtaining the file name of each stack frame calling function through the file name collection function, and adding the file name to the attribute information of the corresponding stack frame calling function; obtaining the line number of each stack frame calling function through the line number collection function, and adding the line number to the attribute information of the corresponding stack frame calling function.

其中,文件名采集函数可以用于采集异常线程调用的函数所属的文件名;行号采集函数可以用于采集异常线程调用的函数在程序代码中的行号。The file name collection function can be used to collect the file name of the function called by the abnormal thread; the line number collection function can be used to collect the line number of the function called by the abnormal thread in the program code.

可以理解的是,采用上述技术方案,可以将各栈帧调用函数的所属文件名和在代码中的所属行号添加到属性信息中,以使第二辅助信息中包括各栈帧调用函数的文件名和行号,进一步提高异常描述信息的信息丰富程度,进而能够使技术人员根据异常描述信息准确的处理内存溢出事件,提高内存溢出事件的处理效率。It can be understood that by adopting the above-mentioned technical scheme, the file name and line number in the code of each stack frame calling function can be added to the attribute information, so that the second auxiliary information includes the file name and line number of each stack frame calling function, further improving the information richness of the exception description information, thereby enabling technicians to accurately handle memory overflow events according to the exception description information, thereby improving the processing efficiency of memory overflow events.

可选的,若根据内存溢出事件的事件类型和事件信息,确定内存溢出事件的异常描述信息,事件类型为堆内存资源枯竭类型或线程资源枯竭类型,则确定内存溢出事件的事件信息中是否包括事件描述信息;若事件信息中包括事件描述信息,则将事件描述信息作为异常描述信息;若事件信息中不包括事件描述信息,则根据内存溢出事件的事件信息中的事件标识,确定内存溢出事件的故障类型,并将故障类型作为异常描述信息。Optionally, if the exception description information of the memory overflow event is determined based on the event type and event information of the memory overflow event, and the event type is a heap memory resource exhaustion type or a thread resource exhaustion type, then it is determined whether the event information of the memory overflow event includes the event description information; if the event information includes the event description information, the event description information is used as the exception description information; if the event information does not include the event description information, then the fault type of the memory overflow event is determined based on the event identifier in the event information of the memory overflow event, and the fault type is used as the exception description information.

其中,事件描述信息可以是记录内存溢出事件的故障类型的文本信息;事件标识可以用于唯一标识故障类型。具体的,若事件信息中不包括事件描述信息,在预设的事件标识配置信息中,查询内存溢出事件的故障类型,并将查询到的故障类型作为异常描述信息。可以理解的是,采用上述技术方案,若存在记录故障类型的事件描述信息,则将事件描述信息作为异常描述信息;若不存在事件描述信息,则查询故障类型,并将查询到的故障类型作为事件描述信息,可以提高确定异常描述信息的灵活性,能够确保得到包括故障类型的异常描述信息。Among them, the event description information can be text information that records the fault type of the memory overflow event; the event identifier can be used to uniquely identify the fault type. Specifically, if the event information does not include the event description information, the fault type of the memory overflow event is queried in the preset event identifier configuration information, and the queried fault type is used as the abnormal description information. It can be understood that by adopting the above technical solution, if there is event description information that records the fault type, the event description information is used as the abnormal description information; if there is no event description information, the fault type is queried, and the queried fault type is used as the event description information, which can improve the flexibility of determining the abnormal description information and ensure that the abnormal description information including the fault type is obtained.

S306、将虚拟机的运行参数和主机的运行参数作为运行环境信息。S306: Use the operating parameters of the virtual machine and the operating parameters of the host as operating environment information.

S307、对异常描述信息和运行环境信息进行拼接,得到补充信息。S307: Combine the exception description information and the operating environment information to obtain supplementary information.

在一个具体实施方式中,将补充信息发送至事件监控端,并将探针端的补充信息删除,以腾出存储空间用于存储该时间周期之后的时间周期中确定的补充信息。In a specific implementation, the supplementary information is sent to the event monitoring end, and the supplementary information at the probe end is deleted to free up storage space for storing supplementary information determined in a time period after the time period.

本发明实施例若在时间周期中监测到内存溢出事件,则根据采集到的内存溢出事件的事件信息,确定内存溢出事件的事件类型;根据内存溢出事件的事件类型和事件信息,确定内存溢出事件的异常描述信息;将虚拟机的运行参数和主机的运行参数作为运行环境信息;对异常描述信息和运行环境信息进行拼接,得到补充信息,并将补充信息发送至事件监控端,提高了内存溢出事件的信息丰富程度,进而能够使技术人员根据补充信息准确的处理内存溢出事件,提高内存溢出事件的处理效率。If a memory overflow event is detected during a time period, the embodiment of the present invention determines the event type of the memory overflow event based on the collected event information of the memory overflow event; determines the exception description information of the memory overflow event based on the event type and event information of the memory overflow event; uses the operating parameters of the virtual machine and the operating parameters of the host as the operating environment information; splices the exception description information and the operating environment information to obtain supplementary information, and sends the supplementary information to the event monitoring end, thereby improving the information richness of the memory overflow event, and enabling technical personnel to accurately handle the memory overflow event based on the supplementary information, thereby improving the processing efficiency of the memory overflow event.

实施例四Embodiment 4

图4为本发明实施例四提供的一种内存溢出事件的监测装置的结构示意图。本发明实施例可适用于对内存溢出事件的进行监测的情况,该装置可以执行内存溢出事件的监测方法,该内存溢出事件的监测装置可以采用硬件和/或软件的形式实现,该装置可配置于电子设备中,例如服务器中。Fig. 4 is a schematic diagram of the structure of a monitoring device for memory overflow events provided by Embodiment 4 of the present invention. The embodiment of the present invention can be applied to the situation of monitoring memory overflow events, the device can execute the monitoring method for memory overflow events, the monitoring device for memory overflow events can be implemented in the form of hardware and/or software, and the device can be configured in an electronic device, such as a server.

参见图4所示的内存溢出事件的监测装置,包括参数获取模块401、函数确定模块402和函数调用模块403,其中,Referring to the monitoring device for memory overflow events shown in FIG4 , the device includes a parameter acquisition module 401 , a function determination module 402 and a function calling module 403 , wherein:

参数获取模块401,用于在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;The parameter acquisition module 401 is used to acquire the operation parameters of the virtual machine in each time period and the operation parameters of the host to which the virtual machine belongs in the time period during the operation of the virtual machine;

函数确定模块402,用于根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机提供的开发调试函数;The function determination module 402 is used to determine at least one target memory overflow monitoring function within the time period from the candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, and determine the callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a development and debugging function provided by the virtual machine;

函数调用模块403,用于调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息。The function calling module 403 is used to call each target memory overflow function and each callback function to monitor the memory overflow events occurring in the virtual machine within the time period through each target memory overflow function, and to collect the event information of the memory overflow events monitored within the time period through each callback function.

本发明实施例参数获取模块,在虚拟机的运行过程中,针对每一时间周期,获取时间周期内虚拟机的运行参数,以及时间周期内虚拟机所属主机的运行参数;通过函数确定模块,根据时间周期内虚拟机的运行参数和时间周期内主机的运行参数,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数,以及确定各目标内存溢出监测函数对应的回调函数;其中,候选内存溢出监测函数是虚拟机提供的开发调试函数;通过函数调用模块,调用各目标内存溢出函数和各回调函数,以通过各目标内存溢出函数监测时间周期内虚拟机发生的内存溢出事件,并通过各回调函数采集时间周期内监测到的内存溢出事件的事件信息,相较于现有技术仅能监测到异常捕获代码对应位置处的内存溢出事件的技术方案,本发明实施例的技术方案通过调用虚拟机中预置的目标内存溢出函数与对应的回调函数,无需插入异常捕获代码,也可对多个位置处的内存溢出事件进行监测,提高了监测效率;并且通过部署在虚拟机中的探针,与虚拟机中的程序并行执行,能够周期性的根据虚拟机运行函数和主机运行参数,确定对应时间周期的目标内存溢出监测函数,实现对目标内存溢出监测函数的周期性调整,避免在任意时间周期中均调用全部的候选内存溢出监测函数导致资源浪费,从而进一步提高对内存溢出事件的监测效率。The parameter acquisition module of the embodiment of the present invention obtains the operating parameters of the virtual machine within the time period and the operating parameters of the host to which the virtual machine belongs within the time period for each time period during the operation of the virtual machine; determines at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period through a function determination module, and determines the callback function corresponding to each target memory overflow monitoring function; wherein the candidate memory overflow monitoring function is a development and debugging function provided by the virtual machine; calls each target memory overflow function and each callback function through a function calling module, so as to monitor the memory overflow event occurring in the virtual machine within the time period through each target memory overflow function, and collects the memory overflow event monitored within the time period through each callback function. Compared with the technical solutions of the prior art which can only monitor the memory overflow events at the corresponding positions of the exception capture codes, the technical solutions of the embodiments of the present invention can monitor the memory overflow events at multiple positions by calling the preset target memory overflow function and the corresponding callback function in the virtual machine without inserting the exception capture code, thereby improving the monitoring efficiency; and by deploying the probe in the virtual machine and executing it in parallel with the program in the virtual machine, it can periodically determine the target memory overflow monitoring function of the corresponding time period according to the virtual machine running function and the host running parameters, thereby realizing the periodic adjustment of the target memory overflow monitoring function, avoiding the waste of resources caused by calling all the candidate memory overflow monitoring functions in any time period, thereby further improving the monitoring efficiency of the memory overflow events.

可选的,函数确定模块302,包括:Optionally, the function determination module 302 includes:

参数确定单元,用于根据虚拟机的运行参数和主机的运行参数,确定至少一个资源枯竭关联参数,以及至少一个异常错误关联参数;a parameter determination unit, configured to determine at least one resource exhaustion-related parameter and at least one abnormal error-related parameter according to the operating parameters of the virtual machine and the operating parameters of the host;

比较结果确定单元,用于确定各资源枯竭关联参数与对应的第一阈值之间的比较结果,以及确定各异常错误关联参数与第二阈值之间的比较结果;a comparison result determination unit, configured to determine a comparison result between each resource exhaustion associated parameter and a corresponding first threshold value, and to determine a comparison result between each abnormal error associated parameter and a second threshold value;

函数确定单元,用于根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定时间周期内的至少一个目标内存溢出监测函数。The function determination unit is used to determine at least one target memory overflow monitoring function within a time period from the candidate memory overflow monitoring functions according to the comparison results of the resource exhaustion associated parameters and the comparison results of the abnormal error associated parameters.

可选的,候选内存溢出监测函数包括至少一个资源枯竭监测函数和异常监测函数;Optionally, the candidate memory overflow monitoring function includes at least one resource exhaustion monitoring function and an abnormality monitoring function;

函数确定单元,包括:Function determination unit, including:

第一函数确定单元,用于针对每一资源枯竭关联参数的比较结果,若资源枯竭关联参数的比较结果为资源枯竭关联参数大于或等于资源枯竭关联参数对应的第一阈值,则将资源枯竭关联参数对应的资源枯竭监测函数确定为目标内存溢出监测函数;a first function determination unit, configured to determine, for each resource depletion associated parameter comparison result, a resource depletion monitoring function corresponding to the resource depletion associated parameter as a target memory overflow monitoring function if the resource depletion associated parameter comparison result is that the resource depletion associated parameter is greater than or equal to a first threshold value corresponding to the resource depletion associated parameter;

第二函数确定单元,用于若存在至少一个异常错误关联参数的比较结果为异常错误关联参数大于或等于第二阈值,则将异常监测函数确定为目标内存溢出监测函数。The second function determination unit is used to determine the abnormal monitoring function as a target memory overflow monitoring function if there is a comparison result of at least one abnormal error associated parameter that the abnormal error associated parameter is greater than or equal to a second threshold.

可选的,该装置还包括:Optionally, the device further comprises:

事件类型确定模块,用于若在时间周期中监测到内存溢出事件,则根据采集到的内存溢出事件的事件信息,确定内存溢出事件的事件类型;An event type determination module is used to determine the event type of the memory overflow event based on the collected event information of the memory overflow event if a memory overflow event is detected during a time period;

异常描述信息确定模块,用于根据内存溢出事件的事件类型和事件信息,确定内存溢出事件的异常描述信息;The abnormal description information determination module is used to determine the abnormal description information of the memory overflow event according to the event type and event information of the memory overflow event;

运行环境信息确定模块,用于将虚拟机的运行参数和主机的运行参数作为运行环境信息;An operating environment information determination module, used to use the operating parameters of the virtual machine and the operating parameters of the host as the operating environment information;

补充信息确定模块,用于对异常描述信息和运行环境信息进行拼接,得到补充信息。The supplementary information determination module is used to splice the abnormal description information and the operating environment information to obtain supplementary information.

可选的,异常描述信息确定模块,包括:Optionally, the abnormal description information determination module includes:

事件信息解析单元,用于若事件类型为异常类型,则对内存溢出事件的事件信息进行解析,得到故障类型、异常线程名和异常线程的堆栈栈帧数量;An event information parsing unit, for parsing the event information of the memory overflow event if the event type is an exception type, to obtain the fault type, the name of the exception thread and the number of stack frames of the exception thread;

第一信息确定单元,用于对故障类型和异常线程名进行拼接,得到第一辅助信息;A first information determination unit, configured to concatenate the fault type and the abnormal thread name to obtain first auxiliary information;

数量确定单元,用于将堆栈栈帧数量和预设栈帧阈值之间的最小值确定为目标栈帧数量;a quantity determining unit, configured to determine a minimum value between the number of stack frames and a preset stack frame threshold as a target number of stack frames;

第二信息确定单元,用于从异常线程的调用堆栈中,获取目标栈帧数量的栈帧调用函数的属性信息,并对属性信息进行拼接,得到第二辅助信息;A second information determination unit is used to obtain attribute information of stack frame call functions of a target stack frame number from the call stack of the abnormal thread, and to splice the attribute information to obtain second auxiliary information;

将第一辅助信息和第二辅助信息进行拼接,得到异常描述信息。The first auxiliary information and the second auxiliary information are concatenated to obtain abnormal description information.

可选的,该装置还包括:Optionally, the device further comprises:

采集函数调用模块,用于若目标内存溢出函数为异常监测函数,则调用文件名采集函数和行号采集函数;A collection function calling module is used to call a file name collection function and a line number collection function if the target memory overflow function is an exception monitoring function;

该装置,还包括:The device further comprises:

文件名采集模块,用于通过文件名采集函数,获取各栈帧调用函数所属的文件名,并将文件名添加到对应栈帧调用函数的属性信息中;The file name collection module is used to obtain the file name of each stack frame calling function through the file name collection function, and add the file name to the attribute information of the corresponding stack frame calling function;

行号采集模块,用于通过行号采集函数,获取各栈帧调用函数所属的行号,并将行号添加到对应栈帧调用函数的属性信息中。The line number collection module is used to obtain the line number of each stack frame calling function through the line number collection function, and add the line number to the attribute information of the corresponding stack frame calling function.

可选的。异常描述信息确定模块,包括:Optional. The abnormal description information determination module includes:

事件描述信息确定单元,用于若事件类型为堆内存资源枯竭类型或线程资源枯竭类型,则确定内存溢出事件的事件信息中是否包括事件描述信息;an event description information determination unit, configured to determine whether the event information of the memory overflow event includes event description information if the event type is a heap memory resource exhaustion type or a thread resource exhaustion type;

第三信息确定单元,用于若事件信息中包括事件描述信息,则将事件描述信息作为异常描述信息;a third information determining unit, configured to use the event description information as the abnormality description information if the event information includes the event description information;

第四信息确定单元,用于若事件信息中不包括事件描述信息,则根据内存溢出事件的事件信息中的事件标识,确定内存溢出事件的故障类型,并将故障类型作为异常描述信息。The fourth information determination unit is used to determine the fault type of the memory overflow event according to the event identifier in the event information of the memory overflow event if the event information does not include the event description information, and use the fault type as the abnormal description information.

本发明实施例所提供的内存溢出事件的监测装置可执行本发明任意实施例所提供的内存溢出事件的监测方法,具备执行内存溢出事件的监测方法相应的功能模块和有益效果。The memory overflow event monitoring device provided in the embodiment of the present invention can execute the memory overflow event monitoring method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the memory overflow event monitoring method.

实施例五Embodiment 5

图5示出了可以用来实施本发明的实施例的电子设备500的结构示意图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备(如头盔、眼镜、手表等)和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本发明的实现。FIG5 shows a block diagram of an electronic device 500 that can be used to implement an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and/or required herein.

如图5所示,电子设备500包括至少一个处理器501,以及与至少一个处理器501通信连接的存储器,如只读存储器(ROM)502、随机访问存储器(RAM)503等,其中,存储器存储有可被至少一个处理器执行的计算机程序,处理器501可以根据存储在只读存储器(ROM)502中的计算机程序或者从存储单元508加载到随机访问存储器(RAM)503中的计算机程序,来执行各种适当的动作和处理。在RAM 503中,还可存储电子设备500操作所需的各种程序和数据。处理器501、ROM 502以及RAM 503通过总线504彼此相连。输入/输出(I/O)接口505也连接至总线504。As shown in FIG5 , the electronic device 500 includes at least one processor 501, and a memory connected to the at least one processor 501 in communication, such as a read-only memory (ROM) 502, a random access memory (RAM) 503, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 501 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 502 or the computer program loaded from the storage unit 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to the bus 504.

电子设备500中的多个部件连接至I/O接口505,包括:输入单元506,例如键盘、鼠标等;输出单元507,例如各种类型的显示器、扬声器等;存储单元508,例如磁盘、光盘等;以及通信单元509,例如网卡、调制解调器、无线通信收发机等。通信单元509允许电子设备500通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the electronic device 500 are connected to the I/O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information/data with other devices through a computer network such as the Internet and/or various telecommunication networks.

处理器501可以是各种具有处理和计算能力的通用和/或专用处理组件。处理器501的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的处理器、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。处理器501执行上文所描述的各个方法和处理,例如内存溢出事件的监测方法。Processor 501 may be a variety of general and/or special processing components with processing and computing capabilities. Some examples of processor 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. Processor 501 executes the various methods and processes described above, such as a method for monitoring a memory overflow event.

在一些实施例中,内存溢出事件的监测方法可被实现为计算机程序,其被有形地包含于计算机可读存储介质,例如存储单元508。在一些实施例中,计算机程序的部分或者全部可以经由ROM 502和/或通信单元509而被载入和/或安装到电子设备500上。当计算机程序加载到RAM 503并由处理器501执行时,可以执行上文描述的内存溢出事件的监测方法的一个或多个步骤。备选地,在其他实施例中,处理器501可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行内存溢出事件的监测方法。In some embodiments, the monitoring method of memory overflow event can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 508. In some embodiments, part or all of the computer program can be loaded and/or installed on the electronic device 500 via ROM 502 and/or communication unit 509. When the computer program is loaded into RAM 503 and executed by processor 501, one or more steps of the monitoring method of memory overflow event described above can be performed. Alternatively, in other embodiments, processor 501 can be configured to perform the monitoring method of memory overflow event by any other appropriate means (e.g., by means of firmware).

本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、复杂可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and/or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

用于实施本发明的方法的计算机程序可以采用一个或多个编程语言的任何组合来编写。这些计算机程序可以提供给通用计算机、专用计算机或其他可编程内存溢出事件的监测装置的处理器,使得计算机程序当由处理器执行时使流程图和/或框图中所规定的功能/操作被实施。计算机程序可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。The computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to the processor of the monitoring device of general-purpose computer, special-purpose computer or other programmable memory overflow event, so that the computer program makes the function/operation specified in the flow chart and/or the block diagram be implemented when executed by the processor. The computer program can be executed completely on the machine, partially on the machine, as an independent software package, partially on the machine and partially on the remote machine or completely on the remote machine or server.

在本发明的上下文中,计算机可读存储介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的计算机程序。计算机可读存储介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。备选地,计算机可读存储介质可以是机器可读信号介质。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

为了提供与用户的交互,可以在电子设备上实施此处描述的系统和技术,该电子设备具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给电子设备。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)、区块链网络和互联网。The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

计算系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与VPS(VirtualPrivate Server,虚拟专用服务器)服务中,存在的管理难度大,业务扩展性弱的缺陷。A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS (Virtual Private Server) services.

应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发明中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本发明的技术方案所期望的结果,本文在此不进行限制。It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修正、组合、子组合和替代。任何在本发明的精神和原则之内所作的修正、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims (10)

Translated fromChinese
1.一种内存溢出事件的监测方法,其特征在于,由部署在虚拟机中的探针执行,所述方法包括:1. A method for monitoring a memory overflow event, characterized in that it is performed by a probe deployed in a virtual machine, and the method comprises:在所述虚拟机的运行过程中,针对每一时间周期,获取所述时间周期内所述虚拟机的运行参数,以及所述时间周期内所述虚拟机所属主机的运行参数;During the operation of the virtual machine, for each time period, obtaining the operation parameters of the virtual machine in the time period and the operation parameters of the host to which the virtual machine belongs in the time period;根据所述时间周期内虚拟机的运行参数和所述时间周期内主机的运行参数,从候选内存溢出监测函数中确定所述时间周期内的至少一个目标内存溢出监测函数,以及确定各所述目标内存溢出监测函数对应的回调函数;其中,所述候选内存溢出监测函数是所述虚拟机中预置的函数;According to the operating parameters of the virtual machine in the time period and the operating parameters of the host in the time period, determining at least one target memory overflow monitoring function in the time period from the candidate memory overflow monitoring functions, and determining a callback function corresponding to each of the target memory overflow monitoring functions; wherein the candidate memory overflow monitoring function is a function preset in the virtual machine;调用各所述目标内存溢出函数和各所述回调函数,以通过各所述目标内存溢出函数监测所述时间周期内虚拟机发生的内存溢出事件,并通过各所述回调函数采集所述时间周期内监测到的内存溢出事件的事件信息。Call each of the target memory overflow functions and each of the callback functions to monitor memory overflow events occurring in the virtual machine within the time period through each of the target memory overflow functions, and collect event information of the memory overflow events monitored within the time period through each of the callback functions.2.根据权利要求1所述的方法,其特征在于,所述根据所述时间周期内虚拟机的运行参数和所述时间周期内主机的运行参数,从候选内存溢出监测函数中确定所述时间周期内的至少一个目标内存溢出监测函数,包括:2. The method according to claim 1, characterized in that the step of determining at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period comprises:根据所述虚拟机的运行参数和所述主机的运行参数,确定至少一个资源枯竭关联参数,以及至少一个异常错误关联参数;Determining at least one resource exhaustion-related parameter and at least one abnormal error-related parameter according to the operating parameters of the virtual machine and the operating parameters of the host;确定各所述资源枯竭关联参数与对应的第一阈值之间的比较结果,以及确定各所述异常错误关联参数与第二阈值之间的比较结果;Determining a comparison result between each of the resource exhaustion associated parameters and a corresponding first threshold, and determining a comparison result between each of the abnormal error associated parameters and a second threshold;根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定所述时间周期内的至少一个目标内存溢出监测函数。At least one target memory overflow monitoring function within the time period is determined from the candidate memory overflow monitoring functions according to the comparison results of the resource exhaustion associated parameters and the comparison results of the abnormal error associated parameters.3.根据权利要求2所述的方法,其特征在于,所述候选内存溢出监测函数包括至少一个资源枯竭监测函数和异常监测函数;3. The method according to claim 2, characterized in that the candidate memory overflow monitoring function includes at least one resource exhaustion monitoring function and an abnormality monitoring function;所述根据各资源枯竭关联参数的比较结果和各异常错误关联参数的比较结果,从候选内存溢出监测函数中确定所述时间周期内的至少一个目标内存溢出监测函数,包括:The step of determining at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions according to the comparison results of the resource exhaustion associated parameters and the comparison results of the abnormal error associated parameters includes:针对每一资源枯竭关联参数的比较结果,若所述资源枯竭关联参数的比较结果为所述资源枯竭关联参数大于或等于所述资源枯竭关联参数对应的第一阈值,则将所述资源枯竭关联参数对应的资源枯竭监测函数确定为目标内存溢出监测函数;For each comparison result of the resource depletion associated parameter, if the comparison result of the resource depletion associated parameter is that the resource depletion associated parameter is greater than or equal to a first threshold value corresponding to the resource depletion associated parameter, then determining the resource depletion monitoring function corresponding to the resource depletion associated parameter as a target memory overflow monitoring function;若存在至少一个异常错误关联参数的比较结果为异常错误关联参数大于或等于第二阈值,则将所述异常监测函数确定为目标内存溢出监测函数。If there is at least one abnormal error associated parameter whose comparison result is that the abnormal error associated parameter is greater than or equal to the second threshold, the abnormal monitoring function is determined as a target memory overflow monitoring function.4.根据权利要求1所述的方法,其特征在于,所述方法还包括:4. The method according to claim 1, characterized in that the method further comprises:若在所述时间周期中监测到内存溢出事件,则根据采集到的内存溢出事件的事件信息,确定所述内存溢出事件的事件类型;If a memory overflow event is detected during the time period, determining the event type of the memory overflow event according to the collected event information of the memory overflow event;根据所述内存溢出事件的事件类型和事件信息,确定所述内存溢出事件的异常描述信息;Determine the abnormal description information of the memory overflow event according to the event type and event information of the memory overflow event;将所述虚拟机的运行参数和所述主机的运行参数作为运行环境信息;Using the operating parameters of the virtual machine and the operating parameters of the host as operating environment information;对所述异常描述信息和所述运行环境信息进行拼接,得到补充信息。The exception description information and the operating environment information are concatenated to obtain supplementary information.5.根据权利要求4所述的方法,其特征在于,所述根据所述内存溢出事件的事件类型和事件信息,确定所述内存溢出事件的异常描述信息,包括:5. The method according to claim 4, characterized in that the determining the abnormal description information of the memory overflow event according to the event type and event information of the memory overflow event comprises:若所述事件类型为异常类型,则对所述内存溢出事件的事件信息进行解析,得到故障类型、异常线程名和异常线程的堆栈栈帧数量;If the event type is an abnormal type, the event information of the memory overflow event is parsed to obtain the fault type, the abnormal thread name and the number of stack frames of the abnormal thread;对所述故障类型和所述异常线程名进行拼接,得到第一辅助信息;Concatenate the fault type and the abnormal thread name to obtain first auxiliary information;将所述堆栈栈帧数量和预设栈帧阈值之间的最小值确定为目标栈帧数量;Determine the minimum value between the number of stack frames and a preset stack frame threshold as the target number of stack frames;从所述异常线程的调用堆栈中,获取所述目标栈帧数量的栈帧调用函数的属性信息,并对所述属性信息进行拼接,得到第二辅助信息;Acquire attribute information of stack frame call functions of the target stack frame number from the call stack of the abnormal thread, and concatenate the attribute information to obtain second auxiliary information;将所述第一辅助信息和所述第二辅助信息进行拼接,得到异常描述信息。The first auxiliary information and the second auxiliary information are concatenated to obtain abnormal description information.6.根据权利要求5所述的方法,其特征在于,在调用各所述目标内存溢出函数和各所述回调函数之后,还包括:6. The method according to claim 5, characterized in that after calling each of the target memory overflow functions and each of the callback functions, it further comprises:若所述目标内存溢出函数为异常监测函数,则调用文件名采集函数和行号采集函数;If the target memory overflow function is an exception monitoring function, then the file name collection function and the line number collection function are called;相应的,在从所述异常线程的调用堆栈中,获取所述目标栈帧数量的栈帧调用函数的属性信息之后,还包括:Correspondingly, after acquiring the attribute information of the stack frame calling function of the target stack frame number from the call stack of the abnormal thread, the method further includes:通过所述文件名采集函数,获取各所述栈帧调用函数所属的文件名,并将所述文件名添加到对应栈帧调用函数的属性信息中;The file name acquisition function is used to obtain the file name of each stack frame calling function, and the file name is added to the attribute information of the corresponding stack frame calling function;通过所述行号采集函数,获取各所述栈帧调用函数所属的行号,并将所述行号添加到对应栈帧调用函数的属性信息中。The line number to which each stack frame calling function belongs is obtained through the line number acquisition function, and the line number is added to the attribute information of the corresponding stack frame calling function.7.根据权利要求4所述的方法,其特征在于,所述根据所述内存溢出事件的事件类型和事件信息,确定所述内存溢出事件的异常描述信息,包括:7. The method according to claim 4, characterized in that the determining the abnormal description information of the memory overflow event according to the event type and event information of the memory overflow event comprises:若所述事件类型为堆内存资源枯竭类型或线程资源枯竭类型,则确定所述内存溢出事件的事件信息中是否包括事件描述信息;If the event type is a heap memory resource exhaustion type or a thread resource exhaustion type, determining whether the event information of the memory overflow event includes event description information;若事件信息中包括事件描述信息,则将所述事件描述信息作为异常描述信息;If the event information includes event description information, the event description information is used as the abnormal description information;若事件信息中不包括事件描述信息,则根据所述内存溢出事件的事件信息中的事件标识,确定所述内存溢出事件的故障类型,并将所述故障类型作为异常描述信息。If the event information does not include event description information, the fault type of the memory overflow event is determined according to the event identifier in the event information of the memory overflow event, and the fault type is used as the exception description information.8.一种内存溢出事件的监测装置,其特征在于,配置于部署在虚拟机中的探针中,所述装置包括:8. A monitoring device for memory overflow events, characterized in that it is configured in a probe deployed in a virtual machine, and the device comprises:参数获取模块,用于在所述虚拟机的运行过程中,针对每一时间周期,获取所述时间周期内所述虚拟机的运行参数,以及所述时间周期内所述虚拟机所属主机的运行参数;A parameter acquisition module, used for acquiring, during the operation of the virtual machine, for each time period, the operation parameters of the virtual machine in the time period and the operation parameters of the host to which the virtual machine belongs in the time period;函数确定模块,用于根据所述时间周期内虚拟机的运行参数和所述时间周期内主机的运行参数,从候选内存溢出监测函数中确定所述时间周期内的至少一个目标内存溢出监测函数,以及确定各所述目标内存溢出监测函数对应的回调函数;其中,所述候选内存溢出监测函数是所述虚拟机提供的开发调试函数;A function determination module, used to determine at least one target memory overflow monitoring function within the time period from candidate memory overflow monitoring functions according to the operating parameters of the virtual machine within the time period and the operating parameters of the host within the time period, and determine a callback function corresponding to each of the target memory overflow monitoring functions; wherein the candidate memory overflow monitoring function is a development and debugging function provided by the virtual machine;函数调用模块,用于调用各所述目标内存溢出函数和各所述回调函数,以通过各所述目标内存溢出函数监测所述时间周期内虚拟机发生的内存溢出事件,并通过各所述回调函数采集所述时间周期内监测到的内存溢出事件的事件信息。A function calling module is used to call each of the target memory overflow functions and each of the callback functions, so as to monitor the memory overflow events occurring in the virtual machine within the time period through each of the target memory overflow functions, and to collect event information of the memory overflow events monitored within the time period through each of the callback functions.9.一种电子设备,其特征在于,所述电子设备包括:9. An electronic device, characterized in that the electronic device comprises:至少一个处理器;以及at least one processor; and与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-7中任一项所述的内存溢出事件的监测方法。The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for monitoring a memory overflow event according to any one of claims 1 to 7.10.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现权利要求1-7中任一项所述的内存溢出事件的监测方法。10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the memory overflow event monitoring method according to any one of claims 1 to 7 when executed.
CN202410265603.8A2024-03-082024-03-08 A memory overflow event monitoring method, device, equipment and mediumPendingCN118132379A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202410265603.8ACN118132379A (en)2024-03-082024-03-08 A memory overflow event monitoring method, device, equipment and medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202410265603.8ACN118132379A (en)2024-03-082024-03-08 A memory overflow event monitoring method, device, equipment and medium

Publications (1)

Publication NumberPublication Date
CN118132379Atrue CN118132379A (en)2024-06-04

Family

ID=91233886

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202410265603.8APendingCN118132379A (en)2024-03-082024-03-08 A memory overflow event monitoring method, device, equipment and medium

Country Status (1)

CountryLink
CN (1)CN118132379A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN119440741A (en)*2025-01-082025-02-14中电云计算技术有限公司 Memory overflow event processing method, device, electronic device and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN119440741A (en)*2025-01-082025-02-14中电云计算技术有限公司 Memory overflow event processing method, device, electronic device and storage medium

Similar Documents

PublicationPublication DateTitle
CN111552607A (en)Health evaluation method, device and equipment of application program and storage medium
CN118132379A (en) A memory overflow event monitoring method, device, equipment and medium
CN118069056A (en) Data writing method, device, equipment and medium
WO2023016485A1 (en)Method for acquiring function call information, and apparatus, electronic device and medium
WO2025045227A1 (en)Application program compliance verification method and apparatus, electronic device and storage medium
CN118733149A (en) Data interaction method, device, electronic device and storage medium
CN118445110A (en) Fault repair method, device, storage medium and electronic device
CN117033058A (en)Analysis method, device, equipment and medium for software crash data
WO2020073200A1 (en)Program debugging method and system
CN115048279A (en)Server processing method and device, electronic equipment and computer readable medium
CN118606008B (en)Garbage disposal method, device and equipment for Java virtual machine and storage medium
CN118502814B (en)Software modification evaluation method, device, equipment and medium based on byte codes
CN116340102B (en)Memory overflow monitoring method, device, equipment and storage medium
CN117156398B (en)Message processing method, device, electronic equipment and storage medium
CN113821512B (en) Data storage object analysis method, device, medium and electronic device
Nicolaescu et al.On Adequate Behavior-based Architecture Conformance Checks
CN118568006A (en) Application interface awakening method, device, equipment, storage medium and program product
CN118113288A (en) Plug-in compilation method, device, electronic device and storage medium
CN118689682A (en) Fault storage method, device, electronic equipment and storage medium
CN117971640A (en) Testing methods, devices, equipment and media for embedded software
CN118760569A (en) A log recording method, device, equipment and storage medium
CN118747153A (en) A process splitting method, device, equipment and storage medium
CN120029934A (en) Symbolization method, device, equipment and storage medium for continuous performance analysis data
CN116302796A (en)Process monitoring method and device, electronic equipment and storage medium
CN118585448A (en) A test case generation method, device, equipment and medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp