Detection method, device and equipment, computer readable storage medium and program product

By obtaining the handle time series data of the process and using indicators such as statistical curve slope and smoothing rate to determine handle leakage, the problem of low handle leakage detection efficiency in the existing technology is solved, and more efficient detection is achieved.

CN120386707APending Publication Date: 2025-07-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410104181.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-24
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

In the prior art, handle leakage detection is more complex and timely, resulting in lower detection efficiency.

Method used

By obtaining the process's handle time series data, determine the handle change trend value, including statistical curve slope, smoothing rate and business statistical indicator values, and determine whether there is handle leakage in the process.

Benefits of technology

Improves the efficiency and accuracy of handle leakage detection, and can determine whether there is handle leakage in the process faster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386707A_ABST
    Figure CN120386707A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a detection method, device and equipment, a computer readable storage medium and a program product, and relates to the fields of artificial intelligence, maps and the like, and application scenes include but are not limited to handle leakage detection scenes. The method comprises the steps of obtaining time sequence data of a handle of each process in at least one process, wherein the handle of each process is used for representing a handle which is not released by each process; based on the time sequence data of the handles of each process, a handle change trend value of each process is determined, the handle change trend value of each process is used for representing the change trend of the number of the handles of each process in a preset time period, and the number of the handles is used for representing the number of the handles which are not released by each process; based on the handle change trend value of each process, determining whether handle leakage exists in each process or not; therefore, whether handle leakage exists in the process or not can be judged more quickly by counting the change trend of the handle, so that the efficiency of handle leakage detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology. Specifically, this application relates to a detection method, device, equipment, computer-readable storage medium, and program product. Background Art

[0002] In the prior art, a handle can be an identifier of an object or instance in an operating system. The objects include modules, application instances, windows, controls, bitmaps, graphics device interface objects, resources, files, etc. If a certain process in a program does not correctly close the handle after using the handle and the handle remains in memory all the time, it will cause a handle leak, that is, there is a memory leak in the process. In the prior art, the complexity of handle leak detection is relatively high, and the timeliness of handle leak detection is relatively low, resulting in low efficiency of handle leak detection. Summary of the Invention

[0003] In view of the disadvantages of the existing methods, this application provides a detection method, device, equipment, computer-readable storage medium, and computer program product to solve the problem of how to improve the efficiency of handle leak detection.

[0004] In a first aspect, this application provides a detection method, including:

[0005] Obtain time series data of handles of each process in at least one process, where the handles of each process are used to represent the un-released handles of each process;

[0006] Based on the time series data of the handles of each process, determine a handle change trend value for each process, where the handle change trend value for each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of un-released handles of each process;

[0007] Based on the handle change trend value of each process, determine whether there is a handle leak in each process.

[0008] In one embodiment, obtaining the time series data of the handles of each process in at least one process includes:

[0009] For each process in at least one process, obtain the number of handles of each process at each time point within at least one collection period;

[0010] Based on the number of handles of each process at each time point, determine the time series data of the handles of each process, where the time series data of the handles of each process includes each time point and the number of handles of each process at each time point.

[0011] In one embodiment, for each process among at least one process, obtaining the number of handles of each process at each time point within at least one collection period includes:

[0012] For each process among at least one process, through a preset process system utility, obtaining the number of handles of the file handles of each process at each time point within at least one collection period.

[0013] In one embodiment, based on the time series data of the handles of each process, determining the handle change trend value of each process includes:

[0014] For a preset number of detection periods, based on the time series data of the handles of each process, determining the handle change trend value of each process in each detection period. The handle change trend value of each process includes at least one of the statistical curve slope corresponding to the handles of each process, the smoothing rate corresponding to the handles of each process, and the business statistical index value corresponding to the handles of each process.

[0015] In one embodiment, the handle change trend value of each process includes the statistical curve slope corresponding to the handles of each process. Based on the handle change trend value of each process, determining whether there is a handle leak in each process includes:

[0016] For N consecutive detection periods among a plurality of detection periods, if the statistical curve slope corresponding to the handles of each process in each of the N consecutive detection periods is greater than a preset slope threshold, it is determined that there is a handle leak in each process. The statistical curve slope corresponding to the handles of each process is used to characterize the growth trend of the number of handles of each process within a predetermined time period, and N is a positive integer.

[0017] In one embodiment, the handle change trend value of each process includes the smoothing rate corresponding to the handles of each process. Based on the handle change trend value of each process, determining whether there is a handle leak in each process includes:

[0018] If for N consecutive detection periods among a plurality of detection periods, the absolute value of the smoothing rate corresponding to the handles of each process in each of the N consecutive detection periods is less than a preset smoothing rate threshold, it is determined that there is no handle leak in each process. The smoothing rate corresponding to the handles of each process is used to characterize the smoothing degree of the number of handles of each process within a predetermined time period, and N is a positive integer.

[0019] In one embodiment, the handle change trend value of each process includes the statistical curve slope corresponding to the handles of each process and the smoothing rate corresponding to the handles of each process. Based on the handle change trend value of each process, determining whether there is a handle leak in each process includes:

[0020] For N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the handle of each process is greater than or equal to a preset smoothing rate threshold, then it is determined that there is a handle leak for each process, where N is a positive integer.

[0021] In one embodiment, the handle of each process is a service handle. Determining whether there is a handle leak for each process based on the handle change trend value of each process includes:

[0022] Determining whether there is a handle leak for each process based on at least one of the slope of the statistical curve corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical index value corresponding to the service handle of each process.

[0023] In one embodiment, determining whether there is a handle leak for each process based on the service statistical index value corresponding to the service handle of each process includes:

[0024] If for N consecutive detection cycles among multiple detection cycles, the service statistical index value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, then it is determined that there is a handle leak for each process.

[0025] In one embodiment, the service handle is a Transmission Control Protocol (TCP) handle, and the service statistical index value is a TCP index value. Determining whether there is a handle leak for each process based on the service statistical index value corresponding to the service handle of each process includes:

[0026] If for N consecutive detection cycles among multiple detection cycles, the TCP index value corresponding to the TCP handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, then it is determined that there is a handle leak for each process. The TCP index value corresponding to the TCP handle of each process is used to represent the number of TCP handles in the closed-wait state for each process within a predetermined time period, where N is a positive integer.

[0027] In one embodiment, determining whether there is a handle leak for each process based on the slope of the statistical curve corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical index value corresponding to the service handle of each process includes:

[0028] For N consecutive detection cycles out of multiple detection cycles, if the slope of the statistical curve corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than the preset slope threshold, and the absolute value of the smoothing rate corresponding to the service handle of each process is greater than or equal to the preset smoothing rate threshold, or the service statistical index value corresponding to the service handle of each process is greater than the preset index value threshold, then it is determined that there is a handle leak in each process, where N is a positive integer.

[0029] In one embodiment, the time series data of the handles of each process includes each time point and the number of handles of each process at each time point. Based on the time series data of the handles of each process, the handle change trend value of each process in each detection cycle is determined, including:

[0030] Based on the time sequence number corresponding to each time point and the number of handles of each process at each time point, the least squares line is determined by least squares fitting, and the slope of the least squares line is determined as the statistical curve slope corresponding to the handle of each process.

[0031] In a second aspect, the present application provides a detection device, including:

[0032] A first processing module, configured to obtain the time series data of the handles of each process in at least one process, where the handle of each process is used to represent the unreleased handle of each process;

[0033] A second processing module, configured to determine the handle change trend value of each process based on the time series data of the handles of each process, where the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of unreleased handles of each process;

[0034] A third processing module, configured to determine whether there is a handle leak in each process based on the handle change trend value of each process.

[0035] In a third aspect, the present application provides an electronic device, including: a processor, a memory, and a bus;

[0036] The bus is used to connect the processor and the memory;

[0037] The memory is used to store operation instructions;

[0038] The processor is configured to execute the detection method of the first aspect of the present application by calling the operation instructions.

[0039] In a fourth aspect, the present application provides a computer-readable storage medium, storing a computer program, and the computer program is used to execute the detection method of the first aspect of the present application.

[0040] Fifthly, the present application provides a computer program product, including a computer program which, when executed by a processor, implements the steps of the detection method in the first aspect of the present application.

[0041] The technical solutions provided by the embodiments of the present application have at least the following beneficial effects:

[0042] Obtain the time series data of the handles of each process in at least one process, where the handle of each process is used to represent the un-released handles of each process; based on the time series data of the handles of each process, determine the handle change trend value of each process, and the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of un-released handles of each process; based on the handle change trend value of each process, determine whether there is a handle leak in each process; thus, by statistically analyzing the change trend of the handles, it is possible to more quickly determine whether there is a handle leak in the process, thereby improving the efficiency of handle leak detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description in the embodiments of the present application.

[0044] Figure 1 It is a schematic diagram of the principle of the TCP connection establishment process

[0045] Figure 2 It is a schematic diagram of the architecture of the detection system provided by the embodiment of the present application;

[0046] Figure 3 It is a schematic flowchart of a detection method provided by the embodiment of the present application;

[0047] Figure 4 It is a schematic flowchart of a detection method provided by the embodiment of the present application;

[0048] Figure 5 It is a schematic diagram of the detection provided by the embodiment of the present application;

[0049] Figure 6 It is a schematic diagram of the detection provided by the embodiment of the present application;

[0050] Figure 7 It is a schematic diagram of the structure of a detection device provided by the embodiment of the present application;

[0051] Figure 8 It is a schematic diagram of the structure of an electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0052] Embodiments of the present application will be described below with reference to the accompanying drawings in the present application. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and do not limit the technical solutions of the embodiments of the present application.

[0053] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the", and "said" used herein may also include the plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements, and / or components, but do not exclude the implementation of other features, information, data, steps, operations, elements, components, and / or their combinations supported by the art of the present technology. It should be understood that when we say an element is "connected" or "coupled" to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used here can include wireless connection or wireless coupling. The term "and / or" used here indicates at least one of the items defined by the term, for example, "A and / or B" indicates being implemented as "A", or being implemented as "B", or being implemented as "A and B".

[0054] It can be understood that in the specific implementation of the present application, when it comes to data related to detection, when the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.

[0055] To make the objectives, technical solutions, and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0056] The embodiment of the present application is a detection method provided by an identification system, and this detection method involves fields such as artificial intelligence and maps.

[0057] Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence is also the study of the design principles and implementation methods of various intelligent machines, enabling the machines to have the functions of perception, reasoning, and decision-making.

[0058] Artificial intelligence technology is an interdisciplinary subject that involves a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, autonomous driving, and intelligent transportation.

[0059] Intelligent Traffic System (ITS), also known as Intelligent Transportation System, is the effective and comprehensive application of advanced scientific and technological (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) in transportation, service control, and vehicle manufacturing, strengthening the connection among vehicles, roads, and users, thus forming a comprehensive transportation system that ensures safety, improves efficiency, improves the environment, and saves energy.

[0060] To better understand and illustrate the solutions of the embodiments of the present application, some technical terms involved in the embodiments of the present application are briefly described below.

[0061] Handle: A handle is a concept introduced in the Windows operating system. A handle is a 32-bit unsigned integer value corresponding to an object; a handle can be mapped to a unique object, and a handle is an interface for processing an object. For the object involved, the corresponding handle can be used to operate the object; the introduction of the handle is mainly for the purpose of the operating system to prevent an application program from directly operating on the data structure of a certain object, and using the operation of the handle to replace the operation of the object; examples of handles include file handles, service handles, memory handles, etc.

[0062] Handle leak: For example, the main reason for causing a handle leak is that after a process calls a system file, it does not release the opened file handle; in the Linux system, the connection between a process and a file is established through the "open file" operation, and the file system will return a file handle to uniquely identify the connection between the process and the file; whenever a process finishes execution, the Linux system will automatically release the file handles related to the process; however, if the process is in an execution state all the time, the file handle can only be self-released through the "close file" operation; different from the settings of the Windows system, the Linux system has a limit on the number of file handles that a process can call. By default, the maximum number of handles that each process can call is 1024; if it exceeds this value of 1024, the process cannot obtain a new handle; therefore, a handle leak will pose a great potential hazard to the failure of the process function.

[0063] File handle: In the Linux / Unix operating system, everything is a file, including devices, regular files, and folders. When a user makes a request, a file handle is generated. A file handle can be understood as an index. As the number of requests and the frequency of process calls increase, more file handles are generated. The operating system has a default limit on file handles and does not allow processes to call handles without limit because system resources are limited. Therefore, it is necessary to limit how many file handles a process can use. The default number of file handles used by the operating system is 1024.

[0064] Memory handle: A memory handle is used to identify allocated memory blocks for reading or releasing these memory blocks. In C and C++, pointers can be used as memory handles.

[0065] gopstuil: gopstuil is the Go language version of psutil. The meaning of psutil is process and system utilities. Psutil is a cross-platform library used to retrieve information about running processes and system utilization in Python. Gopstuil is mainly used for system detection, analysis, limiting process resources, and managing running processes.

[0066] CLOSE_WAIT state: In TCP (Transmission Control Protocol) / IP (Internet Protocol), the CLOSE_WAIT state means that the client has sent a request to close the connection, but the server still has data to transmit and cannot close the connection temporarily, so it is in a waiting state.

[0067] Socket: A socket is an abstraction of an endpoint for two-way communication between application processes on different hosts in a network.

[0068] The four-way handshake process: As Figure 1 shown, the four-way handshake process is as follows:

[0069] The first wave: Host A (such as a client or server) sets the Sequence Number and Acknowledgment Number and sends a FIN packet segment to Host B (such as a server, etc.). At this time, Host A enters the FIN_WAIT_1 state, indicating that Host A has no data to send to Host B.

[0070] Second wave: Host B receives the FIN packet segment sent by Host A and returns an ACK packet segment to Host A. The Acknowledgment Number is the Sequence Number plus 1. Host A enters the FIN_WAIT_2 state. Host B tells Host A that Host B also has no data to send and the connection can be closed.

[0071] Third wave: Host B sends a FIN packet segment to Host A to request closing the connection. At the same time, Host B enters the CLOSE_WAIT state.

[0072] Fourth wave: Host A receives the FIN packet segment sent by Host B and sends an ACK packet segment to Host B. Then Host A enters the TIME_WAIT state. After Host B receives the ACK packet segment from Host A, it closes the connection. At this time, Host A waits for 2 MSL (Maximum Segment Lifetime). If no reply is received after 2 MSLs, it proves that Host B has been normally closed. At this time, Host A can also close the connection.

[0073] The solution provided in the embodiments of the present application relates to artificial intelligence technology. The technical solution of the present application will be described in detail below with specific embodiments. These specific embodiments can be combined with each other. Concepts or processes that are the same or similar may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.

[0074] To better understand the solution provided in the embodiments of the present application, the solution will be described below with a specific application scenario.

[0075] In one embodiment, Figure 2 shows a schematic diagram of the architecture of a detection system applicable to the embodiments of the present application. It can be understood that the detection method provided in the embodiments of the present application can be applicable to but not limited to the application scenarios such as Figure 2 shown.

[0076] In this example, as Figure 2As shown, the architecture of the detection system in this example may include, but is not limited to, a server 10, a terminal 20, and a database 30. The server 10, the terminal 20, and the database 30 may interact through a network 40. The server 10 obtains time series data of the handles of each process in at least one process, and the handle of each process is used to represent the unreleased handles of each process; the server 10 determines a handle change trend value for each process based on the time series data of the handles of each process, and the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of unreleased handles of each process; the server 10 determines whether there is a handle leak for each process based on the handle change trend value of each process; the server 10 sends the result of whether there is a handle leak to the terminal 20, and the server 10 also sends the result of whether there is a handle leak to the database 30 for storage.

[0077] It can be understood that the above is only an example, and this embodiment is not limited herein.

[0078] Among them, the terminal includes, but is not limited to, smart phones (such as Android phones, iOS phones, etc.), phone emulators, tablets, laptops, digital broadcast receivers, MIDs (Mobile Internet Devices), PDAs (Personal Digital Assistants), intelligent voice interaction devices, smart home appliances, in-vehicle terminals, etc.

[0079] The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0080] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computing devices, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides resources is called the "cloud". The resources in the "cloud" seem to be infinitely expandable to users, and can be obtained at any time, used on demand, expanded at any time, and paid according to usage.

[0081] As a basic cloud computing service provider, a cloud computing resource pool (abbreviated as cloud platform, generally referred to as IaaS (Infrastructure as a Service) platform) will be established. Multiple types of virtual resources are deployed in the resource pool for external customers to select and use. The cloud computing resource pool mainly includes: computing devices (virtual machines containing operating systems), storage devices, and network devices.

[0082] Logically divided, the PaaS (Platform as a Service) layer can be deployed on the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, the SaaS can be directly deployed on the IaaS. PaaS is a platform for software running, such as databases, web containers, etc. SaaS is various business software, such as web portals, mass text message senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.

[0083] The so-called artificial intelligence cloud service is generally also referred to as AIaaS (AI as a Service). This is a current mainstream service mode of artificial intelligence platforms. Specifically, the AIaaS platform will split several common AI services and provide independent or packaged services in the cloud. This service mode is similar to opening an AI-themed mall: all developers can access and use one or more artificial intelligence services provided by the platform through the API interface. Some senior developers can also use the AI frameworks and AI infrastructure provided by the platform to deploy and operate their own exclusive cloud artificial intelligence services.

[0084] The above network can include but is not limited to: wired networks, wireless networks. Among them, the wired network includes: local area networks, metropolitan area networks, and wide area networks, and the wireless network includes: Bluetooth, Wi-Fi, and other networks that implement wireless communication. Specifically, it can also be determined based on the actual application scenario requirements and is not limited here.

[0085] See Figure 3 , Figure 3 shows a schematic flowchart of a detection method provided by an embodiment of the present application. Among them, this method can be executed by any electronic device, such as a server, etc.; as an alternative embodiment, this method can be executed by a server. For the convenience of description, in the description of some alternative embodiments below, the server will be used as an example of the execution subject of this method. As Figure 3 shown, the detection method provided by the embodiment of the present application includes the following steps:

[0086] S201. Obtain the time series data of the handles of each process in at least one process. The handle of each process is used to represent the unreleased handles of each process.

[0087] Specifically, a handle is, for example, an identifier of an object or instance in an operating system. The objects include modules, application instances, windows, controls, bitmaps, graphics device interface objects, resources, files, etc. Set a fixed collection period. Based on the collection period, cyclically collect the time series data of the handles of multiple processes in a system (such as a server), and save the collected time series data of the handles to a time series database. The time series database is, for example, an Elasticsearch database. The time series data stored in the time series database is used to determine handle leaks and conduct a review after determining handle leaks.

[0088] The time series data can be a data set recorded in chronological order. The time series data can be used to analyze and predict time-related phenomena and trends. Based on the time series data, the information of the handles of multiple processes can be statistically analyzed in chronological order. For example, the time series data is {(10:01, Process 1, number of handles 26), (10:01, Process 2, number of handles 30), (10:01, Process 3, number of handles 15), (10:02, Process 1, number of handles 30), (10:02, Process 2, number of handles 10), (10:02, Process 3, number of handles 25), (10:03, Process 1, number of handles 40), (10:03, Process 2, number of handles 20), (10:03, Process 3, number of handles 35)}. The time series data includes the information of the handles of 3 processes. The information of the handles of each of the 3 processes includes the number of handles of each process.

[0089] S202. Based on the time series data of the handles of each process, determine the handle change trend value of each process. The handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period. The number of handles is used to represent the number of unreleased handles of each process.

[0090] Specifically, the handle change trend value of each process is, for example, the slope of the statistical curve corresponding to the handles of each process, the smoothing rate corresponding to the handles of each process, the business statistical standard value corresponding to the handles of each process, etc. A handle is, for example, a file handle, a business handle, etc. A business handle is a handle used in the business field. Business handles include, for example, Transmission Control Protocol handles (TCP handles), database operation handles (DB handles), etc.

[0091] S203. Based on the handle change trend value of each process, determine whether there is a handle leak in each process.

[0092] Specifically, for example, detection method 1 includes: for N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the file handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the file handle of each process is greater than or equal to a preset smoothing rate threshold, then it is determined that each process has a handle leak, where N is a positive integer; in this way, for the file handle, through detection method 1, that is, by statistically analyzing the change trend of the file handle, it is possible to more quickly determine whether a process has a handle leak, thereby improving the efficiency of handle leak detection.

[0093] For example, detection method 1 includes: for N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the service handle of each process is greater than or equal to a preset smoothing rate threshold, then it is determined that each process has a handle leak, where N is a positive integer; detection method 2 includes: for N consecutive detection cycles among multiple detection cycles, if the service statistical index value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, then it is determined that each process has a handle leak, where N is a positive integer; for the service handle, detection method 1 and detection method 2 are respectively executed simultaneously. If it is detected by any one of detection method 1 and detection method 2 that a process has a handle leak, then it is determined that the process has a handle leak; in this way, for the service handle, handle leak detection is performed simultaneously through two detection methods (detection method 1 and detection method 2), improving the accuracy of handle leak detection and also improving the efficiency of handle leak detection.

[0094] Based on the handle change trend value of each process, determine whether each process has a handle leak; in this way, by statistically analyzing the change trend of the handle, it is possible to more quickly determine whether each process has a handle leak, thereby improving the efficiency of handle leak detection.

[0095] In the embodiments of the present application, time series data of the handles of each process in at least one process is obtained, and the handle of each process is used to represent the un-released handles of each process; based on the time series data of the handles of each process, the handle change trend value of each process is determined, and the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of un-released handles of each process; based on the handle change trend value of each process, determine whether each process has a handle leak; in this way, by statistically analyzing the change trend of the handle, it is possible to more quickly determine whether a process has a handle leak, thereby improving the efficiency of handle leak detection.

[0096] In one embodiment, obtaining time - series data of the handles of each process in at least one process includes steps A1 - A2:

[0097] Step A1, for each process in at least one process, obtaining the number of handles of each process at each time point within at least one collection period.

[0098] Specifically, the smaller the collection interval corresponding to the collection period, the more accurate the result of handle leak judgment. Because the smaller the collection interval, the more information about the handles can be collected. However, the smaller the collection interval, the higher the collection frequency, which causes a greater loss to the system performance. If the collection interval is too large, less information about the handles is collected, and the result of handle leak judgment may not be accurate. Therefore, considering the system performance and the accuracy of handle leak judgment comprehensively, for example, the value range of the collection period is set between 10 seconds and 60 seconds.

[0099] Step A2, based on the number of handles of each process at each time point, determining the time - series data of the handles of each process. The time - series data of the handles of each process includes each time point and the number of handles of each process at each time point.

[0100] Specifically, for example, the time points are 10:01, 10:02, and 10:03 respectively, and each process at each time point is Process 1, Process 2, and Process 3 respectively; at 10:01, the number of handles of Process 1 is 26, the number of handles of Process 2 is 30, and the number of handles of Process 3 is 15; at 10:02, the number of handles of Process 1 is 30, the number of handles of Process 2 is 10, and the number of handles of Process 3 is 25; at 10:03, the number of handles of Process 1 is 40, the number of handles of Process 2 is 20, and the number of handles of Process 3 is 35. Based on the number of handles of each process at each time point, determining the time - series data of the handles of each process. The time - series data of Process 1 is {(10:01, Process 1, number of handles 26), (10:02, Process 1, number of handles 30), (10:03, Process 1, number of handles 40)}, the time - series data of Process 2 is {(10:01, Process 2, number of handles 30), (10:02, Process 2, number of handles 10), (10:03, Process 2, number of handles 20)}, and the time - series data of Process 3 is {(10:01, Process 3, number of handles 15), (10:02, Process 3, number of handles 25), (10:03, Process 3, number of handles 35)}.

[0101] In one embodiment, for each process in at least one process, obtaining the number of handles of each process at each time point within at least one collection period includes:

[0102] For each process in at least one process, obtain the number of handles of the file handles of each process at each time point within at least one collection period through a preset process system utility.

[0103] Specifically, the preset process system utility is, for example, the open-source library gopsutil in the Go language, and the handle is, for example, a file handle. For example, for each process in multiple processes, obtain the number of handles of the file handles of each process at each time point within the collection period through the open-source library gopsutil in the Go language.

[0104] It should be noted that using the open-source library gopsutil in the Go language to collect and analyze the number of handles of processes has a low technical threshold, accurate data collection, and lower program complexity compared to other methods.

[0105] In one embodiment, based on the time series data of the handles of each process, determine the handle change trend value of each process, including:

[0106] For a preset multiple detection periods, based on the time series data of the handles of each process, determine the handle change trend value of each process in each detection period. The handle change trend value of each process includes at least one of the statistical curve slope corresponding to the handle of each process, the smoothing rate corresponding to the handle of each process, and the business statistical index value corresponding to the handle of each process.

[0107] Specifically, the detection period refers to detecting the change trend of the handle data (such as the number of handles) within this period every certain time. For example, detect the change trend of the handle data (such as the number of handles) within this detection period every 10 minutes or 60 minutes. The statistical curve slope corresponding to the handle of each process is used to characterize the growth trend of the number of handles of each process within a predetermined time period; the smoothing rate corresponding to the handle of each process is used to characterize the smoothness of the number of handles of each process within a predetermined time period; the business statistical index value is, for example, the Transmission Control Protocol (TCP) index value, and the Transmission Control Protocol (TCP) index value corresponding to the handle of each process is used to characterize the number of Transmission Control Protocol handles (TCP handles) in the closed-wait state (such as the CLOSE_WAIT state) for each process within a predetermined time period.

[0108] For example, the calculation method of the slope of the statistical curve corresponding to the handle of a process includes: x represents the time serial number of the collected data (information of the handle of the process, and the information of the handle includes the number of handles), and the time serial number is, for example, 12:00, 12:10, 12:20, etc., and y represents the number of handles of the process; by fitting the least squares line with x and y, a line with x as the abscissa and y as the ordinate is obtained, as well as the slope of this line. If the slope of this line is greater than 0, it indicates that this section of statistical data is in an upward trend, that is, the number of handles of the process is on the rise.

[0109] For example, the calculation formula (1) of the smoothing rate corresponding to the handle of a process is as follows:

[0110]

[0111] Wherein, t represents the smoothing rate, and y represents the number of handles of the process statistically by time; for example, y n is the number of handles at 12:00, and y n+1 is the number of handles at 12:30; n represents the time series mark. For example, the number of handles at 12:00 is 2, the number of handles at 12:10 is 2, and the number of handles at 12:20 is 3. The set of n is [12:00, 12:10, 12:20]. The time series mark corresponding to 12:00 is 1 (n = 1), the time series mark corresponding to 12:10 is 2 (n = 2), and the time series mark corresponding to 12:00 is 3 (n = 3).

[0112] It should be noted that the smoothing rate can represent the smoothness of the data. For example, if the absolute value of the smoothing rate is less than 15, it is determined that there are large fluctuations in the data, and it can be judged as interference, not handle leakage.

[0113] For example, the TCP metric value corresponding to the handle of a process is used to represent the number of handles of TCP handles in the CLOSE_WAIT state for each process within a predetermined time period; since the system sets the TCP connection cleanup time to 3 - 5 minutes, if the number of handles of TCP handles in the CLOSE_WAIT state in the system is greater than 5, it is determined that the process has handle leakage.

[0114] It should be noted that performing special handle detection on the TCP handles of the process improves the accuracy of TCP handle leakage detection.

[0115] In one embodiment, the handle change trend value of each process includes the slope of the statistical curve corresponding to the handle of each process. Based on the handle change trend value of each process, determining whether there is handle leakage for each process includes:

[0116] For N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, it is determined that there is a handle leak for each process. The slope of the statistical curve corresponding to the handle of each process is used to characterize the growth trend of the number of handles of each process within a predetermined time period, and N is a positive integer.

[0117] Specifically, the preset slope threshold is, for example, 0. For example, when N is 5, for 5 consecutive detection cycles, if the slope of the statistical curve corresponding to the handle of a certain process in each of the 5 consecutive detection cycles is greater than the preset slope threshold 0, it is determined that there is a handle leak for this process; among them, the number threshold is 4, that is, the value of N, which is 5, is greater than the number threshold 4, and it is determined that there is a handle leak for this process.

[0118] For another example, in the first detection cycle, the slope of the statistical curve corresponding to the handle of the process is greater than 0; in the second detection cycle, the slope of the statistical curve corresponding to the handle of the process is greater than 0; in the third detection cycle, the slope of the statistical curve corresponding to the handle of the process is greater than 0; in the fourth detection cycle, the slope of the statistical curve corresponding to the handle of the process is greater than 0; that is, the slope of the statistical curve corresponding to the handle of the process is greater than 0 for 4 consecutive times. If the number threshold is 3, then the number 4 (N is 4) is greater than the number threshold 3, and it is determined that there is a handle leak.

[0119] It should be noted that the number threshold (abnormal threshold) is usually within the range of 3 - 5. In this way, it can not only ensure the accuracy of detecting handle leaks but also ensure the timeliness of detecting handle leaks.

[0120] In one embodiment, the handle change trend value of each process includes the smoothing rate corresponding to the handle of each process. Based on the handle change trend value of each process, determining whether there is a handle leak for each process includes:

[0121] For N consecutive detection cycles among multiple detection cycles, if the absolute value of the smoothing rate corresponding to the handle of each process in each of the N consecutive detection cycles is less than a preset smoothing rate threshold, it is determined that there is no handle leak for each process. The smoothing rate corresponding to the handle of each process is used to characterize the smoothing degree of the number of handles of each process within a predetermined time period, and N is a positive integer.

[0122] Specifically, the preset smoothing rate threshold is, for example, 15. For example, N is set to 5. For five consecutive detection cycles, if the absolute value of the smoothing rate corresponding to the handle of a certain process in each of the five consecutive detection cycles is less than the preset smoothing rate threshold of 15, it is determined that there is no handle leak for this process. The smoothing rate can represent the smoothness of the data. For example, if the absolute value of the smoothing rate is less than the preset smoothing rate threshold of 15, it is determined that the data has large fluctuations and can be judged as interference rather than a handle leak.

[0123] In one embodiment, the handle change trend value of each process includes the statistical curve slope corresponding to the handle of each process and the smoothing rate corresponding to the handle of each process. Based on the handle change trend value of each process, determining whether there is a handle leak for each process includes:

[0124] For N consecutive detection cycles among multiple detection cycles, if the statistical curve slope corresponding to the handle of each process in each of the N consecutive detection cycles is greater than the preset slope threshold, and the absolute value of the smoothing rate corresponding to the handle of each process is greater than or equal to the preset smoothing rate threshold, it is determined that there is a handle leak for each process, where N is a positive integer.

[0125] Specifically, the preset slope threshold is, for example, 0, and the preset smoothing rate threshold is, for example, 15. For example, N is set to 5. For five consecutive detection cycles, if the statistical curve slope corresponding to the handle of a certain process in each of the five consecutive detection cycles is greater than the preset slope threshold of 0, and the absolute value of the smoothing rate corresponding to the handle of each process is greater than or equal to the preset smoothing rate threshold of 15, it is determined that there is a handle leak for this process; where the number threshold is set to 4, that is, the value of N, which is 5, is greater than the number threshold of 4, and it is determined that there is a handle leak for this process.

[0126] In one embodiment, the handle change trend value of each process includes the statistical curve slope corresponding to the handle of each process and the smoothing rate corresponding to the handle of each process. Based on the handle change trend value of each process, determining whether there is a handle leak for each process includes:

[0127] For N consecutive detection cycles among multiple detection cycles, if the statistical curve slope corresponding to the handle of each process in each of the N consecutive detection cycles is less than or equal to the preset slope threshold, or the absolute value of the smoothing rate corresponding to the handle of each process is less than the preset smoothing rate threshold, it is determined that there is no handle leak for each process, where N is a positive integer.

[0128] Specifically, for example, the preset slope threshold is 0, and the preset smoothing rate threshold is 15. For example, N is 5. For five consecutive detection cycles, if the slope of the statistical curve corresponding to the handle of a certain process in each of the five consecutive detection cycles is less than or equal to the preset slope threshold 0, or the absolute value of the smoothing rate corresponding to the handle of the process is less than the preset smoothing rate threshold 15, it is determined that there is no handle leak for the process.

[0129] In one embodiment, the handle of each process is a service handle. Based on the handle change trend value of each process, determining whether there is a handle leak for each process includes:

[0130] Based on at least one of the statistical curve slope corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical index value corresponding to the service handle of each process, determining whether there is a handle leak for each process.

[0131] Specifically, the service handle is a handle used in the service field. The service handle is, for example, a Transmission Control Protocol handle (TCP handle), a database operation handle (DB handle), etc.

[0132] For example, for N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than the preset slope threshold, and the absolute value of the smoothing rate corresponding to the service handle of each process is greater than or equal to the preset smoothing rate threshold, it is determined that there is a handle leak for each process, where N is a positive integer.

[0133] For example, if for N consecutive detection cycles among multiple detection cycles, the service statistical index value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than the preset index value threshold, it is determined that there is a handle leak for each process.

[0134] In one embodiment, based on the service statistical index value corresponding to the service handle of each process, determining whether there is a handle leak for each process includes:

[0135] If for N consecutive detection cycles among multiple detection cycles, the service statistical index value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than the preset index value threshold, it is determined that there is a handle leak for each process.

[0136] Specifically, the service handle is, for example, a Transmission Control Protocol handle, and the service statistical index value is, for example, a Transmission Control Protocol index value.

[0137] In one embodiment, the service handle is a Transmission Control Protocol (TCP) handle, and the service statistic index value is a TCP index value. Determining whether there is a handle leak for each process based on the service statistic index value corresponding to the service handle of each process includes:

[0138] If for N consecutive detection cycles among multiple detection cycles, the TCP index value corresponding to the TCP handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, it is determined that there is a handle leak for each process. The TCP index value corresponding to the TCP handle of each process is used to represent the number of handles of the TCP handles in the close-wait state within a predetermined time period for each process. N is a positive integer.

[0139] Specifically, for example, TCP handles in the close-wait state are selected from multiple TCP handles for statistics. TCP handles in the close-wait state are, for example, TCP handles in the CLOSE_WAIT state. The preset index value threshold is, for example, 5. For example, N is set to 4. If for 4 consecutive detection cycles, the TCP index value corresponding to the TCP handle of a certain process in each of the 4 consecutive detection cycles is greater than the preset index value threshold of 5, it is determined that there is a handle leak for that process; where the number threshold is set to 3, that is, the value of N, which is 4, is greater than the number threshold of 3, and it is determined that there is a handle leak for that process.

[0140] It should be noted that in the four-way handshake process as Figure 1 shown, if host B never performs the third handshake, it will cause a large number of connections in the CLOSE_WAIT state on host B; a large number of such situations will affect the server performance and may also cause the number of sockets to reach the server limit; the network connection is not released in a timely manner, usually because the server fails to close the connection after an exception or the configuration time of CLOSE_WAIT (the configuration time of CLOSE_WAIT is, for example, a CLOSE_WAIT will last for at least 2 hours) is too long, that is, when there are a large number of TCP handles in the CLOSE_WAIT state, the service program is abnormal and there is a handle leak; if it is a MySQL database, there may also be a possibility that after a transaction is started, it is not correctly rolled back or committed. That is, in MySQL, the client application communicates with the MySQL server through a TCP connection. When there are a large number of CLOSE_WAIT states, it means that the service program does not properly release the MySQL data TCP connection, that is, it means that the service program does not properly release the TCP handles of the MySQL data, and there is a handle leak at this time.

[0141] In one embodiment, determining whether there is a handle leak for each process based on the statistical curve slope corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical metric value corresponding to the service handle of each process includes:

[0142] For N consecutive detection cycles among multiple detection cycles, if the statistical curve slope corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the service handle of each process is greater than or equal to a preset smoothing rate threshold, or the service statistical metric value corresponding to the service handle of each process is greater than a preset metric value threshold, then it is determined that there is a handle leak for each process, where N is a positive integer.

[0143] Specifically, detection method 1 includes: for N consecutive detection cycles among multiple detection cycles, if the statistical curve slope corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the service handle of each process is greater than or equal to a preset smoothing rate threshold, then it is determined that there is a handle leak for each process. Detection method 2 includes: for N consecutive detection cycles among multiple detection cycles, if the service statistical metric value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset metric value threshold, then it is determined that there is a handle leak for each process. For the service handle, detection method 1 and detection method 2 are respectively executed simultaneously. If a process is detected to have a handle leak through either detection method 1 or detection method 2, then it is determined that the process has a handle leak; thus, for the service handle, handle leak detection is performed simultaneously through two detection methods (detection method 1 and detection method 2), which improves the accuracy of handle leak detection and thereby improves the efficiency of handle leak detection.

[0144] In one embodiment, the time series data of the handles of each process includes each time point and the number of handles of each process at each time point. Based on the time series data of the handles of each process, determining the handle change trend value of each process in each detection cycle includes:

[0145] Based on the time sequence numbers corresponding to each time point and the number of handles of each process at each time point, by least squares fitting, a least squares line is determined, and the slope of the least squares line is determined as the statistical curve slope corresponding to the handle of each process.

[0146] Specifically, for example, based on the time sequence numbers corresponding to multiple time points and the number of handles of a certain process at multiple time points, by least squares fitting, a least squares line is determined, and the slope of the least squares line is determined as the statistical curve slope corresponding to the handle of the process.

[0147] For another example, the calculation method of the slope of the statistical curve corresponding to the handle of a process includes: x represents the time serial number of the collected data (information of the handle of a certain process, and the information of the handle includes the number of handles), and multiple time serial numbers are, for example, 12:00, 12:10, 12:20, etc.; y represents the number of handles of the process at multiple time points; by the least squares method, x and y are fitted into a least squares straight line, that is, a straight line with the abscissa being x and the ordinate being y is obtained, and the slope of this straight line. If the slope of this straight line is greater than 0, it means that this section of statistical data is in an upward trend, that is, the number of handles of this process is in a growing trend.

[0148] Applying the embodiments of the present application has at least the following beneficial effects:

[0149] Obtain the time series data of the handles of each process among multiple processes, where the handle of each process is used to represent the un-released handles of each process; based on the time series data of the handles of each process, determine the handle change trend value of each process, and the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period; based on the handle change trend value of each process, determine whether there is a handle leak in each process; in this way, by statistically analyzing the change trend of the handles, it is possible to more quickly determine whether there is a handle leak in the process, thereby improving the efficiency of handle leak detection. Use the open-source library gopsutil of the Go language to collect and analyze the number of handles of the process, which has a low technical threshold, accurate data collection, and lower program complexity compared to other methods. Special handle detection is performed on the TCP handles of the process, which improves the accuracy of TCP handle leak detection. Timely discover the handle leaks existing in the processes in the system, thereby reducing the probability of accidents caused by handle leaks in the production environment programs.

[0150] To better understand the method provided by the embodiments of the present application, the following further describes the solution of the embodiments of the present application in combination with examples of specific application scenarios.

[0151] In an embodiment of a specific application scenario, for example, in the handle leak detection scenario, refer to Figure 4 , which shows the processing flow of a detection method. As Figure 4 shown, the processing flow of the detection method provided by the embodiments of the present application includes the following steps:

[0152] S401, the backend server obtains the time series data of the handles of each process among multiple processes.

[0153] Specifically, for example, as Figure 5As shown, the number of handles of each process is collected by a backend program in the backend server, and the number of handles of each process at each time point is obtained; based on the number of handles of each process at each time point, the time series data of the handles of each process is obtained; for example, the time series data of process 1 is {(10:01, process 1, number of handles 26), (10:02, process 1, number of handles 30), (10:03, process 1, number of handles 40)}, the time series data of process 2 is {(10:01, process 2, number of handles 30), (10:02, process 2, number of handles 10), (10:03, process 2, number of handles 20)}, and the time series data of process 3 is {(10:01, process 3, number of handles 15), (10:02, process 3, number of handles 25), (10:03, process 3, number of handles 35)}.

[0154] S402. The backend server saves the time series data of the handles of each process to a time series database.

[0155] Specifically, for example, as Figure 5 shown, the time series data of the handles of each process is saved to a time series database. The time series database is, for example, an Elasticsearch database. The time series data stored in the time series database is used to determine handle leaks and for post-mortems after determining handle leaks.

[0156] S403. Based on the time series data of the handles of each process, handle leak detection is performed to determine whether there is a handle leak in each process.

[0157] Specifically, for example, as Figure 5 shown, handle leak detection is performed based on the time series data of the handles of each process.

[0158] For example, as Figure 6 shown, the handle leak detection includes steps S601 - S610:

[0159] Step S601. The current handle leak detection starts.

[0160] Step S602. Determine whether the handle leak detection time difference is greater than 60 minutes. If the handle leak detection time difference is greater than 60 minutes, go to step S604 for processing; if the handle leak detection time difference is not greater than 60 minutes, go to step S609 for processing.

[0161] Specifically, the handle leak detection time difference = current time - last handle leak detection time. For example, the change trend of handle data (such as the number of handles) is detected every 60 minutes.

[0162] Step S603: Determine whether the handle leakage detection time difference is greater than 10 minutes. If the handle leakage detection time difference is greater than 10 minutes, proceed to step S605; if the handle leakage detection time difference is not greater than 10 minutes, proceed to step S609.

[0163] Specifically, the handle leakage detection time difference = current time - last handle leakage detection time. For example, the change trend of handle data (such as the number of handles) is detected every 10 minutes.

[0164] Step S604: Based on the time series data of the handles of each process among multiple processes, determine the statistical curve slope corresponding to the handle of each process and the smoothing rate corresponding to the handle of each process during the detection period; proceed to step S606 for execution.

[0165] Step S605: Based on the time series data of the handles of each process among multiple processes, determine the Transmission Control Protocol (TCP) metric values corresponding to the handles of each process during the detection period.

[0166] Step S606: Determine whether the statistical curve slope corresponding to the handle of each process and the smoothing rate corresponding to the handle of each process trigger the number threshold, or determine whether the TCP metric values corresponding to the handles of each process trigger the number threshold; if it is determined that the number threshold is triggered, proceed to step S607 for processing; if it is determined that the number threshold is not triggered, proceed to step S608 for processing.

[0167] Specifically, for example, if the statistical curve slope corresponding to the handle of a certain process in each detection period of N consecutive detection periods is greater than the preset slope threshold, the absolute value of the smoothing rate corresponding to the handle of this process is greater than or equal to the preset smoothing rate threshold, and N is greater than the number threshold (abnormal threshold), it is determined that the number threshold is triggered; N is a positive integer.

[0168] For example, if the TCP metric value corresponding to the handle of a certain process in each detection period of N consecutive detection periods is greater than the preset metric value threshold, and N is greater than the number threshold (abnormal threshold), it is determined that the number threshold is triggered; N is a positive integer.

[0169] Step S607: Report the handle leakage event.

[0170] Specifically, the backend server reports the handle leakage event to the frontend server.

[0171] Step S608: Enter the next detection period.

[0172] Step S609: Sample and statistically analyze the process data.

[0173] Specifically, sample and statistically analyze the process data. For example, Figure 5As shown in the figure, the number of handles of each process among multiple processes is collected by a backend program in the backend server, and the number of handles of each process at each time point is obtained; based on the number of handles of each process at each time point, the time series data of the handles of each process is obtained.

[0174] Step S610, the current handle leak detection ends, and it goes to step S601 to execute the next detection cycle.

[0175] S404, if there is a handle leak in at least one process among multiple processes, the backend server reports the handle leak event to the frontend server.

[0176] Specifically, for example, as Figure 5 shown, the backend server reports the handle leak event to the frontend server.

[0177] S405, the frontend server receives the handle leak event reported by the backend server.

[0178] Specifically, for example, as Figure 5 shown, the frontend server receives the handle leak event reported by the backend server through the frontend program.

[0179] S406, the frontend server records the handle leak event; and initiates an alarm to notify relevant personnel.

[0180] Specifically, for example, as Figure 5 shown, the frontend server records the handle leak event; and initiates an alarm to notify relevant personnel.

[0181] It should be noted that by applying the embodiments of the present application, in the normal detection of production, development, test and other environments, the handle leak of the service process in the system can be found in time; during the stress testing of the application program, the handle leak of the object under test can be found in time.

[0182] Applying the embodiments of the present application has at least the following beneficial effects:

[0183] By statistically analyzing the change trend of handles, it is possible to more quickly determine whether there is a handle leak in a process, thereby improving the efficiency of handle leak detection; by statistically analyzing the change trend of handles, special handle detection is performed on the TCP handles of the process, improving the accuracy of TCP handle leak detection; timely discovering the handle leak existing in the processes in the system, thereby reducing the probability of accidents caused by handle leak in the production environment program.

[0184] The embodiments of the present application also provide a detection device, and the structural schematic diagram of the detection device is as Figure 7 shown, the detection device 60 includes a first processing module 601, a second processing module 602 and a third processing module 603.

[0185] The first processing module 601 uses the time series data of the handles of each process in at least one process, and the handle of each process is used to represent the un-released handles of each process;

[0186] The second processing module 602 is used to determine the handle change trend value of each process based on the time series data of the handles of each process. The handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of un-released handles of each process;

[0187] The third processing module 603 is used to determine whether there is a handle leak in each process based on the handle change trend value of each process.

[0188] In one embodiment, the first processing module 601 is specifically used for:

[0189] For each process in at least one process, obtain the number of handles of each process at each time point within at least one collection period;

[0190] Based on the number of handles of each process at each time point, determine the time series data of the handles of each process. The time series data of the handles of each process includes each time point and the number of handles of each process at each time point.

[0191] In one embodiment, the first processing module 601 is specifically used for:

[0192] For each process in at least one process, obtain the number of handles of the file handles of each process at each time point within at least one collection period through a preset process system utility.

[0193] In one embodiment, the second processing module 602 is specifically used for:

[0194] For a preset plurality of detection periods, based on the time series data of the handles of each process, determine the handle change trend value of each process in each detection period. The handle change trend value of each process includes at least one of the statistical curve slope corresponding to the handle of each process, the smoothing rate corresponding to the handle of each process, and the business statistical index value corresponding to the handle of each process.

[0195] In one embodiment, the handle change trend value of each process includes the statistical curve slope corresponding to the handle of each process. The third processing module 603 is specifically used for:

[0196] For N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, it is determined that there is a handle leak for each process. The slope of the statistical curve corresponding to the handle of each process is used to characterize the growth trend of the number of handles of each process within a predetermined time period, and N is a positive integer.

[0197] In one embodiment, the handle change trend value of each process includes the smoothing rate corresponding to the handle of each process. The third processing module 603 is specifically configured to:

[0198] For N consecutive detection cycles among multiple detection cycles, if the absolute value of the smoothing rate corresponding to the handle of each process in each of the N consecutive detection cycles is less than a preset smoothing rate threshold, it is determined that there is no handle leak for each process. The smoothing rate corresponding to the handle of each process is used to characterize the smoothness of the number of handles of each process within a predetermined time period, and N is a positive integer.

[0199] In one embodiment, the handle change trend value of each process includes the slope of the statistical curve corresponding to the handle of each process and the smoothing rate corresponding to the handle of each process. The third processing module 603 is specifically configured to:

[0200] For N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the handle of each process is greater than or equal to a preset smoothing rate threshold, it is determined that there is a handle leak for each process, and N is a positive integer.

[0201] In one embodiment, the handle of each process is a service handle. The third processing module 603 is specifically configured to:

[0202] Based on at least one of the slope of the statistical curve corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical index value corresponding to the service handle of each process, it is determined whether there is a handle leak for each process.

[0203] In one embodiment, the third processing module 603 is specifically configured to:

[0204] For N consecutive detection cycles among multiple detection cycles, if the service statistical index value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, it is determined that there is a handle leak for each process.

[0205] In one embodiment, the service handle is a Transmission Control Protocol (TCP) handle, and the service statistical index value is a TCP index value. The third processing module 603 is specifically configured to:

[0206] If, for N consecutive detection cycles among multiple detection cycles, the Transmission Control Protocol (TCP) metric values corresponding to the TCP handles of each process in each of the N consecutive detection cycles are all greater than a preset metric value threshold, it is determined that there is a handle leak in each process. The TCP metric values corresponding to the TCP handles of each process are used to represent the number of handles of the TCP handles in the close-wait state for each process within a predetermined time period. N is a positive integer.

[0207] In one embodiment, the third processing module 603 is specifically configured to:

[0208] For N consecutive detection cycles among multiple detection cycles, if the slope of the statistical curve corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the service handle of each process is greater than or equal to a preset smoothing rate threshold, or the service statistical metric value corresponding to the service handle of each process is greater than a preset metric value threshold, it is determined that there is a handle leak in each process. N is a positive integer.

[0209] In one embodiment, the time series data of the handles of each process includes each time point and the number of handles of each process at each time point. The second processing module 602 is specifically configured to:

[0210] Based on the time sequence numbers corresponding to each time point and the number of handles of each process at each time point, by fitting using the least squares method, a least squares line is determined, and the slope of the least squares line is determined as the slope of the statistical curve corresponding to the handle of each process.

[0211] Applying the embodiments of the present application has at least the following beneficial effects:

[0212] Obtain the time series data of the handles of each process in at least one process. The handles of each process are used to represent the unreleased handles of each process; based on the time series data of the handles of each process, determine the handle change trend value of each process. The handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period. The number of handles is used to represent the number of unreleased handles of each process; based on the handle change trend value of each process, determine whether there is a handle leak in each process. In this way, by statistically analyzing the change trend of the handles, it is possible to more quickly determine whether there is a handle leak in a process, thereby improving the efficiency of handle leak detection.

[0213] The embodiments of the present application also provide an electronic device. The structural schematic diagram of the electronic device is as Figure 8 shown Figure 8The electronic device 4000 shown includes: a processor 4001 and a memory 4003. Among them, the processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 can be used for data interaction between this electronic device and other electronic devices, such as data transmission and / or data reception, etc. It should be noted that in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation to the embodiments of the present application.

[0214] The processor 4001 may be a CPU (Central Processing Unit, central processor), a general-purpose processor, a DSP (Digital Signal Processor, data signal processor), an ASIC (Application Specific Integrated Circuit, application-specific integrated circuit), an FPGA (Field Programmable Gate Array, field programmable gate array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in combination with the disclosure of the present application. The processor 4001 may also be a combination that implements computing functions, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0215] The bus 4002 may include a path for transmitting information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 8 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0216] The memory 4003 can be a ROM (Read Only Memory), or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory), or other types of dynamic storage devices that can store information and instructions. It can also be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, which is not limited herein.

[0217] The memory 4003 is used to store the computer program for implementing the embodiments of the present application and is controlled by the processor 4001 to execute. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0218] Among them, the electronic device includes but is not limited to: servers, etc.

[0219] Applying the embodiments of the present application has at least the following beneficial effects:

[0220] Obtain the time series data of the handles of each process in at least one process, where the handle of each process is used to represent the unreleased handles of each process; based on the time series data of the handles of each process, determine the handle change trend value of each process, where the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period; based on the handle change trend value of each process, determine whether there is a handle leak in each process, and the number of handles is used to represent the number of unreleased handles of each process; thus, by statistically analyzing the change trend of the handles, it is possible to more quickly determine whether there is a handle leak in the process, thereby improving the efficiency of handle leak detection.

[0221] The embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it can implement the steps and corresponding contents of the foregoing method embodiments.

[0222] The embodiments of the present application further provide a computer program product, including a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding contents of the foregoing method embodiments.

[0223] Based on the same principle as the method provided in the embodiments of the present application, the embodiments of the present application also provide a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in any optional embodiment of the present application described above.

[0224] It should be understood that although the flowchart of the embodiments of the present application indicates each operation step by an arrow, the execution order of these steps is not limited to the order indicated by the arrow. Unless otherwise clearly stated in this application, in some implementation scenarios of the embodiments of the present application, the implementation steps in each flowchart can be executed in other orders according to requirements. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage among these sub-steps or stages can also be executed at different times respectively. In the scenario where the execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and the embodiments of the present application do not limit this.

[0225] The above are only optional implementation manners of some implementation scenarios of the present application. It should be noted that for those of ordinary skill in the art in the technical field of the present application, without departing from the technical concept of the solution of the present application, adopting other similar implementation means based on the technical idea of the present application also belongs to the protection scope of the embodiments of the present application.

Claims

1. A detection method, characterized in that, Including: Obtaining time series data of the handles of each process in at least one process, where the handle of each process is used to characterize the unreleased handles of each process; Based on the time series data of the handles of each process, determining a handle change trend value for each process, where the handle change trend value for each process is used to characterize the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to characterize the number of unreleased handles of each process; Based on the handle change trend value of each process, determining whether there is a handle leak in each process.

2. The method according to claim 1, wherein The obtaining time series data of the handles of each process in at least one process includes: For each process in at least one process, obtaining the number of handles of each process at each time point within at least one collection period; Based on the number of handles of each process at each time point, determining the time series data of the handles of each process, where the time series data of the handles of each process includes each time point and the number of handles of each process at each time point.

3. The method according to claim 2, wherein The for each process in at least one process, obtaining the number of handles of each process at each time point within at least one collection period includes: For each process in at least one process, through a preset process system utility, obtaining the number of handles of the file handles of each process at each time point within at least one collection period.

4. The method according to claim 1, characterized in that The based on the time series data of the handles of each process, determining the handle change trend value for each process includes: For a preset plurality of detection periods, based on the time series data of the handles of each process, determining the handle change trend value for each process in each detection period, where the handle change trend value for each process includes at least one of the statistical curve slope corresponding to the handle of each process, the smoothing rate corresponding to the handle of each process, and the service statistical index value corresponding to the handle of each process.

5. The method according to claim 4, wherein The handle change trend value for each process includes the statistical curve slope corresponding to the handle of each process. The based on the handle change trend value of each process, determining whether there is a handle leak in each process includes: For N consecutive detection periods among the plurality of detection periods, if the statistical curve slope corresponding to the handle of each process in each of the N consecutive detection periods is greater than a preset slope threshold, it is determined that there is a handle leak in each process. The statistical curve slope corresponding to the handle of each process is used to characterize the growth trend of the number of handles of each process within the predetermined time period, and N is a positive integer.

6. The method according to claim 4, characterized in that The handle change trend value for each process includes the smoothing rate corresponding to the handle of each process. The based on the handle change trend value of each process, determining whether there is a handle leak in each process includes: For N consecutive detection cycles among the multiple detection cycles, if the absolute value of the smoothing rate corresponding to the handle of each process in each of the N consecutive detection cycles is less than a preset smoothing rate threshold, it is determined that there is no handle leak for each process. The smoothing rate corresponding to the handle of each process is used to characterize the smoothing degree of the number of handles of each process within the predetermined time period, and N is a positive integer.

7. The method according to claim 4, characterized in that, The handle change trend value of each process includes the statistical curve slope corresponding to the handle of each process and the smoothing rate corresponding to the handle of each process. Determining whether there is a handle leak for each process based on the handle change trend value of each process includes: For N consecutive detection cycles among the multiple detection cycles, if the statistical curve slope corresponding to the handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the handle of each process is greater than or equal to the preset smoothing rate threshold, it is determined that there is a handle leak for each process, and N is a positive integer.

8. The method according to claim 4, characterized in that The handle of each process is a service handle. Determining whether there is a handle leak for each process based on the handle change trend value of each process includes: Based on at least one of the statistical curve slope corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical index value corresponding to the service handle of each process, determine whether there is a handle leak for each process.

9. The method according to claim 8, wherein Determining whether there is a handle leak for each process based on the service statistical index value corresponding to the service handle of each process includes: For N consecutive detection cycles among the multiple detection cycles, if the service statistical index value corresponding to the service handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, it is determined that there is a handle leak for each process.

10. The method according to claim 8, wherein The service handle is a Transmission Control Protocol (TCP) handle, and the service statistical index value is a TCP index value. Determining whether there is a handle leak for each process based on the service statistical index value corresponding to the service handle of each process includes: For N consecutive detection cycles among the multiple detection cycles, if the TCP index value corresponding to the TCP handle of each process in each of the N consecutive detection cycles is greater than a preset index value threshold, it is determined that there is a handle leak for each process. The TCP index value corresponding to the TCP handle of each process is used to characterize the number of TCP handles in the close-wait state for each process within the predetermined time period, and N is a positive integer.

11. The method according to claim 8, wherein Determining whether there is a handle leak for each process based on the statistical curve slope corresponding to the service handle of each process, the smoothing rate corresponding to the service handle of each process, and the service statistical index value corresponding to the service handle of each process includes: For N consecutive detection cycles among the multiple detection cycles, if the slope of the statistical curve corresponding to the business handle of each process in each of the N consecutive detection cycles is greater than a preset slope threshold, and the absolute value of the smoothing rate corresponding to the business handle of each process is greater than or equal to a preset smoothing rate threshold, or the business statistical index value corresponding to the business handle of each process is greater than a preset index value threshold, it is determined that there is a handle leak for each process, where N is a positive integer.

12. The method according to claim 4, wherein The time series data of the handles of each process includes each time point and the number of handles of each process at each of the time points. Determining the handle change trend value of each process in each detection cycle based on the time series data of the handles of each process includes: Based on the time sequence numbers corresponding to the respective time points and the number of handles of each process at each of the time points, a least-squares line is determined by least-squares fitting, and the slope of the least-squares line is determined as the statistical curve slope corresponding to the handle of each process.

13. A detection device, characterized in that, Includes: A first processing module that obtains the time series data of the handles of each process in at least one process, where the handle of each process is used to represent the un-released handle of each process; A second processing module that is used to determine the handle change trend value of each process based on the time series data of the handles of each process, where the handle change trend value of each process is used to represent the change trend of the number of handles of each process within a predetermined time period, and the number of handles is used to represent the number of un-released handles of each process; A third processing module that is used to determine whether there is a handle leak for each process based on the handle change trend value of each process.

14. An electronic device, comprising a memory, a processor, and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-12.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1-12.