WO2014187431A1 - 判断资源泄漏、预测资源使用情况的方法及装置 - Google Patents

判断资源泄漏、预测资源使用情况的方法及装置 Download PDF

Info

Publication number
WO2014187431A1
WO2014187431A1 PCT/CN2014/080271 CN2014080271W WO2014187431A1 WO 2014187431 A1 WO2014187431 A1 WO 2014187431A1 CN 2014080271 W CN2014080271 W CN 2014080271W WO 2014187431 A1 WO2014187431 A1 WO 2014187431A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource usage
program
program running
component
period
Prior art date
Application number
PCT/CN2014/080271
Other languages
English (en)
French (fr)
Inventor
李静辉
龚学文
袁健清
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP14801434.3A priority Critical patent/EP2911060B1/en
Publication of WO2014187431A1 publication Critical patent/WO2014187431A1/zh
Priority to US14/922,595 priority patent/US9846601B2/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5055Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering software capabilities, i.e. software resources associated or available to the machine
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/008Reliability or availability analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/81Threshold
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5019Workload prediction

Definitions

  • the present invention relates to the field of computer applications, and in particular, to a method and apparatus for judging a program running resource leakage, and a method and apparatus for predicting a program operating resource usage situation.
  • Program running resources such as memory, file handles, semaphores, database connection pools, thread pools, etc.
  • Program running resources are key resources required for a program to run.
  • the program makes an application when it needs to use the program running resources, and releases the occupied program running resources in time after the use ends; if the occupied program running resources are not released in time, the program running resource leakage problem occurs.
  • Memory leak refers to the memory that is no longer used by the program due to design or coding problems. As a result, the available memory of the system is less and less. As the program runs for a long time, the memory leak becomes more and more serious, which may eventually lead to the system. Business is damaged or interrupted due to insufficient memory. Memory leaks are problems that are easy to occur and difficult to avoid during program operation. As software becomes larger and more complex, the probability of memory leaks in the system increases.
  • static analysis This method does not require running the program. Instead, it analyzes the program code by manual or automated tools to check the memory allocation and release in the code. Match the situation.
  • static analysis methods can usually detect potential memory leaks, but the corresponding relationship between memory allocation and release is complicated, such as allocating memory in a function. Static analysis methods are often prone to errors and omissions in one or more functions that release corresponding memory.
  • the second way to detect memory leaks is to dynamically monitor memory allocation during program execution. To manage all relevant memory allocations and releases in the program, and to accurately determine the life cycle of the memory, resulting in complex implementation and high system performance consumption; on the other hand, in order to achieve the takeover of the memory allocation function and the release function, It is necessary to make corresponding code modifications according to the specific application, and the target system of detection is closely coupled and the versatility is poor. In addition, the prior art can only detect whether there is a memory leak, and for future memory usage, such as how long after the memory is exhausted or how long the memory usage will reach a set threshold, etc., cannot provide prediction .
  • Embodiments of the present invention provide a method and apparatus for determining a program operation resource leakage, which are used to solve the existing method for detecting resource leakage of a detection program, which is prone to false alarms and false negatives, and consumes large system performance and versatility. Poor question.
  • a method for determining a resource leakage of a program operation including:
  • Run the resource usage period for any two programs determine the difference between the program running resource usage for each collection in the subsequent period, and the program running resource usage for the corresponding secondary collection in the previous period, where in the latter period
  • the time difference between the time of each set and the start time of the latter period, and the time difference between the time of the corresponding secondary set in the previous period and the start time of the previous period is within a preset range;
  • the preset range is: Describe a time length range of a minimum time interval in a time interval of each adjacent two sets in the previous period, or the preset range is: less than the time of each adjacent two sets in the subsequent period The length of time interval for the minimum time interval in the interval.
  • determining a program running resource usage amount for each collection in a subsequent period, and a difference between a program running resource usage amount of the corresponding secondary collection in the previous period Also includes:
  • Running resource leaks including:
  • the range of the threshold is greater than or equal to 0, and is less than or equal to a difference of greater than 0 among the determined differences. 70% of the sum of the total and the total number of differences less than zero.
  • Running resource leaks including:
  • determining a statistic Z of the difference S> between the total number of differences greater than 0 and the total difference value less than 0 according to the following formula : If?? ⁇ 10, then ⁇ 7 ⁇ ; where ⁇ is the number of cycles in which the program runs resources;
  • the threshold is a quantized value determined according to a probability distribution of the statistic Z.
  • the second aspect provides an apparatus for judging a program running resource leakage, including: a collection module, configured to collect resource usage of the program at least once during each program running resource usage period, and execute the resource of the collected program The usage quantity is transmitted to the determining module, wherein the number of times the program runs the resource usage amount is the same in each program running resource usage period; the program running resource usage period is set according to the periodic law of the program running resource usage amount. Cycle
  • a determining module configured to receive a program running resource usage amount collected by the collection module each time, and run a resource usage period for any two programs, and determine a program running resource usage amount of each time in the subsequent period, and The difference between the resource usage of the program corresponding to the secondary set in the previous period, and the determined differences are transmitted to the judging module, wherein the time of each set in the post period is the start time of the post period The time difference, and the time difference between the time of the corresponding secondary set in the previous period and the start time of the preceding period is within a preset range;
  • a judging module configured to receive each difference value determined by the determining module, and determine, according to a difference between a total number of differences greater than 0 among the determined differences and a total difference value less than 0, whether the program running resource exists Source leak.
  • the preset range is: a time length range smaller than a minimum time interval in a time interval of each adjacent two sets in the previous period, or
  • the preset range is: a time length range smaller than a minimum time interval in a time interval of each adjacent two sets in the subsequent period.
  • the determining module is specifically configured to: if the difference between the total number of differences greater than 0 and the total number of differences less than 0 is greater than a set threshold, The program runs a resource leak.
  • the range of the threshold is greater than or equal to 0, and is less than or equal to a difference of greater than 0 among the determined differences. 70% of the sum of the total and the total number of differences less than zero.
  • the determining module is specifically configured to: determine a statistic Z of the difference between the total number of differences greater than 0 and the total number of differences less than 0;
  • the determining module is specifically configured to determine, according to the following formula, the total number of differences greater than 0 and the total number of differences less than 0
  • the difference S ' statistic Z is specifically configured to determine, according to the following formula, the total number of differences greater than 0 and the total number of differences less than 0
  • the difference S ' statistic Z is specifically configured to determine, according to the following formula, the total number of differences greater than 0 and the total number of differences less than 0.
  • the threshold is a quantized value determined according to a probability distribution of the statistic Z.
  • a device for determining a resource leakage of a program operation including:
  • a processor configured to collect resource usage of the program at least once during each program running resource usage period; wherein, the number of times the program runs the resource usage is the same in each program running resource usage period;
  • the program runs the resource usage period, and determines the difference between the program running resource usage of each collection in the subsequent period and the program running resource usage of the corresponding secondary collection in the previous period, wherein each time in the subsequent period Time difference from the start time of the post cycle, and the time difference between the time of the corresponding secondary set in the previous cycle and the start time of the previous cycle is within a preset range;
  • the program running resource use period is a period set according to a periodic law of the program running resource usage;
  • a memory configured to store a program running resource usage amount of the processor each time and a determined program running resource usage amount in each subsequent period, and a program running resource corresponding to the second time set in the previous period The difference in usage.
  • a method for determining a resource leakage of a program operation including:
  • the time difference between the time of the corresponding secondary set and the start time of the previous period is within a preset range, wherein the preset range is: less than the interval of each adjacent set of times in the previous period
  • the length of the minimum time interval of the medium time interval, or the preset range is: a time length range smaller than the minimum time interval of the time interval of each adjacent two sets in the subsequent period;
  • the determined difference values if the difference between the total number of differences greater than 0 and the total number of differences less than 0 is greater than a set threshold, it is determined that there is a program running resource leak, wherein the range of the threshold is Greater than or equal to 0, and less than or equal to 70% of the sum of the total of the differences greater than 0 and the total difference of less than 0.
  • a method for determining a resource leakage of a program operation including:
  • Run the resource usage period for each of the two programs determine the difference between the program running resource usage for each collection in the subsequent period, and the program running resource usage for the corresponding subset in the previous period, where in the latter period
  • the time difference between the time of each set and the start time of the latter period, and the time difference between the time of the corresponding secondary set in the previous period and the start time of the previous period is within a preset range, wherein the pre- The range is: less than the length of time interval of the minimum time interval in the interval between each adjacent two sets in the previous period, or the preset range is: less than each adjacent in the subsequent period The length of time interval of the minimum time interval in the interval between two sets;
  • the statistic Z of the total number of differences greater than 0 and the total number of differences less than 0 is determined according to the following formula: Z, 1/2
  • R lk is the i-th program running resource usage collected during the resource usage period of the k-th program; for the i-th in the resource usage period of the first program running resource The secondary program runs the resource usage; m is the number of times the program runs the resource usage during the resource usage period of a program;
  • the threshold is a quantile value determined according to a probability distribution of the statistic Z.
  • a device for determining a resource leakage of a program operation including:
  • a collection module configured to collect resource usage of the program at least once during each program running resource usage period, wherein the number of times the program runs the resource usage is the same in each program running resource usage period;
  • the running resource usage period is a period set according to the periodic law of the running resource usage of the program;
  • Determining a module configured to run a resource usage period for each of the two programs, determining a difference between the program running resource usage for each of the collected processes in the subsequent period, and the program running resource usage for the corresponding secondary set in the previous period, The time difference between the time of each collection in the latter period and the start time of the subsequent period, and the time difference between the time of the corresponding secondary collection in the previous period and the start time of the preceding period is within a preset range,
  • the preset range is: a time length range smaller than a minimum time interval in each of the adjacent two sets of time intervals in the previous period, or the preset range is: less than the The length of time interval of the minimum time interval in the interval between each adjacent two sets of cycles Wai
  • a judging module configured to determine that there is a program running resource leak when the difference between the total number of differences greater than 0 and the total difference value less than 0 is greater than the set threshold value, wherein the range of the threshold value exists It is greater than or equal to 0, and is less than or equal to 70% of the sum of the total number of differences greater than 0 among the determined differences and the total number of differences less than 0.
  • a device for determining a resource leakage of a program operation including:
  • a collection module configured to collect resource usage of the program at least once during each program running resource usage period, wherein the number of times the program runs the resource usage is the same in each program running resource usage period;
  • the running resource usage period is a period set according to the periodic law of the running resource usage of the program;
  • Determining a module configured to run a resource usage period for each of the two programs, determining a difference between the program running resource usage for each of the collected processes in the subsequent period, and the program running resource usage for the corresponding secondary set in the previous period, The time difference between the time of each collection in the latter period and the start time of the subsequent period, and the time difference between the time of the corresponding secondary collection in the previous period and the start time of the preceding period is within a preset range,
  • the preset range is: a time length range smaller than a minimum time interval in each of the adjacent two sets of time intervals in the previous period, or the preset range is: less than the The length of time interval of the minimum time interval in the interval between each adjacent two sets of cycles;
  • a judging module configured to determine a statistic Z of the difference between the total number of differences greater than 0 and the total number of differences less than 0; if Z is greater than the set threshold, it is determined that there is a program running resource leak;
  • the determining module is specifically configured to determine, according to the following formula, a statistic Z of the difference s ' between the total number of differences greater than 0 and the total difference value less than 0:
  • n is the number of cycles in which the program is running VAR(S')
  • R lk is the i-th program running resource usage collected during the k-th program running resource usage period; ⁇ is the ith time of the set in the first program running resource usage period The amount of program running resource usage; m is the number of times the program runs the resource usage during the program life cycle of the program;
  • the threshold is a quantile value determined according to a probability distribution of the statistic Z.
  • the method for running a resource leak according to the first aspect or the fourth aspect or the fifth aspect provided by the fifth aspect, the second aspect or the third aspect or the sixth aspect or the seventh aspect, the device for determining a program running resource leakage,
  • the embodiment of the invention can realize the analysis of the program running resource usage of different program running resource use periods during the running of the program, so that the program running resource usage situation at different stages of the program running can be obtained, and the program running is accurately determined.
  • the embodiment of the present invention only needs to collect the running resource usage of the program intermittently in the running of the program, and determine whether there is a program running resource leakage after collecting the resource usage of the program for a certain number of times. , the system performance is low, and it is suitable for different target systems, and the versatility is strong.
  • the embodiment of the present invention further provides a method and a device for predicting the usage of a program running resource, which are used to solve the problem that the prior art cannot predict the use of the program running resource in the running process of the program.
  • a method for predicting usage of a program running resource includes: collecting at least one program running resource usage amount during each program running resource usage period;
  • the program running resource usage period is a period set according to a periodic law of the program running resource usage amount;
  • the program running resource usage of the set is decomposed into different kinds of resource components, and the different kinds of resource components are components that have different variation laws according to the usage rule of the running resource of the program;
  • the method before the compiled program running resource is used to decompose the usage into different resource components, the method further includes:
  • the decomposing the program running resource usage amount into different resource components including: decomposing the collected program running resource usage into a program running resource The seasonal component of the periodic variation in usage and the random component of the random variation that reflects the amount of resource used by the program; or
  • the program running resource usage of the collection is decomposed into a trend component reflecting the changing trend of the running resource usage of the program, a seasonal component reflecting the periodic variation of the running resource usage of the program, and a random variation reflecting the random variation of the running resource usage of the program. Component.
  • the prediction function of the trend component is to perform linear or nonlinear fitting on data included in the trend component. a linear function or a nonlinear function obtained with the predicted time as an independent variable;
  • the prediction function of the random component is a constant, and the constant is an upper quantile of the random component.
  • the determining, by using the determined prediction function of each resource component, the program running the resource overall prediction function includes: adding the determined prediction functions of each resource component, Get the overall prediction function of the program running resource.
  • the overall operational function of the program running resource is determined according to the following formula:
  • the resource component includes a periodically varying seasonal component and a random variation of the random variation i;
  • the resource component includes a trend component that reflects a trend of the usage of the program running resource and a random component that changes randomly; or
  • the resource component includes a trend component that reflects a trend of change in usage of the program operating resource, a seasonal component of the periodic change, and a random component of the random change;
  • the prediction function of the trend component is a linear function or a nonlinear function obtained by linearly fitting or nonlinearly fitting the data included in the trend component, and the predicted time is an independent variable or a nonlinear function;
  • the prediction function of the random component is a confidence upper limit determined based on the mean and standard deviation of the data contained in the random component.
  • a program running resource overall prediction function when the resource component includes a trend component, a seasonal component, and a random component, determining a program running resource overall prediction function according to the following formula:
  • R t is the overall prediction function of the program running resource: (a+bt ) is the prediction function of the trend component, a and b are constants; ( ⁇ +ka ) is the prediction function of the random component, where ⁇ For the mean of the data contained in the random component, ⁇ is the standard deviation of the data contained in the random component, and k is a constant.
  • the use of the program running resource is predicted based on the determined overall prediction function, including:
  • the number of times the program runs the resource usage during each program running resource usage period the same.
  • the second aspect provides an apparatus for predicting usage of a program running resource, including: a collection module, configured to collect resource usage of the program at least once during each program running resource usage period, and collect the collected program The running resource usage is transmitted to the decomposition module; the program running resource usage period is a period set according to a periodic rule of the program running resource usage amount; and the decomposition module is configured to receive the program running resource used by the collection module And decomposing the program running resource usage of the set into different resource components, and transmitting the data contained in each resource component to the determining module, where the different resource components are used according to the running resource of the program, Decomposing program operating resources into components with different variations;
  • a determining module configured to receive data included in each resource component decomposed by the decomposition module, determine a prediction function of the resource component for each data component, and determine each resource component according to each The prediction function determines a program running resource overall prediction function, and transmits the determined overall prediction function to the prediction module;
  • a prediction module configured to receive an overall prediction function determined by the determining module, and predict a usage of the running resource of the program based on the total prediction function.
  • the determining module is further configured to: before the collecting module decomposes the collected program running resource usage amount into different resource components, The total number of cycles or total number of times the program runs resource usage is not less than the set threshold, and/or the current program running resource occupancy rate is not less than the set threshold, and/or the current CPU CPU usage is less than the set value.
  • the threshold, and/or the current time is within the set time range.
  • the decomposition module is specifically configured to decompose the collected program running resource usage amount into a seasonal component that reflects a cyclical change of the running resource usage of the program, and implements the program running. a random component of the random variation of resource usage; or
  • the program running resource usage of the collection is decomposed into a trend component reflecting the changing trend of the running resource usage of the program, a seasonal component reflecting the periodic variation of the running resource usage of the program, and a random variation reflecting the random variation of the running resource usage of the program. Component.
  • the prediction function of the trend component is to perform linear or nonlinear fitting on data included in the trend component. a linear function or a nonlinear function obtained with the predicted time as an independent variable;
  • the prediction function of the random component is a constant, and the constant is an upper quantile of the random component.
  • the determining module is configured to: when determining, according to the determined prediction function of each resource component, the program running resource overall prediction function, specifically: using each of the determined resource components The prediction functions are added together to obtain the overall prediction function of the program running resource.
  • the determining module is configured to determine, according to the determined prediction function of each resource component, a program running resource overall prediction function, Specifically used to: Determine the overall forecast function of the program running resource according to the following formula:
  • the decomposed module resource component includes a cyclically changing seasonal component and a random component of the random variation ;
  • the resource component after the decomposition of the decomposition module includes a trend component that reflects a change trend of the usage resource usage of the program and a random component of the random change;
  • the resource component after the decomposition of the decomposition module includes a trend component that reflects a change trend of the program operation resource usage amount, a seasonal component that changes periodically, and a random component that changes the randomness;
  • the prediction function of the trend component is a linear function or a nonlinear function obtained by linearly fitting or nonlinearly fitting the data included in the trend component, and the predicted time is an independent variable or a nonlinear function;
  • the prediction function of the random component is a confidence upper limit determined based on the mean and standard deviation of the data contained in the random component.
  • the determining module is specifically configured to: when the resource component decomposed by the decomposition module includes a trend component, a seasonal component, and a random component, Determine the overall forecast function of the program running resource according to the following formula:
  • R t is the overall prediction function of the program running resource: (a+bt ) is the prediction function of the trend component, a and b are constants; ( ⁇ +ka ) is the prediction function of the random component, where ⁇ For the mean of the data contained in the random component, ⁇ is the standard deviation of the data contained in the random component, and k is a constant.
  • the predicting module is specifically configured to: predict, according to the determined overall prediction function, a program running resource usage amount in a future setting time, and/or a prediction program The time when the running resource is exhausted, and/or the time the forecasting program running resource usage will reach the set threshold in the future.
  • the number of times the program runs the resource usage during each program running resource usage period the same.
  • the third aspect provides an apparatus for predicting usage of a program running resource, including: a processor, configured to collect at least one program running resource usage amount in each program running resource usage period; The quantity is decomposed into different kinds of resource components, and the different kinds of resource components are components according to the usage rule of the running resource, and the program running resources are decomposed into components with different changing rules; for each data component, the data is determined.
  • the memory is configured to store the sequence running resource usage of the processor each time, the data included in the different resource components obtained by the decomposition, and the prediction function.
  • the fourth aspect provides a method for predicting usage of a program running resource, including: collecting at least one program running resource usage amount in each program running resource usage period; and decomposing the collected program running resource usage amount into: a trend component of a trend of a change in the amount of resource usage of the program, a seasonal component that reflects a periodic change in the amount of resource usage of the program, and a random component that exhibits a random change in the amount of resource usage of the program;
  • the prediction function of the trend component is to perform linear fitting or nonlinear fitting on the data included in the trend component, and the predicted time is an independent variable.
  • the prediction function of the random component is a constant, and the constant is an upper quantile of the random component.
  • predicting usage of the running resource of the program based on the determined overall prediction function includes:
  • a fourth possible implementation manner collecting resource usage of the program in each program running resource usage period The number of times is the same.
  • the program running resource usage period is a periodicity of running resource usage according to the program The period of regular setting.
  • the fifth aspect provides an apparatus for predicting usage of a program running resource, including: a collection module, configured to collect at least one program running resource usage amount in each program running resource usage period;
  • the decomposition module is used to decompose the program running resource usage of the collection into: a trend component that reflects the changing trend of the running resource usage of the program, a seasonal component that reflects the periodic variation of the running resource usage of the program, and a program running resource usage amount. Random component of random variation;
  • a determining module configured to determine, according to data included in each resource component, a prediction function of the resource component, and add the determined prediction functions of each resource component to obtain a program running resource total prediction function
  • the prediction function of the trend component is a linear fitting or a nonlinear fitting of the data included in the trend component, and the predicted time is an independent variable. Linear function or nonlinear function;
  • the prediction function of the random component is a constant, and the constant is an upper quantile of the random component.
  • the determining module is specifically configured to determine a program running resource overall prediction function according to the following formula:
  • the prediction module is specifically configured to:
  • a fourth possible implementation manner collecting resource usage of the program in each program running resource usage period The number of times is the same.
  • the program running resource usage period is a periodicity of running resource usage according to the program The period of regular setting.
  • the prediction function so that the embodiment of the present invention can predict the future use of the program running resources more accurately, and make up for the defect that the prior art cannot predict the resource usage during the running of the program.
  • FIG. 1 is a flowchart of a method for judging a program running resource leakage according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for judging a program running resource leakage according to a preferred embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of a device for determining a running resource leakage of a program according to an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of a method for predicting a running resource usage of a program according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of decomposing program running resource usage into trend component, seasonal component, and random component by using a classical time series decomposition method according to an embodiment of the present invention
  • FIG. 1 is a flowchart of a method for judging a program running resource leakage according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for judging a program running resource leakage according to a preferred embodiment of the present invention
  • FIG. 7 is a flow chart of a method for predicting usage of a program running resource according to a preferred embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of an apparatus for predicting usage of a program running resource according to an embodiment of the present invention.
  • FIG. 10 is a structural diagram of a device for predicting resource usage of a program according to an embodiment of the present invention
  • FIG. 11 is a schematic diagram of device deployment for detecting resource leakage and predicting resource usage according to an embodiment of the present invention.
  • the resource usage period is run for any two programs, and the program running resource usage amount is determined for each time in the subsequent period.
  • the embodiment of the invention can realize the analysis of the program running resource usage of different program running resource use periods during the running of the program, so that the program running resource usage situation at different stages of the program running can be obtained, and the current situation is accurately determined.
  • the embodiment of the present invention only needs to collect the running resource usage amount in the program running interval, and determine whether the program exists after collecting a certain number of program running resource usage amounts. Running resource leaks, low system performance consumption, and suitable for different applications, the versatility is strong.
  • the program running resource usage amount of the collected set is decomposed into different kinds of resource components, and the data included in each resource component is Determining a prediction function of the resource component, determining a program running resource overall prediction function according to the determined prediction function of each resource component, and finally predicting a program running resource usage based on the determined overall prediction function.
  • the embodiment of the invention decomposes the program operation resource usage into components with different variation rules, and respectively fits and estimates different components, and obtains program running resources that accurately reflect different components.
  • the prediction function of the usage change rule is used to obtain a prediction function reflecting the change rule of the program running resource usage of the whole, so that the embodiment of the present invention can accurately predict the future use of the program running resource, and make up for the prior art. Defects in resource usage during program execution cannot be predicted.
  • An embodiment of the present invention provides a method for determining a program running resource leakage, including: collecting at least one program running resource usage amount in each program running resource usage period; wherein, each program running resource usage period is collected The program runs the same amount of resource usage; the program running resource usage period is set according to the periodic law of the program running resource usage. Cycle
  • Run the resource usage period for each of the two programs determine the difference between the program running resource usage for each collection in the subsequent period, and the program running resource usage for the corresponding subset in the previous period, where in the latter period
  • the time difference between the time of each set and the start time of the latter period, and the time difference between the time of the corresponding secondary set in the previous period and the start time of the previous period is within a preset range, wherein the pre- The range is: less than the length of time interval of the minimum time interval in the interval between each adjacent two sets in the previous period, or the preset range is: less than each adjacent in the subsequent period The length of time interval of the minimum time interval in the interval between two sets;
  • the determined difference values if the difference between the total number of differences greater than 0 and the total number of differences less than 0 is greater than a set threshold, it is determined that there is a program running resource leak, wherein the range of the threshold is Greater than or equal to 0, and less than or equal to 70% of the sum of the total of the differences greater than 0 and the total difference of less than 0.
  • An embodiment of the present invention further provides a method for determining a program running resource leak, comprising: collecting at least one program running resource usage amount in each program running resource usage period; wherein, in each program running resource usage period, The number of times the program runs the resource usage is the same; the program running resource usage period is a period set according to the periodic law of the program running resource usage;
  • Run the resource usage period for each of the two programs determine the difference between the program running resource usage for each collection in the subsequent period, and the program running resource usage for the corresponding subset in the previous period, where in the latter period
  • the time difference between the time of each set and the start time of the latter period, and the time difference between the time of the corresponding secondary set in the previous period and the start time of the previous period is within a preset range, wherein the pre- The range is: less than the length of time interval of the minimum time interval in the interval between each adjacent two sets in the previous period, or the preset range is: less than each adjacent in the subsequent period The length of time interval of the minimum time interval in the interval between two sets;
  • n is the period of the program running resource usage period
  • Ik is the i-th program running resource usage collected during the resource usage period of the kth program
  • R n is the i-th program running resource usage collected during the first program running resource usage period
  • m The number of times the resource usage is run by the collection program for a program running resource usage period
  • the threshold is a quantile value determined according to a probability distribution of the statistic Z.
  • An embodiment of the present invention further provides an apparatus for determining a program running resource leakage, including: a collection module, configured to collect at least one program running resource usage amount in each program running resource usage period, wherein, in each program The number of times the resource usage of the collection program is the same during the running resource usage period; the program running resource usage period is a period set according to the periodic law of the running resource usage of the program;
  • Determining a module configured to run a resource usage period for each of the two programs, determining a difference between the program running resource usage for each of the collected processes in the subsequent period, and the program running resource usage for the corresponding secondary set in the previous period, The time difference between the time of each collection in the latter period and the start time of the subsequent period, and the time difference between the time of the corresponding secondary collection in the previous period and the start time of the preceding period is within a preset range, The preset range is: less than each adjacent set in the previous period.
  • the range of time lengths of the minimum time interval in the time interval, or the preset range is: a time length range smaller than the minimum time interval in the time interval of each adjacent two sets in the subsequent period;
  • a judging module configured to determine that there is a program running resource leak when the difference between the total number of differences greater than 0 and the total difference value less than 0 is greater than the set threshold value, wherein the range of the threshold value exists It is greater than or equal to 0, and is less than or equal to 70% of the sum of the total number of differences greater than 0 among the determined differences and the total number of differences less than 0.
  • An embodiment of the present invention further provides an apparatus for determining a program running resource leakage, including: a collection module, configured to collect at least one program running resource usage amount in each program running resource usage period, wherein, in each program The number of times the resource usage of the collection program is the same during the running resource usage period; the program running resource usage period is a period set according to the periodic law of the running resource usage of the program;
  • Determining a module configured to run a resource usage period for each of the two programs, determining a difference between the program running resource usage for each of the collected processes in the subsequent period, and the program running resource usage for the corresponding secondary set in the previous period, The time difference between the time of each collection in the latter period and the start time of the subsequent period, and the time difference between the time of the corresponding secondary collection in the previous period and the start time of the preceding period is within a preset range,
  • the preset range is: a time length range smaller than a minimum time interval in each of the adjacent two sets of time intervals in the previous period, or the preset range is: less than the The length of time interval of the minimum time interval in the interval between each adjacent two sets of cycles;
  • a judging module configured to determine a statistic Z of the difference between the total number of differences greater than 0 and the total number of differences less than 0; if Z is greater than the set threshold, it is determined that there is a program running resource leak;
  • the determining module is specifically configured to determine, according to the following formula, a statistic of the difference between the total number of differences greater than 0 and the total number of differences less than 0.
  • n is the period of the program running resource usage period , 1/2
  • the threshold is a quantile value determined according to a probability distribution of the statistic Z.
  • a flow chart of a method for determining a program running resource leakage includes the following steps:
  • S101 Collecting resource usage of the program at least once during each program running resource usage period; wherein, the number of times the program runs the resource usage is the same in each program running resource usage period; the program running resource usage period is based on The period in which the periodicity of the program running resource usage is set;
  • S102 Running a resource usage period for any two programs, determining a difference between a program running resource usage amount of each collection in the subsequent period, and a program running resource usage amount corresponding to the secondary collection in the previous period, wherein The time difference between the time of each collection in the period and the start time of the subsequent period, and the time difference between the time of the corresponding secondary collection in the previous period and the start time of the preceding period is within a preset range;
  • the program running resource in the embodiment of the present invention may be a memory resource, or may be a software resource such as a file handle, a semaphore, a database connection pool, or a thread pool required for the program to run;
  • Target objects can be of different levels, such as hosts, virtual machines, processes, process submodules, memory partitions of processes, and so on.
  • the basic idea of the embodiment of the present invention is to collect the resource usage amount of one or more programs in each program running resource usage period according to the periodic characteristics of the program running resource usage amount, and determine the current usage of each time in the subsequent period.
  • the program running resource usage in the post-period is higher than the program running resource usage in the previous period.
  • the difference is less than 0, it indicates that the difference corresponds to the two program running resource usage.
  • the running resource usage of the program is lower than the running resource usage of the program in the previous period.
  • the difference is equal to 0, it indicates that the difference corresponds to the two programs running resource usage, after The periodic program running resource usage is equal to the program running resource usage in the previous period; therefore, the determined difference values for all periods are determined.
  • the total number of differences greater than 0 identifies the number of times the program running resource usage increases with time in the total number of program running resource usages of the set, and the total number of differences less than 0 identifies the program running resource usage of the set. In the total number of times, the number of times the program runs resource usage decreases with time. Therefore, the difference between the total number of differences greater than 0 and the total difference of less than 0 can identify the overall rise or fall of the program running resource usage.
  • the time difference between the time of each set in the post-period and the start time of the post-period, and the time difference between the time of the corresponding sub-set in the previous period and the start time of the previous period are within a preset range.
  • the time difference between the time of each collection in the latter period and the start time of the latter period, and the time of the corresponding secondary collection in the previous period may be made.
  • the time difference between the start times of the cycles is the same.
  • the preset range is: a time length range smaller than a minimum time interval in a time interval of each adjacent two sets in the previous period, or The preset range is: less than the minimum of the interval between each adjacent two sets in the latter period The length of time interval.
  • the program usage resource usage can be collected at the same set frequency during each program running resource usage period.
  • the method before determining a difference between the program running resource usage amount of each time set in the subsequent period and the program running resource usage amount of the corresponding secondary data set in the previous period, the method further includes:
  • one or several conditions for starting to determine whether there is a program running resource leak may be set, for example, the total number of cycles or total times of the currently used program running resource usage has reached or exceeded the set threshold, The current program running resource occupancy rate has reached or exceeded the set threshold, the current CPU usage is less than the set threshold, and the current time is within the set time range.
  • it may be set to determine whether there is a program running resource leak when any one or more of the above-mentioned determination conditions are reached.
  • a threshold can be set. When the total number of cycles or the total number of times the program runs the resource usage has reached or When the value exceeds the set threshold, it is determined whether there is a program running resource leak. You can also consider the current CPU usage. If the current CPU usage is high, the current system is busy. In order to not affect the system performance, you can set the CPU usage. When the rate is less than the set threshold, it is started to determine whether there is a program running resource leak.
  • the resource occupancy rate is the first wide value, wherein the program running resource occupancy rate reaches the first threshold value, indicating that the program running resource exhaustion risk is relatively high, and can be set when the program running resource occupancy rate reaches the first threshold value, whether or not it is satisfied.
  • Other judgment conditions are started to determine whether there is program running capital Leakage;
  • you can also set the second threshold of the program running resource occupancy rate.
  • the program running resource occupancy rate does not reach the second threshold.
  • the program running resources are still relatively abundant, and the program running resource occupancy rate can not be set to the second.
  • Method 1 According to whether the difference between the total number of differences greater than 0 and the total number of differences less than 0 is greater than the set threshold, determine whether there is a program running resource leak;
  • the range of the threshold is greater than or equal to 0, and is less than or equal to 70% of the sum of the total of the differences greater than 0 and the total of the differences less than zero.
  • the rise or fall of the total resource usage of the program may be identified, so that the difference between the number of differences greater than 0 and the difference less than 0 may be directly Whether the difference between the number of values has reached or exceeded the set threshold to determine whether there is a program running resource leak. For example, in the total difference, 90% of the difference is greater than 0, only 10% difference. If the value is less than 0, then it can be considered that there is currently a program running resource leak.
  • This method is more intuitive for judging whether there is a program running resource leak, and the implementation process is relatively simple, and the impact on system performance is also very small.
  • Manner 2 According to whether the statistic Z of the difference between the total number of differences greater than 0 and the total difference of less than 0 is greater than the set threshold, it is determined whether there is a program running resource leak;
  • the threshold is determined according to a probability distribution of the statistic Z.
  • the basic idea of the present embodiment is to use the method of probability and statistics, and not directly compare the difference between the number of differences greater than 0 and the number of differences less than 0 with the set threshold, but determine and have a corresponding relationship.
  • the statistic Z is an amount that can represent the size and satisfy a probability distribution.
  • the present embodiment determines whether there is a program running resource leak according to whether the statistic Z is greater than the set threshold.
  • the statistic of the difference between the total number of differences greater than 0 and the total number of differences less than 0 is determined according to the following formula: Z: If ?? ⁇ 10, then ⁇ 7 ⁇ ; where ⁇ is the number of cycles in which the program runs resources;
  • k program running resource usage period of the i-th program running resource usage ⁇ is the i-th program running resource usage during the first program running resource usage period
  • m is a program running resource The number of times the resource usage was run by the collection program during the usage period.
  • the statistic Z corresponding to the above relationship obeys the standard normal distribution
  • VAR() is a variance function
  • sgn() is a symbol function, when the program is used for the resource usage in the subsequent period, and the previous period
  • the symbol function value is 1, when the program runs the resource usage in the subsequent cycle, and the corresponding time set in the previous cycle
  • the value of the symbol function is -1.
  • the symbol function has a value of 0.
  • the set statistic value ⁇ ⁇ z of the width of the sub-site of a standard normal distribution, wherein the width is greater than the value of the statistic probability ⁇ o, o value may be set according to actual needs, such as 5% , 1%, etc., if the determined ⁇ is greater than ⁇ ⁇ , it is determined that there is a program running resource leak. On the contrary, if ⁇ is not greater than ⁇ ⁇ , then there is no program running resource leak.
  • a flowchart of a method for determining a program running resource leakage includes:
  • S201 Collecting a plurality of program running resource usages at a set frequency within each program running resource usage period;
  • step S202 determining whether the total number of cycles or the total number of times of the program running resource usage of the set is not less than the set threshold, if yes, proceeding to step S203, otherwise returning to step S201;
  • judgment conditions may also be set, such as whether the current program running resource occupancy rate is not less than the set threshold, whether the current CPU CPU usage is less than the set threshold, and whether the current time is set. Wait for the time range.
  • S203 Running a resource usage period for any two programs, determining a difference between a program running resource usage amount of each set in the subsequent period and a program running resource usage amount corresponding to the secondary set in the previous period;
  • S204 Determine whether there is a program running resource leak according to a difference between a total number of differences greater than 0 among the determined differences and a total difference of less than 0.
  • an embodiment of the present invention further provides a device for judging a program running resource leakage corresponding to a method for determining a program running resource leak, and the method for solving the problem is determined by the device in the embodiment of the present invention.
  • the method is similar, so the implementation of the device can be referred to the implementation of the method, and the repeated description will not be repeated.
  • a schematic structural diagram of an apparatus for determining a program running resource leakage according to an embodiment of the present invention includes:
  • the collection module 31 is configured to collect resource usage of the program at least once during each program running resource usage period, and transmit the collected program running resource usage to the determining module, where the resource usage is run in each program The number of times the program runs the resource usage in the cycle is the same; the program running resource usage period is a period set according to the periodicity of the program running resource usage; the determining module 32 is configured to receive the collecting module 31 each time The set program runs the resource usage, and runs the resource usage period for any two programs, determines the program running resource usage for each set in the subsequent period, and runs the resource usage for the program corresponding to the secondary set in the previous period.
  • the determined difference values are transmitted to the judging module 33, wherein the time difference between the time of each set in the post period and the start time of the post period, and the time of the corresponding set in the previous period
  • the time difference from the start time of the previous cycle is within a preset range
  • the determining module 33 is configured to receive the difference values determined by the determining module 32, and determine whether there is a program running resource leakage according to a difference between a total number of differences greater than 0 and a total difference value less than 0 among the determined differences.
  • the preset range is: a time length range smaller than a minimum time interval in a time interval of each adjacent two sets in the previous period, or the preset range It is: a time length range smaller than the minimum time interval in the time interval of each adjacent two sets in the subsequent period.
  • the determining module 32 is further configured to determine, before determining a difference between a program running resource usage amount of each time set in the subsequent period and a program running resource usage amount of the corresponding secondary data set in the previous period.
  • the total number of cycles or the total number of times the program runs the resource usage is not less than the set threshold, and/or the current program running resource occupancy rate is not less than the set threshold, and/or the current CPU CPU usage is less than the set.
  • the set threshold, and / or the current time is within the set time range.
  • the determining module 33 is specifically configured to: if the difference between the total number of differences greater than 0 and the total number of differences less than 0 is greater than the set threshold, it is determined that there is a program running resource leak.
  • the threshold The range is greater than or equal to 0, and less than or equal to 70% of the sum of the total of the differences greater than 0 and the total difference of less than 0
  • the determining module 33 is specifically configured to:
  • the threshold is a quantile value determined according to a probability distribution of the statistic Z.
  • the judging module 33 is specifically configured to determine the statistic Z of the difference between the total number of differences greater than 0 and the total difference value less than 0 according to the following formula:
  • n is the number of cycles in which the program runs resources
  • k program running resource usage period of the i-th program running resource usage ⁇ is the i-th program running resource usage during the first program running resource usage period
  • m is a program running resource The number of times the resource usage was run by the collection program during the usage period.
  • the device structure diagram for determining a program running resource leakage includes:
  • the processor 41 is configured to collect at least one program running resource usage amount in each program running resource usage period; wherein, the program running the resource usage amount is the same in each program running resource usage period;
  • the usage period is a period set according to the periodicity of the program running resource usage; the resource usage period is run for any two programs, and the program running resource usage amount is determined each time in the subsequent period, corresponding to the previous period.
  • the program running resources of the second set The difference between the usage amount, wherein the time difference between the time of each collection in the latter period and the start time of the subsequent period, and the time difference between the time of the corresponding secondary collection in the previous period and the start time of the preceding period is Within a preset range; determining whether there is a program running resource leak according to a difference between a total number of differences greater than 0 among the determined differences and a total difference of less than 0;
  • the memory 42 is configured to store a program running resource usage amount collected by the processor each time and a determined program running resource usage amount in each subsequent period, and a program running corresponding to the second time set in the previous period The difference in resource usage.
  • the preset range is: a time length range smaller than a minimum time interval in each of the adjacent two sets of time intervals in the previous period, or the preset range is: less than the The length of time interval of the minimum time interval in the interval between each adjacent two sets of cycles.
  • the processor 41 is further configured to determine, before determining a difference between a program running resource usage amount of each time set in the subsequent period and a program running resource usage amount of the corresponding second set in the previous period.
  • the total number of cycles or the total number of times the program runs the resource usage is not less than the set threshold, and/or the current program running resource occupancy rate is not less than the set threshold, and/or the current CPU CPU usage is less than the set.
  • the set threshold, and / or the current time is within the set time range.
  • the processor 41 is specifically configured to: if the difference between the total number of differences greater than 0 and the total number of differences less than 0 is greater than a set threshold, determine that there is a program running resource leak.
  • the range of the threshold is greater than or equal to 0, and is less than or equal to 70% of the sum of the total of the differences greater than 0 and the total difference of less than 0.
  • the processor 41 is specifically configured to: determine a statistic Z of the difference between the total number of differences greater than 0 and the total number of differences less than 0; if Z is greater than the set threshold, determine that there is a program running resource leak .
  • the threshold is a quantile value determined according to a probability distribution of the statistic Z.
  • k program running resource usage period of the i-th program running resource usage ⁇ is the i-th program running resource usage during the first program running resource usage period
  • m is a program running resource The number of times the resource usage was run by the collection program during the usage period.
  • the present invention provides a method for predicting usage of a program running resource, including:
  • the resource usage of the program is collected at least once during each program running resource usage period; the program running resource usage of the collection is decomposed into: a trend component that reflects the changing trend of the running resource usage of the program, and reflects the running resource usage of the program.
  • the seasonal component of the periodic variation and the random component of the random variation that reflects the amount of resource usage of the program;
  • the prediction function of the trend component is a linear function or nonlinearity obtained by linearly fitting or nonlinearly fitting the data included in the trend component, and the obtained prediction time is an independent variable.
  • the prediction function of the random component is a constant, and the constant is an upper quantile of the random component.
  • the overall prediction function of the program running resource may be determined according to the following formula:
  • the predicting the usage of the program running resource based on the determined overall prediction function may include:
  • the number of times the program uses the resource usage in the program usage resource usage period is the same.
  • the program running resource usage period is a period set according to a periodic rule of the program running resource usage amount.
  • An embodiment of the present invention further provides an apparatus for predicting usage of a program running resource, including: a collection module, configured to collect at least one program running resource usage amount during each program running resource usage period;
  • the decomposition module is used to decompose the program running resource usage of the collection into: a trend component that reflects the changing trend of the running resource usage of the program, a seasonal component that reflects the periodic variation of the running resource usage of the program, and a program running resource usage amount. Random component of random variation;
  • a determining module configured to determine, according to data included in each resource component, a prediction function of the resource component, and add the determined prediction functions of each resource component to obtain a program running resource total prediction function
  • the prediction function of the trend component may be a linear function or a non-linear fitting of the data included in the trend component, and the obtained linear function or non-predicted time is an independent variable.
  • T is the program running resource usage period
  • Si is the i-th data of the program running resource usage period of the seasonal component to which t belongs
  • the prediction function of the random component may be a constant, the constant being an upper quantile of the random component.
  • the determining module may be specifically configured to determine an overall running function of the program running resource according to the following formula:
  • the prediction module is specifically configured to:
  • the number of times the program uses the resource usage in the program usage resource usage period is the same.
  • the program running resource usage period is a period set according to a periodic rule of the program running resource usage amount.
  • a flowchart of a method for predicting a program running resource usage situation includes:
  • S501 Collecting at least one program running resource usage during each program running resource usage period
  • the program running resource usage period is a period set according to the periodic law of the program running resource usage
  • S502 Decomposing the program running resource usage of the set into different kinds of resource components, where the different resource components are components that have different variation rules according to the usage rule of the running resource of the program;
  • S503 determining, according to data included in each resource component, a prediction function of the resource component; determining, according to the determined prediction function of each resource component, a program running resource overall prediction function;
  • S504 Predicting the usage of the running resource of the program based on the determined overall prediction function.
  • the program running resource in the embodiment of the present invention may be a memory resource, or may be a software resource such as a file handle, a semaphore, a database connection pool, or a thread pool required for the program to run;
  • Objects can be of different levels, such as hosts, virtual machines, processes, process submodules, memory partitions of processes, and so on.
  • the basic idea of the embodiment of the present invention is to decompose the program running resources into components with different changing rules, that is, different resource components, and respectively fit and estimate each resource component according to the usage rule of the program running resource, and determine each The prediction function of the resource component is integrated with the determined prediction function of each resource component to obtain an overall prediction function of the program running resource, and the usage of the future program running resource is predicted according to the overall prediction function.
  • the method further includes:
  • the resource component decomposed into includes a seasonal component that changes periodically and a random component that changes in randomness; or
  • the resource components that are decomposed into include a trend component that reflects the trend of the running resource usage of the program and a random component of the random variation; or
  • the resource components that are decomposed into include trend trends that reflect the changing trend of the running resources of the program.
  • the prediction function of the trend component is a linear function or a nonlinear function obtained by linearly fitting or nonlinearly fitting the data contained in the trend component, and the obtained prediction time is an independent variable;
  • the prediction function of the random component is a confidence upper limit determined based on the mean and standard deviation of the data contained in the random component.
  • the prediction function of the trend component may be a linear function or a nonlinear function obtained by linearly fitting or nonlinearly fitting data included in the trend component, and the obtained time is an independent variable;
  • the prediction function of the random component may be a constant, the constant being an upper quantile of the random component.
  • determining the program running resource overall prediction function according to the determined prediction function of each resource component may include: adding the determined prediction functions of each resource component to obtain a program running resource total Predictive function.
  • the overall prediction function of the program running resource can be determined according to the following formula:
  • the program running resources may be decomposed into seasonal components and random components, or trend components and random components, or trend components, seasonal components, and random components according to the usage rules of the program running resources, wherein the trend components are embodied
  • the program runs the component of the trend of the resource usage, the seasonal component indicates the amount of periodic variation of the program running resource usage, and the random component indicates the amount of random variation of the program running resource usage.
  • time series decomposition method such as classical decomposition method or STL decomposition method
  • classical decomposition method or STL decomposition method
  • the number of times the program running resource usage in a cycle is an odd number N, and the resource usage of the program running for the previous set, the resource usage of the (N-1)/2 program running the previous time, After that, the (Nl)/2 program running resource usage of the collection and the program running resource usage of the collection are added, and divided by the total number of times the program runs the resource usage in one cycle,
  • the program of the collected program runs the value of the trend component corresponding to the resource usage; the program running resource usage of the collection is subtracted from the value of the corresponding trend component, and the program running resource usage corresponding to the collection is obtained.
  • the sum of the seasonal component and the random component on the basis of which the average value of the sum of the seasonal component and the random component corresponding to the program running resource usage amount of the corresponding sub-set of each cycle is determined, and the average is used as each cycle.
  • the value of the seasonal component corresponding to the resource usage of the program corresponding to the secondary set that is, the value of the seasonal component of the different cycle is the same; finally, the time
  • the program runs resource usage by subtracting the trend and seasonal components corresponding component to obtain a random component to the run of resource usage procedures preclude the set of corresponding.
  • FIG. 6 a schematic diagram of decomposing program running resource usage into trend component, seasonal component, and random component by using a classical time series decomposition method according to an embodiment of the present invention; the horizontal and vertical coordinate values in the figure are only used as an illustration, where No specific description of the unit, etc., the figure corresponds to 6 cycles
  • the program runs the resource usage, and collects 96 resource running resource resource usages in each cycle.
  • the program running resource overall prediction function is determined according to the following formula:
  • R t is the overall prediction function of the program running resource: (a+bt ) is the prediction function of the trend component, a and b are constants; ( ⁇ +ka ) is the prediction function of the random component, where ⁇ is the random component The mean of the data contained, ⁇ is the standard deviation of the data contained in the random component, and k is a constant.
  • the prediction function of the trend component may be a linear function in the above formula, or may be a nonlinear function obtained by fitting, such as a quadratic function, an exponential function, a logarithmic function, a polynomial, Gompertz, Logistic
  • the seasonal component data of each cycle is the same. Therefore, the seasonal component of one cycle can be used to predict the future program operation resource usage.
  • the prediction function of the seasonal component is S.
  • step S504 the usage of the program running resource is predicted based on the determined overall prediction function, including:
  • the usage of the program running resource can be predicted, and if the R t is equal to the set program running resource usage threshold, the program can be obtained.
  • the running resource usage will reach the set threshold in the future, so that the above R t is equal to the total available program running resources, and the time when the running resource of the program is exhausted can be obtained, so that t is equal to the set time in the future, and the time is obtained.
  • the program runs resource usage at a future time t.
  • a flowchart of a method for predicting usage of a program running resource includes:
  • S701 Collecting a plurality of program running resource usages at a set frequency during each program running resource usage period;
  • step S702 determining whether the total number of cycles or the total number of times of the program running resource usage of the set is not less than the set threshold, if yes, proceeding to step S703, otherwise, returning to step S701;
  • judgment conditions may also be set, such as whether the current program running resource occupancy rate is not less than the set threshold, whether the current CPU CPU usage is less than the set threshold, and whether the current time is set. Wait for the time range.
  • S703 Decomposing the program running resource usage of the set into a trend component reflecting a changing trend of the running resource usage of the program, a seasonal component of the periodic variation, and a random component of the random variation;
  • S704 Determine, according to data included in each resource component, a prediction function of the resource component; determine, according to the determined prediction function of each resource component, a program running resource overall prediction function;
  • the prediction function of the trend component may be a linear or nonlinear fitting of the data contained in the trend component, and the obtained linear or nonlinear function with the prediction time as an independent variable;
  • the prediction function of the random component A confidence limit determined based on the mean and standard deviation of the data contained in the random component.
  • S705 predicting a program running resource usage amount in a future setting time according to the determined overall prediction function, and/or predicting a time when the program running resource is exhausted, and/or predicting a program running resource usage amount to reach a set threshold in the future time.
  • the method for determining the running resource leakage of the program and the method for predicting the running of the running resource of the program may be combined, and the process of determining the running resource leakage of the program and the process of predicting the running of the running resource of the program may be performed simultaneously, or may be performed simultaneously. In succession.
  • the following is an example of a memory resource in a program running resource, and a method for judging a memory leak and predicting memory usage is combined with an implementation of the application.
  • the overall method flow chart including:
  • S801 Collecting multiple memory usages at a set frequency within each memory resource usage period
  • step S802 determining whether the total number of cycles or total number of memory usages of the set is not less than the set threshold, if yes, proceeding to step S803; otherwise, returning to step S801;
  • other conditions for starting the detection of the memory leak may be set. For example, if the current memory usage is not less than the set threshold, the current CPU usage of the central processing unit is less than the set threshold, and the current time is set. Within the time range.
  • step S803 determining whether to start detecting a memory leak, and if so, proceeding to step S804, otherwise proceeding to step S805;
  • step S804 Perform memory leak detection, and after detecting the output detection result, proceed to step S805;
  • the specific detection process may refer to the foregoing method for judging the running resource leakage of the program, and details are not described herein;
  • step S805 determining whether to start predicting memory usage, if yes, proceeding to step S806, otherwise, returning to step S801;
  • S806 Predict the memory usage and output the prediction result after the prediction.
  • the specific prediction process can be referred to the foregoing method for predicting the running of resource usage of the program, and will not be described here.
  • a schematic structural diagram of a device for predicting a program running resource usage situation includes:
  • the collection module 91 is configured to collect at least one program in each program running resource usage period Row resource usage, and the collected program running resource usage is transferred to the decomposition module 92; the program running resource usage period is a period set according to the periodicity of the program running resource usage; the decomposition module 92 is configured to receive The program set by the collection module 91 runs resource usage, and decomposes the program running resource usage of the collection into different kinds of resource components, and transmits the data contained in each resource component to the determining module 93, where different resource components are In order to use the running rules of the resources according to the program, the program running resources are decomposed into components with different changing rules;
  • a determining module 93 configured to receive data included in each resource component decomposed by the decomposition module 92, determine a prediction function of the resource component for each data component, and determine each resource component according to each The prediction function determines a program running resource overall prediction function, and transmits the determined overall prediction function to the prediction module 94;
  • the prediction module 94 is configured to receive an overall prediction function determined by the determining module 93, and predict a usage of the program running resource based on the total prediction function.
  • the decomposing module may be specifically configured to decompose the collected program running resource usage amount into a seasonal component that reflects periodic changes in the running resource usage of the program and a random amount that reflects the running resource usage of the program. Random component of sexual change; or
  • the program running resource usage of the collection is decomposed into a trend component reflecting the changing trend of the running resource usage of the program, a seasonal component reflecting the periodic variation of the running resource usage of the program, and a random variation reflecting the random variation of the running resource usage of the program. Component.
  • the prediction function of the trend component may be a linear function or a non-linear fitting of the data included in the trend component, and the obtained linear function or non-predicted time is an independent variable.
  • the prediction function of the random component may be a constant, the constant being an upper quantile of the random component.
  • the determining module when the determining module is configured to determine a program running resource overall prediction function according to the determined prediction function of each resource component, the determining module may be specifically configured to: determine a prediction function of each resource component determined Add, get the overall prediction function of the program running resource.
  • the determining module when the determining module is configured to determine a program running resource overall prediction function according to the determined prediction function of each resource component, the determining module may be specifically configured to: determine a program running resource overall prediction function according to the following formula:
  • the determining module 93 is further configured to determine, before the buffering module 91 decomposes the collected program running resource usage amount into different resource components, the total number of cycles or the total number of times of the program running resource usage of the set is not less than The set threshold, and/or the current program running resource occupancy rate is not less than the set threshold, and/or the current CPU processor CPU usage is less than the set threshold, and/or the current time is at the set time.
  • the determining module 93 is further configured to determine, before the buffering module 91 decomposes the collected program running resource usage amount into different resource components, the total number of cycles or the total number of times of the program running resource usage of the set is not less than The set threshold, and/or the current program running resource occupancy rate is not less than the set threshold, and/or the current CPU processor CPU usage is less than the set threshold, and/or the current time is at the set time.
  • the decomposed resource component of the decomposition module 92 includes a seasonal component that changes periodically and a random component that changes with randomness; or
  • the decomposed module 92 decomposed resource components include a trend component that reflects a trend of the running resource usage of the program and a random component of the random variation; or
  • the decomposed module 92 decomposed resource components include a trend component that reflects a trend of the running resource usage of the program, a seasonal component that changes periodically, and a random component that changes in randomness;
  • the prediction function of the trend component is a linear function or a nonlinear function obtained by linearly fitting or nonlinearly fitting the data contained in the trend component, and the obtained prediction time is an independent variable;
  • the prediction function of the random component is a confidence upper limit determined based on the mean and standard deviation of the data contained in the random component.
  • the determining module 93 is specifically configured to determine a program running resource overall prediction function according to the following formula when the resource components decomposed by the decomposition module 92 include a trend component, a seasonal component, and a random component:
  • R t is the overall prediction function of the program running resource: (a+bt ) is the prediction function of the trend component, a and b are constants; ( ⁇ +ka ) is the prediction function of the random component, where ⁇ For the mean of the data contained in the random component, ⁇ is the standard deviation of the data contained in the random component, and k is a constant.
  • the prediction module 94 is specifically configured to:
  • the number of times the program is used to run the resource usage is the same in each program running resource usage period.
  • FIG. 10 it is a device structure diagram of predicting program usage resource usage status provided by an embodiment of the present invention, including:
  • the processor 101 is configured to collect at least one program running resource usage amount in each program running resource usage period, and decompose the collected program running resource usage amount into different kinds of resource components, where different resource components are according to the program.
  • the usage rule of the running resource the program running resource is decomposed into components having different variation rules;
  • the program running resource usage period is a period set according to the periodic law of the program running resource usage amount; for each resource component The data contained in it, Determining a prediction function of the resource component, and determining a program running resource overall prediction function according to the determined prediction function of each resource component, and predicting a usage of the program running resource based on the determined overall prediction function;
  • the memory 102 is configured to store a program running resource usage amount and a determined prediction function of each resource component and a program running resource overall prediction function for each set.
  • the decomposing the collected program running resource usage amount into different kinds of resource components includes: decomposing the collected program running resource usage amount into a periodic change reflecting the program running resource usage amount.
  • the program running resource usage of the collection is decomposed into a trend component reflecting the changing trend of the running resource usage of the program, a seasonal component reflecting the periodic variation of the running resource usage of the program, and a random variation reflecting the random variation of the running resource usage of the program. Component.
  • the prediction function of the trend component is a linear function or nonlinearity obtained by linearly fitting or nonlinearly fitting the data included in the trend component, and the obtained prediction time is an independent variable.
  • the prediction function of the random component is a constant, and the constant is an upper quantile of the random component.
  • the determining, according to the determined prediction function of each resource component, the program running the resource overall prediction function comprising: adding the determined prediction functions of each resource component to obtain an overall prediction of the running resource of the program function.
  • the overall prediction function of the program running resource is determined according to the following formula Number:
  • the processor 101 is further configured to determine, before decomposing the program running resource usage amount of the collected program into different kinds of resource components, the total number of cycles or the total number of times of the program running resource usage of the set is not less than a set width.
  • the value, and/or the current program running resource occupancy is not less than the set threshold, and/or the current CPU CPU usage is less than the set threshold, and/or the current time is within the set time range.
  • the resource component comprises a seasonal component of the periodic variation and a random component of the random variation; or
  • the resource component includes a trend component that reflects the trend of the running resource usage of the program and a random component of the random variation;
  • the resource component includes a trend component that reflects a trend of the running resource usage of the program, a seasonal component of the periodic variation, and a random component of the random variation;
  • the prediction function of the trend component is a linear function or a nonlinear function obtained by linearly fitting or nonlinearly fitting the data contained in the trend component, and the obtained prediction time is an independent variable;
  • the prediction function of the random component is a confidence upper limit determined based on the mean and standard deviation of the data contained in the random component.
  • the processor 101 is specifically configured to determine a program running resource overall prediction function according to the following formula when the resource component includes a trend component, a seasonal component, and a random component:
  • R t is the overall prediction function of the program running resource: (a+bt ) is the prediction function of the trend component, a and b are constants; ( ⁇ +ka ) is the prediction function of the random component, where ⁇ For the mean of the data contained in the random component, ⁇ is the standard deviation of the data contained in the random component, and k is a constant.
  • the processor 101 is specifically configured to:
  • FIG. 11 a schematic diagram of device deployment for detecting resource leakage and predicting resource usage according to an embodiment of the present invention
  • a device according to the embodiment of the present invention may be deployed for the monitoring object. If it is necessary to detect whether a plurality of monitoring objects of the target system have program running resource leaks and/or predict program running resource usage of the plurality of monitoring objects, one device of the embodiment of the present invention may be deployed for each monitoring object.
  • the device can be deployed online, that is, data collection and data analysis are performed on the target system, and online deployment and offline deployment can be combined, that is, the resource usage is only run in the target system collection program, and
  • the data analysis that is, the specific process of judging the program running resource leakage and/or predicting the running of the program running resources, is performed offline.
  • the memory resource is taken as an example to describe in detail the interaction process between the device for detecting resource leakage and predicting resource usage in the embodiment of the present invention and the target system:
  • the target system sets relevant parameters through the configuration file of the device, such as the number of memory usages collected in one cycle, the significance level of leakage detection, that is, the k value of the prediction function of ⁇ and random components in the above embodiment, and starts judgment. Whether there is memory leak or memory usage threshold for memory leaks, etc.;
  • the target system registers with the device a hook function for obtaining memory usage, so that the device calls the function during the running process to collect the memory usage of the target monitoring object;
  • the target system registers with the device a hook function for detecting the prediction result, so that the device calls the function to notify the target system of the detection and prediction result, and the target system performs corresponding processing according to the result, such as notification alarm, active/standby switchover, and process restart.
  • the operating system restarts, restarts the machine, etc.; the target system periodically invokes the external interface function provided by the device through the timing task, and the external interface function of the device invokes the hook function of the target system to register the memory usage of the device.
  • the memory usage of the object, the accumulated data is stored in the memory, and the process of memory leak detection and prediction of memory usage is performed by using the collected data.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can be embodied in the form of one or more computer program products embodied on a computer-usable storage medium (including but not limited to disk storage, CD-ROM, optical storage, etc.) in which computer usable program code is embodied.
  • a computer-usable storage medium including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Computer Hardware Design (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

一种判断程序运行资源泄漏的方法及装置,涉及计算机应用领域,用以解决现有的检测程序运行资源泄漏的方法中,容易出现误报和漏报、通用性较差的问题;还涉及一种预测程序运行资源使用情况的方法及装置,用以解决现有技术不能预测在程序运行过程中,将来程序运行资源使用情况的问题;预测程序运行资源使用情况的方法包括:在每个程序运行资源使用周期内采集至少一次程序运行资源使用量;将采集的程序运行资源使用量分解成不同种资源分量;针对每一种资源分量中包含的数据,确定该资源分量的预测函数;根据确定的每种资源分量的预测函数确定程序运行资源总体预测函数;基于确定的总体预测函数,预测程序运行资源的使用情况。

Description

判断资源泄漏、 预测资源使用情况的方法及装置 技术领域
本发明涉及计算机应用领域, 尤其涉及一种判断程序运行资源泄漏的方 法及装置、 一种预测程序运行资源使用情况的方法及装置。
背景技术 程序运行资源, 如内存、 文件句柄、 信号量、 数据库连接池、 线程池等 是程序运行时需要的关键资源。 在运行过程中, 程序在需要使用程序运行资 源时提出申请, 在使用结束后及时释放所占用的程序运行资源; 若没有及时 释放已占用的程序运行资源, 就会出现程序运行资源泄漏的问题。 下面以内 存泄漏为例, 对程序运行资源泄漏的问题作具体说明。
内存泄漏是指由于设计或编码问题等造成程序没有及时释放已经不再使 用的内存, 导致系统的可用内存越来越少, 随着程序长时间运行, 内存泄漏 越来越严重, 最终可能导致系统由于内存不足而使业务受损或中断。 内存泄 漏是程序运行过程中容易出现而又难以避免的问题, 随着软件规模越来越大、 复杂度越来越高, 系统中出现内存泄漏的概率也越来越高。
针对内存泄漏的问题, 现有检测内存泄漏的方法之一是釆用静态分析的 方法, 这种方法不需要运行程序, 而是通过人工或自动化工具分析程序代码 以检查代码中内存分配和释放的匹配情况。 对于内存分配和释放的对应关系 比较简单的情况, 静态分析方法通常可以有效检测出潜在的内存泄漏, 但对 于内存分配和释放的对应关系比较复杂的情况, 如在一个函数中分配内存, 在另外一个甚至多个函数中释放对应的内存等, 静态分析方法通常容易出现 误才艮和漏才艮。
现有检测内存泄漏的方法之二是在程序运行过程中动态监控内存的分配 要对程序中所有相关的内存分配和释放进行管理, 并需要准确判断内存的生 命周期, 导致实施复杂、 对系统性能消耗较大; 另一方面, 为了实现对内存 分配函数和释放函数的接管, 需要根据具体的应用程序作相应的代码修改, 检测的目标系统耦合紧密, 通用性较差。 另外, 现有技术只能检测是否存在内存泄漏, 而对将来的内存使用情况, 如多长时间后会出现内存耗尽或多长时间后内存使用量将达到设定阔值等, 不能提供预测。 发明内容 本发明实施例提供一种判断程序运行资源泄漏的方法及装置, 用以解决 现有的检测程序运行资源泄漏的方法中, 容易出现误报和漏报、 对系统性能 消耗大、 通用性较差的问题。
第一方面, 提供一种判断程序运行资源泄漏的方法, 包括:
在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其 中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的 周期;
针对任意两个程序运行资源使用周期, 确定在后周期内每次釆集的程序 运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周 期内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围内; 根据在确定的各差值中大于 0的差值总数与小于 0的差值总数之差, 判 断是否存在程序运行资源泄漏。
结合第一方面, 在第一种可能的实现方式中, 所述预设范围为: 小于所 述在前周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为:小于所述在后周期内每相邻两次釆集的时间间隔中的 最小时间间隔的时间长度范围。
结合第一方面, 在第二种可能的实现方式中, 确定在后周期内每次釆集 的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的 差值之前, 还包括:
确定釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当前程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU 占用率小于设定的阔值, 和 /或当前时间在设定的时间范围内。
结合第一方面或者第一方面的第二种可能的实现方式, 在第三种可能的 实现方式中, 根据所述大于 0的差值总数与小于 0的差值总数之差, 判断是 否存在程序运行资源泄漏, 包括:
若所述大于 0的差值总数与小于 0的差值总数之差大于设定的阔值, 则 确定存在程序运行资源泄漏。
结合第一方面的第三种可能的实现方式, 在第四种可能的实现方式中, 所述阔值的范围为大于或等于 0,并且小于或等于确定的各差值中大于 0的差 值总数与小于 0的差值总数之和的 70%。
结合第一方面或者第一方面的第二种可能的实现方式, 在第五种可能的 实现方式中, 根据所述大于 0的差值总数与小于 0的差值总数之差, 判断是 否存在程序运行资源泄漏, 包括:
确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏。
结合第一方面的第五种可能的实现方式, 在第六种可能的实现方式中, 根据以下公式确定所述大于 0的差值总数与小于 0的差值总数之差 S'的统计 量 Z: 若??≥10,则 Ϊ7Τ ;其中, η为程序运行资源使用周期的个数;
VAR(S/)
'-ι)
1/2 S' > 0 z = 0 s' = o
否则,
( + i)
, S' < 0
VAR(Sf) 其中, = fe ) ; Rlk为在第
Figure imgf000006_0001
k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量, m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数。
结合第一方面的第五种可能的实现方式, 在第七种可能的实现方式中, 所述阔值为根据所述统计量 Z的概率分布确定的分位值。
第二方面, 提供一种判断程序运行资源泄漏的装置, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 并将釆集的程序运行资源使用量传输至确定模块, 其中, 在每 个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序 运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期;
确定模块, 用于接收所述釆集模块每次釆集的程序运行资源使用量, 并 针对任意两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运行 资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 并将 确定的各差值传输至判断模块, 其中在后周期内每次釆集的时间与在后周期 的起始时间的时间差, 和在前周期内对应次釆集的时间与在前周期的起始时 间的时间差在一个预设范围内;
判断模块, 用于接收所述确定模块确定的各差值, 并根据在确定的各差 值中大于 0的差值总数与小于 0的差值总数之差, 判断是否存在程序运行资 源泄漏。
结合第二方面, 在第一种可能的实现方式中, 所述预设范围为: 小于所 述在前周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围 , 或者, 所述预设范围为:小于所述在后周期内每相邻两次釆集的时间间隔中的 最小时间间隔的时间长度范围。
结合第二方面, 在第二可能的实现方式中, 所述判断模块具体用于: 若所述大于 0的差值总数与小于 0的差值总数之差大于设定的阔值, 则 确定存在程序运行资源泄漏。
结合第二方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述阔值的范围为大于或等于 0 ,并且小于或等于确定的各差值中大于 0的差 值总数与小于 0的差值总数之和的 70%。
结合第二方面, 在第四种可能的实现方式中, 所述判断模块具体用于: 确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏。
结合第二方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述判断模块具体用于根据以下公式确定所述大于 0的差值总数与小于 0的 差值总数之差 S'的统计量 Z:
Figure imgf000007_0001
为程序运行资源源使用周期的个 数;
z = 否则,
Figure imgf000007_0002
n-\ n m m
St =∑∑ gn (R, - Rik \ S' =∑ St , VAR (S') =∑ VAR (S, ) 其中, k=l l=k+l i=l i=l ; Rlk为在第 k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量, m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数。
结合第二方面的第四种可能的实现方式, 在第六种可能的实现方式中, 所述阔值为根据所述统计量 Z的概率分布确定的分位值。
第三方面, 提供一种判断程序运行资源泄漏的装置, 包括:
处理器, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量; 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量 的次数相同; 针对任意两个程序运行资源使用周期, 确定在后周期内每次釆 集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量 的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个预设 范围内; 根据在确定的各差值中大于 0的差值总数与小于 0的差值总数之差, 判断是否存在程序运行资源泄漏; 所述程序运行资源使用周期为根据程序运 行资源使用量的周期性规律设定的周期;
存储器, 用于存储所述处理器每次釆集的程序运行资源使用量及确定的 在后周期内每次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程 序运行资源使用量的差值。
第四方面, 提供一种判断程序运行资源泄漏的方法, 包括:
在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其 中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的 周期;
针对每两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运 行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其 中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期 内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围内, 其 中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔中的 最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内 每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围;
在确定的各差值中, 若所述大于 0的差值总数与小于 0的差值总数之差 大于设定的阔值, 则确定存在程序运行资源泄漏, 其中, 所述阔值的范围为 大于或等于 0 ,并且小于或等于确定的各差值中大于 0的差值总数与小于 0的 差值总数之和的 70%。
第五方面, 提供一种判断程序运行资源泄漏的方法, 包括:
在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其 中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的 周期;
针对每两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运 行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其 中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期 内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围内, 其 中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔中的 最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内 每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围;
确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏;
其中, 根据以下公式确定所述大于 0的差值总数与小于 0的差值总数之 s'的统计量 Z: Z ,1/2
VAR(Sf)
为程序运行资源使用周期的个
Figure imgf000010_0001
Z = 0 , sf = o
( +i)
VAR(Sf)
否则,
S, = ∑ J sgn fc - RJ, S' = , VAR (S,) =∑VAR (Si )
其中 l 1 l 二 1 二 1 ; Rlk为在 第 k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; 为在 第 1个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个 程序运行资源使用周期内釆集程序运行资源使用量的次数;
所述阔值为根据所述统计量 Z的概率分布确定的分位值。
第六方面, 提供一种判断程序运行资源泄漏的装置, 包括:
釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用 量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周 期性规律设定的周期;
确定模块, 用于针对每两个程序运行资源使用周期, 确定在后周期内每 次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使 用量的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间 差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个 预设范围内, 其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集 的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于 所述在后周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范 围;
判断模块, 用于在确定的各差值中大于 0的差值总数与小于 0的差值总 数之差大于设定的阔值时, 确定存在程序运行资源泄漏, 其中, 所述阔值的 范围为大于或等于 0 ,并且小于或等于确定的各差值中大于 0的差值总数与小 于 0的差值总数之和的 70%。
第七方面, 提供一种判断程序运行资源泄漏的装置, 包括:
釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用 量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周 期性规律设定的周期;
确定模块, 用于针对每两个程序运行资源使用周期, 确定在后周期内每 次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使 用量的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间 差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个 预设范围内, 其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集 的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于 所述在后周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范 围;
判断模块, 用于确定所述大于 0的差值总数与小于 0的差值总数之差的 统计量 Z; 若 Z大于设定的阔值, 则确定存在程序运行资源泄漏;
其中, 所述判断模块具体用于根据以下公式确定所述大于 0 的差值总数 与小于 0的差值总数之差 s'的统计量 Z:
,1/2
) 其中, n 为程序运行资源使用周期的个 VAR(S')
Z = 0 , sf = o
( +i)
1/2 S' < 0
VAR(S')
否则,
n-\
=∑∑ sgn (R, - Rik \ S' =∑ Si , VAR (S') =∑ VAR )
i=i i=i ; Rlk为在第 k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数;
所述阔值为根据所述统计量 Z的概率分布确定的分位值。
根据第一方面或第四方面或第五方面提供的判断程序运行资源泄漏的方 法, 第二方面或第三方面或第六方面或第七方面提供的判断程序运行资源泄 漏的装置, 釆用本发明实施例可以实现对程序运行过程中不同程序运行资源 使用周期的程序运行资源使用量的分析, 从而可以得到程序运行中不同阶段 的程序运行资源使用情况, 较准确地判断出当前是否存在程序运行资源泄漏, 比如内存泄漏, 另外, 本发明实施例仅需在程序运行中间隔性地釆集程序运 行资源使用量, 在釆集一定次数的程序运行资源使用量后, 判断是否存在程 序运行资源泄漏, 对系统性能消耗较低, 且适用于不同的目标系统, 通用性 较强。 本发明实施例还提供一种预测程序运行资源使用情况的方法及装置, 用 以解决现有技术不能预测在程序运行过程中, 将来程序运行资源使用情况的 问题。
第一方面, 提供一种预测程序运行资源使用情况的方法, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 所 述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周 期;
将釆集的程序运行资源使用量分解成不同种资源分量, 所述不同种资源 分量为根据程序运行资源的使用规律, 将程序运行资源分解成的具有不同变 化规律的组成部分;
针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 根据确定的每种资源分量的预测函数确定程序运行资源总体预测函数; 基于确定的总体预测函数, 预测程序运行资源的使用情况。
结合第一方面, 在第一种可能的实现方式中, 将釆集的程序运行资源使 用量分解成不同种资源分量之前, 还包括:
确定釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当前程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU 占用率小于设定的阔值, 和 /或当前时间在设定的时间范围内。
结合第一方面, 在第二种可能的实现方式中, 所述将釆集的程序运行资 源使用量分解成不同种资源分量, 包括: 将釆集的程序运行资源使用量分解 成体现程序运行资源使用量的周期性变化的季节分量和体现程序运行资源使 用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程 序运行资源使用量的随机性变化的随机分量。
结合第一方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述趋势分量的预测函数为将所述趋势分量中包含的数据进行线性拟合或非 线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数;
所述季节分量的预测函数为 St=Si , 其中, i=t mod T , t为预测时间, T为 程序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期 的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上 分位点。
结合第一方面, 在第四种可能的实现方式中, 所述根据确定的每种资源 分量的预测函数确定程序运行资源总体预测函数, 包括: 将确定的每种资源 分量的预测函数相加, 得到程序运行资源总体预测函数。
结合第一方面的第三种或第四种可能的实现方式, 在第五种可能的实现 方式中, 根据以下公式确定程序运行资源总体预测函数:
Figure imgf000014_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所 述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ 为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
结合第一方面或第一方面的第一种可能的实现方式, 在第六种可能的实 现方式中, 所述资源分量包括周期性变化的季节分量和随机性变化的随机分 i; 或
所述资源分量包括体现程序运行资源使用量的变化趋势的趋势分量和随 机性变化的随机分量; 或
所述资源分量包括体现程序运行资源使用量的变化趋势的趋势分量、 周 期性变化的季节分量和随机性变化的随机分量;
其中, 所述趋势分量的预测函数为将所述趋势分量中包含的数据进行线 性拟合或非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数; 所述季节分量的预测函数为 , 其中, i=t mod T , t为预测时间, T为程 序运行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行 资源使用量; 所述随机分量的预测函数为根据所述随机分量中包含的数据的均值和标 准差, 确定的一个置信上限。
结合第一方面的第六种可能的实现方式, 在第七种可能的实现方式中, 在所述资源分量包括趋势分量、 季节分量和随机分量时, 根据以下公式确定 程序运行资源总体预测函数:
Figure imgf000015_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; ( μ +k a ) 为所述随机分量的预测函数, 其中, μ为所 述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数。
结合第一方面或第一方面的第一至七种任一种可能的实现方式, 在第八 种可能的实现方式中, 基于确定的总体预测函数, 预测程序运行资源的使用 情况, 包括:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
结合第一方面或第一方面的第一至八种任一种可能的实现方式, 在第九 种可能的实现方式中, 在每个程序运行资源使用周期内釆集程序运行资源使 用量的次数相同。
第二方面, 提供一种预测程序运行资源使用情况的装置, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 并将釆集到的程序运行资源使用量传输至分解模块; 所述程序 运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 分解模块, 用于接收所述釆集模块釆集的程序运行资源使用量, 并将釆 集的程序运行资源使用量分解成不同种资源分量, 将每种资源分量中包含的 数据传输至确定模块, 所述不同种资源分量为根据程序运行资源的使用规律, 将程序运行资源分解成的具有不同变化规律的组成部分;
确定模块, 用于接收所述分解模块分解得到的每种资源分量中包含的数 据, 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数, 并根 据确定的每种资源分量的预测函数确定程序运行资源总体预测函数, 将确定 的总体预测函数传输至预测模块;
预测模块, 用于接收所述确定模块确定的总体预测函数, 并基于所述总 体预测函数, 预测程序运行资源的使用情况。
结合第二方面, 在第一种可能的实现方式中, 所述确定模块还用于, 在 所述釆集模块将釆集的程序运行资源使用量分解成不同种资源分量之前, 确 定釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当 前程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU占用率 小于设定的阔值, 和 /或当前时间在设定的时间范围内。
结合第二方面, 在第二种可能的实现方式中, 所述分解模块具体用于将 釆集的程序运行资源使用量分解成体现程序运行资源使用量的周期性变化的 季节分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程 序运行资源使用量的随机性变化的随机分量。
结合第二方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述趋势分量的预测函数为将所述趋势分量中包含的数据进行线性拟合或非 线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数;
所述季节分量的预测函数为 St=Si , 其中, i=t mod T , t为预测时间, T为 程序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期 的第 i个数据; 所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上 分位点。
结合第二方面, 在第四种可能的实现方式中, 确定模块用于根据确定的 每种资源分量的预测函数确定程序运行资源总体预测函数时, 具体用于: 将 确定的每种资源分量的预测函数相加, 得到程序运行资源总体预测函数。
结合第二方面的第三种或第四种可能的实现方式, 在第五种可能的实现 方式中, 确定模块用于根据确定的每种资源分量的预测函数确定程序运行资 源总体预测函数时, 具体用于: 根据以下公式确定程序运行资源总体预测函 数:
Figure imgf000017_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所 述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ 为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
结合第二方面或者第二方面的第一种可能的实现方式, 在第六种可能的 实现方式中, 所述分解模块分解后的资源分量包括周期性变化的季节分量和 随机性变化的随机分量; 或
所述分解模块分解后的资源分量包括体现程序运行资源使用量的变化趋 势的趋势分量和随机性变化的随机分量; 或
所述分解模块分解后的资源分量包括体现程序运行资源使用量的变化趋 势的趋势分量、 周期性变化的季节分量和随机性变化的随机分量;
其中, 所述趋势分量的预测函数为将所述趋势分量中包含的数据进行线 性拟合或非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数; 所述季节分量的预测函数为 , 其中, i=t mod T , t为预测时间, T为程 序运行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行 资源使用量; 所述随机分量的预测函数为根据所述随机分量中包含的数据的均值和标 准差, 确定的一个置信上限。
结合第二方面的第六种可能的实现方式, 在第七种可能的实现方式中, 所述确定模块具体用于在所述分解模块分解的资源分量包括趋势分量、 季节 分量和随机分量时, 根据以下公式确定程序运行资源总体预测函数:
Figure imgf000018_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; ( μ +k a ) 为所述随机分量的预测函数, 其中, μ为所 述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数。
结合第二方面, 在第八种可能的实现方式中, 所述预测模块具体用于: 根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
结合第二方面或第二方面的第一至八种任一种可能的实现方式, 在第九 种可能的实现方式中, 在每个程序运行资源使用周期内釆集程序运行资源使 用量的次数相同。
第三方面, 提供一种预测程序运行资源使用情况的装置, 包括: 处理器, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量; 将釆集的程序运行资源使用量分解成不同种资源分量, 所述不同 种资源分量为根据程序运行资源的使用规律, 将程序运行资源分解成的具有 不同变化规律的组成部分; 针对每一种资源分量中包含的数据, 确定该资源 分量的预测函数, 并根据确定的每种资源分量的预测函数确定程序运行资源 总体预测函数, 基于所述总体预测函数, 预测程序运行资源的使用情况; 所 述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周 期; 存储器, 用于存储所述处理器每次釆集的序运行资源使用量、 分解得到 的不同种资源分量包含的数据及所述预测函数。
第四方面, 提供一种预测程序运行资源使用情况的方法, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 将釆集的程序运行资源使用量分解成: 体现程序运行资源使用量的变化 趋势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现 程序运行资源使用量的随机性变化的随机分量;
针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 将确定的每种资源分量的预测函数相加, 得到程序运行资源总体预测函 数;
基于确定的总体预测函数, 预测程序运行资源的使用情况。
结合第四方面, 在第一种可能的实现方式中, 所述趋势分量的预测函数 为将所述趋势分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测 时间为自变量的线性函数或非线性函数;
所述季节分量的预测函数为 St=Si , 其中, i=t mod T , t为预测时间, T为 程序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期 的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上 分位点。
结合第四方面, 或第四方面的第一种可能的实现方式, 在第二种可能的 实现方式中, 根据以下公式确定程序运行资源总体预测函数:
Figure imgf000019_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所 述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ 为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。 结合第四方面或第四方面的第一至二种中任一种可能的实现方式, 在第 三种可能的实现方式中, 基于确定的总体预测函数, 预测程序运行资源的使 用情况, 包括:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
结合第四方面或第四方面的第一至三种中任一种可能的实现方式, 在第 四种可能的实现方式中, 在每个程序运行资源使用周期内釆集程序运行资源 使用量的次数相同。
结合第四方面或第四方面的第一至四种中任一种可能的实现方式, 在第 五种可能的实现方式中, 所述程序运行资源使用周期为根据程序运行资源使 用量的周期性规律设定的周期。
第五方面, 提供一种预测程序运行资源使用情况的装置, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量;
分解模块,用于将釆集的程序运行资源使用量分解成: 体现程序运行资源 使用量的变化趋势的趋势分量、 体现程序运行资源使用量的周期性变化的季 节分量和体现程序运行资源使用量的随机性变化的随机分量;
确定模块, 用于针对每一种资源分量中包含的数据, 确定该资源分量的 预测函数, 并将确定的每种资源分量的预测函数相加, 得到程序运行资源总 体预测函数;
预测模块, 用于基于所述总体预测函数, 预测程序运行资源的使用情况。 结合第五方面, 在第一种可能的实现方式中, 所述趋势分量的预测函数 为将所述趋势分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测 时间为自变量的线性函数或非线性函数;
所述季节分量的预测函数为 St=Si , 其中, i=t mod T , t为预测时间, T为 程序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期 的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上 分位点。
结合第五方面或第五方面的第一种可能的实现方式, 在第二种可能的实 现方式中, 其特征在于, 所述确定模块具体用于根据以下公式确定程序运行 资源总体预测函数:
Figure imgf000021_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所 述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ 为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
结合第五方面或第五方面的第一至二种中任一种可能的实现方式, 在第 三种可能的实现方式中, 所述预测模块具体用于:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
结合第五方面或第五方面的第一至三种中任一种可能的实现方式, 在第 四种可能的实现方式中, 在每个程序运行资源使用周期内釆集程序运行资源 使用量的次数相同。
结合第五方面或第五方面的第一至四种中任一种可能的实现方式, 在第 五种可能的实现方式中, 所述程序运行资源使用周期为根据程序运行资源使 用量的周期性规律设定的周期。
根据第一方面或第四方面提供的预测程序运行资源使用情况的方法, 第 二方面或第三方面或第五方面提供的预测程序运行资源使用情况的装置, 本 发明实施例根据程序运行资源的使用规律, 将程序运行资源使用量分解成具 有不同变化规律的组成部分, 并对不同组成部分分别进行拟合和估计, 得到 准确反映不同组成部分的程序运行资源使用量变化规律的预测函数, 进而得 到反映总体的程序运行资源使用量变化规律的预测函数, 从而釆用本发明实 施例可以较准确地预测出将来的程序运行资源使用情况, 弥补了现有技术不 能预测程序运行过程中资源使用情况的缺陷。
附图说明 图 1为本发明实施例提供的判断程序运行资源泄漏的方法流程图; 图 2为本发明较佳的实施例提供的判断程序运行资源泄漏的方法流程图; 图 3为本发明实施例提供的判断程序运行资源泄漏的装置结构示意图; 图 4为本发明实施例提供的判断程序运行资源泄漏的装置结构图; 图 5为本发明实施例提供的预测程序运行资源使用情况的方法流程图; 图 6 为本发明实施例釆用经典的时间序列分解方法将程序运行资源使用 量分解成趋势分量、 季节分量和随机分量的示意图;
图 7 为本发明较佳的实施例提供的预测程序运行资源使用情况的方法流 程图; 法流程图;
图 9 为本发明实施例提供的预测程序运行资源使用情况的装置结构示意 图;
图 10为本发明实施例提供的预测程序运行资源使用情况的装置结构图; 图 11为本发明实施例检测资源泄漏、 预测资源使用情况的装置部署示意 图。
具体实施方式 本发明实施例通过在每个程序运行资源使用周期内釆集至少一次程序运 行资源使用量, 针对任意两个程序运行资源使用周期, 确定在后周期内每次 釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用 量的差值, 根据在确定的各差值中大于 0的差值总数与小于 0的差值总数之 差, 判断是否存在程序运行资源泄漏。 釆用本发明实施例可以实现对程序运 行过程中不同程序运行资源使用周期的程序运行资源使用量的分析, 从而可 以得到程序运行中不同阶段的程序运行资源使用情况, 较准确地判断出当前 是否存在程序运行资源泄漏, 比如内存泄漏, 另外, 本发明实施例仅需在程 序运行中间隔性地釆集程序运行资源使用量, 在釆集一定次数的程序运行资 源使用量后, 判断是否存在程序运行资源泄漏, 对系统性能消耗较低, 且适 用于不同的应用程序, 通用性较强。
本发明实施例通过在每个程序运行资源使用周期内釆集至少一次程序运 行资源使用量, 将釆集的程序运行资源使用量分解成不同种资源分量, 针对 每一种资源分量中包含的数据, 确定该资源分量的预测函数, 根据确定的每 种资源分量的预测函数确定程序运行资源总体预测函数, 最后基于确定的总 体预测函数, 预测程序运行资源的使用情况。 本发明实施例根据程序运行资 源的使用规律, 将程序运行资源使用量分解成具有不同变化规律的组成部分, 并对不同组成部分分别进行拟合和估计, 得到准确反映不同组成部分的程序 运行资源使用量变化规律的预测函数, 进而得到反映总体的程序运行资源使 用量变化规律的预测函数, 从而釆用本发明实施例可以较准确地预测出将来 的程序运行资源使用情况, 弥补了现有技术不能预测程序运行过程中资源使 用情况的缺陷。
本发明的实施例提供一种判断程序运行资源泄漏的方法, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其 中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的 周期;
针对每两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运 行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其 中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期 内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围内, 其 中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔中的 最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内 每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围;
在确定的各差值中, 若所述大于 0的差值总数与小于 0的差值总数之差 大于设定的阔值, 则确定存在程序运行资源泄漏, 其中, 所述阔值的范围为 大于或等于 0, 并且小于或等于确定的各差值中大于 0 的差值总数与小于 0 的差值总数之和的 70%。
本发明的实施例还提供一种判断程序运行资源泄漏的方法, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其 中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的 周期;
针对每两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运 行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其 中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期 内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围内, 其 中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔中的 最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内 每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围;
确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏; 其中, 根据以下公式确定所述大于 0的差值总数与小于 0的差值总数之 s'的统计量 Z:
Z - ,1/2
VAR(Sf)
其中, n 为程序运行资源使用周期的个
Figure imgf000025_0001
Z 二 0 s' = o
( + i)
, s' < o
VAR(Sf)
否则,
Figure imgf000025_0002
ik为在 第 k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; Rn为在第 I个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程 序运行资源使用周期内釆集程序运行资源使用量的次数;
所述阔值为根据所述统计量 Z的概率分布确定的分位值。
本发明的实施例还提供一种判断程序运行资源泄漏的装置, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用 量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周 期性规律设定的周期;
确定模块, 用于针对每两个程序运行资源使用周期, 确定在后周期内每 次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使 用量的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间 差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个 预设范围内, 其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集 的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于 所述在后周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范 围;
判断模块, 用于在确定的各差值中大于 0的差值总数与小于 0的差值总 数之差大于设定的阔值时, 确定存在程序运行资源泄漏, 其中, 所述阔值的 范围为大于或等于 0,并且小于或等于确定的各差值中大于 0的差值总数与小 于 0的差值总数之和的 70%。
本发明的实施例还提供一种判断程序运行资源泄漏的装置, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用 量的次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周 期性规律设定的周期;
确定模块, 用于针对每两个程序运行资源使用周期, 确定在后周期内每 次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使 用量的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间 差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个 预设范围内, 其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集 的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于 所述在后周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范 围;
判断模块, 用于确定所述大于 0的差值总数与小于 0的差值总数之差的 统计量 Z; 若 Z大于设定的阔值, 则确定存在程序运行资源泄漏;
其中, 所述判断模块具体用于根据以下公式确定所述大于 0 的差值总数 与小于 0的差值总数之差 ^的统计量 Z:
,1/2
VAR(S')
其中, n 为程序运行资源使用周期的个 ,1/2
VAR (S')
Z = 0 , sf = o
( +i)
1/2 S'< 0
VAR (S')
否则,
n-\
St =∑ ∑ gn (R, - Rik ), Sf =∑ Si , VAR (S') =∑ VAR (St ) 其中, k=l l=k+l i=l i=l ; Rik为在第 k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; Rn为在第 I 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数;
所述阔值为根据所述统计量 Z的概率分布确定的分位值。
下面结合说明书附图对本发明实施例作进一步详细描述。
如图 1 所示, 为本发明实施例提供的判断程序运行资源泄漏的方法流程 图, 包括以下步骤:
S101 : 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用 量; 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数 相同; 程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定 的周期;
S102: 针对任意两个程序运行资源使用周期, 确定在后周期内每次釆集 的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的 差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和 在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范 围内;
S103: 根据在确定的各差值中大于 0的差值总数与小于 0的差值总数之 差, 判断是否存在程序运行资源泄漏。 本发明实施例中的程序运行资源可以是内存资源, 也可以是程序运行需 要的文件句柄、 信号量、 数据库连接池、 或线程池等软件资源; 本发明实施 例判断是否存在程序运行资源泄漏的目标对象可以是不同层级的, 如主机、 虚拟机、 进程、 进程子模块、 进程的内存分区等。
本发明实施例的基本思想是根据程序运行资源使用量的周期性特点, 在 每个程序运行资源使用周期内釆集一次或多次程序运行资源使用量, 确定在 后周期内每次釆集的程序运行资源使用量与在前周期对应次釆集的程序运行 资源使用量的差值, 这里, 针对一个差值, 若该差值大于 0 , 则表示在该差值 对应的两个程序运行资源使用量中, 在后周期的程序运行资源使用量相比在 前周期的程序运行资源使用量是上升的, 若该差值小于 0 , 则表示该差值对应 的两个程序运行资源使用量中, 在后周期的程序运行资源使用量相比在前周 期的程序运行资源使用量是下降的, 若该差值等于 0 , 则表示该差值对应的两 个程序运行资源使用量中, 在后周期的程序运行资源使用量与在前周期的程 序运行资源使用量是相等的; 因此, 确定的所有周期对应的各差值中, 大于 0 的差值总数标识了釆集的程序运行资源使用量总次数中, 程序运行资源使用 量随时间上升的次数, 而小于 0 的差值总数则标识了釆集的程序运行资源使 用量总次数中, 程序运行资源使用量随时间下降的次数, 因此, 大于 0 的差 值总数与小于 0 的差值总数的差值, 则可以标识程序运行资源使用量总体的 上升或下降情况。 这里, 在后周期内每次釆集的时间与在后周期的起始时间 的时间差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差 在一个预设范围内, 在实际实施中, 为了使判断结果更加准确, 可以使在后 周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期内对应 次釆集的时间与在前周期的起始时间的时间差相同。
进一步地, 在该本发明的实施例中, 所述预设范围为: 小于所述在前周 期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内每相邻两次釆集的时间间隔中的最小 时间间隔的时间长度范围。
较佳地, 可以在每个程序运行资源使用周期内, 以相同的设定频率釆集 程序运行资源使用量。
较佳地, 确定在后周期内每次釆集的程序运行资源使用量, 与在前周期 内对应次釆集的程序运行资源使用量的差值之前, 还包括:
确定釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当前程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU 占用率小于设定的阔值, 和 /或当前时间在设定的时间范围内。
在具体实施过程中, 可以设置一个或几个启动判断是否存在程序运行资 源泄漏的条件, 如当前已釆集的程序运行资源使用量总周期数或总次数已达 到或超过设定的阔值、 当前程序运行资源占用率已达到或超过设定的阔值, 当前 CPU占用率小于设定的阔值, 当前时间是在设定的时间范围内等。
在具体实施过程中, 可以设置当达到上述判断条件中的任意一个或几个 时, 启动判断是否存在程序运行资源泄漏。 这里, 由于釆集的程序运行资源 使用量总周期数或总次数越多, 判断结果越准确, 因此可以设置一个阔值, 当釆集的程序运行资源使用量总周期数或总次数已达到或超过设定的阔值 时, 启动判断是否存在程序运行资源泄漏; 还可以考虑当前的 CPU占用率, 若当前 CPU占用率较高, 说明当前系统繁忙, 为了不影响系统性能, 可以设 置在 CPU占用率小于设定阔值时, 才启动判断是否存在程序运行资源泄漏; 还可以设置一个启动判断的时间范围, 设置在系统空闲的时间执行判断是否 存在程序运行资源泄漏; 此外, 还可以设置程序运行资源占用率第一阔值, 其中, 程序运行资源占用率达到第一阔值说明程序运行资源耗尽的危险性比 较高, 可以设置当程序运行资源占用率达到第一阔值时, 不管是否满足其它 判断条件, 都启动判断是否存在程序运行资源泄漏; 另外, 还可以设置程序 运行资源占用率第二阔值, 其中, 程序运行资源占用率未达到第二阔值说明 程序运行资源还比较宽裕, 可以设置在程序运行资源占用率未达到第二阔值 时, 不管是否满足其它判断条件, 都不启动判断是否存在程序运行资源泄漏。 在具体实施过程中, 根据确定的各差值中大于 0的差值总数与小于 0的 差值总数之差, 判断是否存在程序运行资源泄漏的方式可以有多种, 本发明 实施例给出以下两种实现方式:
方式一、 根据大于 0的差值总数与小于 0的差值总数之差是否大于设定 的阔值, 判断是否存在程序运行资源泄漏;
具体地, 根据大于 0的差值总数与小于 0的差值总数之差, 判断是否存 在程序运行资源泄漏, 包括:
若所述大于 0的差值总数与小于 0的差值总数之差大于设定的阔值, 则 确定存在程序运行资源泄漏。
在该实现方式中, 所述阔值的范围为大于或等于 0, 并且小于或等于确定 的各差值中大于 0的差值总数与小于 0的差值总数之和的 70%。
这里, 由于大于 0的差值总数与小于 0的差值总数的差值, 可以标识程 序运行资源使用量总体的上升或下降情况, 因此可以直接根据大于 0 的差值 个数与小于 0 的差值个数之差是否已达到或超过设定的阔值来判断是否存在 程序运行资源泄漏, 如在总的差值个数中, 有 90%的差值是大于 0的, 只有 10%的差值是小于 0的, 则可以认为当前存在程序运行资源泄漏。
该方式对于判断是否存在程序运行资源泄漏较为直观, 实施过程也较为 简单, 对系统性能影响也非常小。
方式二、 根据大于 0的差值总数与小于 0的差值总数之差的统计量 Z是 否大于设定的阔值, 判断是否存在程序运行资源泄漏;
具体地, 根据大于 0的差值总数与小于 0的差值总数之差, 判断是否存 在程序运行资源泄漏, 包括:
确定大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏。
在该种实现方式中, 所述阔值为根据所述统计量 Z的概率分布确定的分 位值 t
本实施方式的基本思想是釆用概率统计的方式, 不直接将大于 0 的差值 个数与小于 0 的差值个数的差值 与设定阔值比较, 而是确定与 具有对 应关系的统计量 Z, 该统计量 Z是一个可以表征 大小并满足一个概率分布 的量; 本实施方式根据统计量 Z是否大于设定的阔值来判断是否存在程序运 行资源泄漏。
较佳地, 根据以下公式确定所述大于 0的差值总数与小于 0的差值总数 之差 的统计量 Z: 若??≥10,则 Ϊ7Τ ;其中, η为程序运行资源使用周期的个数;
VAR(S')
'-ι)
,1/2
VAR(S')
z = 0 , sf = o
否则,
( +i)
1/2 S' < 0
VAR(S') n-\
其中, =∑∑sgn( — RJ S' =∑ , ^R (S') =∑^te ) ; Rlk为在第 l 1 l:l +l 二 1 二 1
k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数。
这里, 与 具有上述对应关系的统计量 Z服从标准正态分布, VAR()为 方差函数, sgn()为符号函数, 当在后周期内一次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值大于 0 时, 该符号函 数值为 1 , 当在后周期内一次釆集的程序运行资源使用量, 与在前周期内对应 次釆集的程序运行资源使用量的差值小于 0时,该符号函数值为 -1 , 当在后周 期内一次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行 资源使用量的差值等于 0时, 该符号函数值为 0。 这里,设置的统计量 z的阔值 ζα为在标准正态分布中的上分位点,其中, 统计量 Ζ大于阔值 概率为 o , o的值可以根据实际需要设定, 如 5%、 1% 等, 若确定的 Ζ大于 Ζα, 则确定存在程序运行资源泄漏, 相反, 若 Ζ不大于 Ζα, 则认为不存在程序运行资源泄漏。
下面将列举一个较典型的判断程序运行资源泄漏的实施方式。
如图 2 所示, 为本发明较佳的实施例提供的判断程序运行资源泄漏的方 法流程图, 包括:
S201 : 在每个程序运行资源使用周期内以设定频率釆集多次程序运行资 源使用量;
S202: 判断釆集的程序运行资源使用量总周期数或总次数是否不小于设 定的阔值, 若是, 则进入步骤 S203 , 否则返回步骤 S201 ;
在具体实施过程中, 还可以设置其它判断条件, 如当前程序运行资源占 用率是否不小于设定的阔值, 当前中央处理器 CPU占用率是否小于设定的阔 值, 当前时间是否在设定的时间范围内等。
S203 : 针对任意两个程序运行资源使用周期, 确定在后周期内每次釆集 的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的 差值;
S204: 根据在确定的各差值中大于 0的差值总数与小于 0的差值总数之 差, 判断是否存在程序运行资源泄漏。
在具体实施过程中, 根据大于 0的差值总数与小于 0的差值总数之差, 判断是否存在程序运行资源泄漏, 可以具体釆用上述方式一或方式二, 这里 不再赘述。
基于同一发明构思, 本发明实施例中还提供了一种与判断程序运行资源 泄漏的方法对应的判断程序运行资源泄漏的装置, 由于该装置解决问题的原 理与本发明实施例判断程序运行资源泄漏的方法相似, 因此该装置的实施可 以参见方法的实施, 重复之处不再赘述。 如图 3 所示, 为本发明实施例提供的判断程序运行资源泄漏的装置结构 示意图, 包括:
釆集模块 31 , 用于在每个程序运行资源使用周期内釆集至少一次程序运 行资源使用量, 并将釆集的程序运行资源使用量传输至确定模块, 其中, 在 每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程 序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 确定模块 32 , 用于接收釆集模块 31每次釆集的程序运行资源使用量, 并 针对任意两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运行 资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 并将 确定的各差值传输至判断模块 33 , 其中在后周期内每次釆集的时间与在后周 期的起始时间的时间差, 和在前周期内对应次釆集的时间与在前周期的起始 时间的时间差在一个预设范围内;
判断模块 33 , 用于接收确定模块 32确定的各差值, 并根据在确定的各差 值中大于 0的差值总数与小于 0的差值总数之差, 判断是否存在程序运行资 源泄漏。
进一步地, 在该实施例中, 所述预设范围为: 小于所述在前周期内每相 邻两次釆集的时间间隔中的最小时间间隔的时间长度范围, 或者, 所述预设 范围为: 小于所述在后周期内每相邻两次釆集的时间间隔中的最小时间间隔 的时间长度范围。
较佳地, 确定模块 32还用于, 在确定在后周期内每次釆集的程序运行资 源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值之前, 确 定釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当 前程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU占用率 小于设定的阔值, 和 /或当前时间在设定的时间范围内。
较佳地, 判断模块 33具体用于: 若大于 0的差值总数与小于 0的差值总 数之差大于设定的阔值, 则确定存在程序运行资源泄漏。 其中, 所述阔值的 范围为大于或等于 0,并且小于或等于确定的各差值中大于 0的差值总数与小 于 0的差值总数之和的 70%
较佳地, 判断模块 33具体用于:
确定大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏。 其中, 所述阔值 为根据所述统计量 Z的概率分布确定的分位值。
较佳地, 判断模块 33具体用于根据以下公式确定大于 0的差值总数与小 于 0的差值总数之差 S '的统计量 Z:
S'
若??≥10,则 Ϊ7Τ ;其中, n为程序运行资源使用周期的个数;
VAR(S/) '― 1)
1/2 S' > 0
Z 二 0 s' = o
否则,
( + i)
, S' < 0
VAR(Sf) 其中, Rlk为在第
Figure imgf000034_0001
k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数。
如图 4 所示, 为本发明实施例提供的判断程序运行资源泄漏的装置结构 图, 包括:
处理器 41 , 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量; 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用 量的次数相同; 程序运行资源使用周期为根据程序运行资源使用量的周期性 规律设定的周期; 针对任意两个程序运行资源使用周期, 确定在后周期内每 次釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使 用量的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间 差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个 预设范围内; 根据在确定的各差值中大于 0的差值总数与小于 0的差值总数 之差, 判断是否存在程序运行资源泄漏;
存储器 42 , 用于存储所述处理器每次釆集的程序运行资源使用量及确定 的在后周期内每次釆集的程序运行资源使用量, 与在前周期内对应次釆集的 程序运行资源使用量的差值。
其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间 隔中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后 周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围。
较佳地, 处理器 41还用于, 在确定在后周期内每次釆集的程序运行资源 使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值之前, 确定 釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当前 程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU占用率小 于设定的阔值, 和 /或当前时间在设定的时间范围内。
较佳地, 处理器 41具体用于: 若所述大于 0的差值总数与小于 0的差值 总数之差大于设定的阔值, 则确定存在程序运行资源泄漏。 其中, 所述阔值 的范围为大于或等于 0,并且小于或等于确定的各差值中大于 0的差值总数与 小于 0的差值总数之和的 70%。
较佳地, 处理器 41具体用于: 确定所述大于 0的差值总数与小于 0的差 值总数之差的统计量 Z; 若 Z大于设定的阔值, 则确定存在程序运行资源泄 漏。 其中, 所述阔值为根据所述统计量 Z的概率分布确定的分位值。
较佳地, 处理器 41具体用于根据以下公式确定所述大于 0的差值总数与 小于 0的差值总数之差 S'的统计量 Z: 若"≥10,则2 =7 — ^ΪΤΤ ;其中, η为程序运行资源使用周期的个数;
VAR(S )」 '-ι)
,1/2
VAR(S')
0 , sf = o
否则,
( +i)
S' < 0
VAR(S') 其中, = fe ) ; Rlk为在第
Figure imgf000036_0001
k个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序 运行资源使用周期内釆集程序运行资源使用量的次数。
本发明提供一种预测程序运行资源使用情况的方法, 包括:
在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 将釆集的程序运行资源使用量分解成: 体现程序运行资源使用量的变化 趋势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现 程序运行资源使用量的随机性变化的随机分量;
针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 将确定的每种资源分量的预测函数相加, 得到程序运行资源总体预测函 数;
基于确定的总体预测函数, 预测程序运行资源的使用情况。
进一步地, 在本实施例中, 所述趋势分量的预测函数为将所述趋势分量 中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为自变量的线 性函数或非线性函数;
所述季节分量的预测函数为 St=S 其中, i=t mod T, t为预测时间, T 为程序运行资源使用周期, Si为 t所属的所述季节分量的程序运行资源使用周 期的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上 分位点。 进一步地, 在本实施例中, 可以根据以下公式确定程序运行资源总体预 测函数:
Figure imgf000037_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, Τ为程序运行资源使用周期; ( μ +k a )为 所述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
进一步地, 在本实施例中, 所述基于确定的总体预测函数, 预测程序运 行资源的使用情况, 可以包括:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
进一步地, 在本实施例中, 在每个程序运行资源使用周期内釆集程序运 行资源使用量的次数相同。
进一步地, 在本实施例中, 所述程序运行资源使用周期为根据程序运行 资源使用量的周期性规律设定的周期。
本发明的实施例还提供一种预测程序运行资源使用情况的装置, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量;
分解模块,用于将釆集的程序运行资源使用量分解成: 体现程序运行资源 使用量的变化趋势的趋势分量、 体现程序运行资源使用量的周期性变化的季 节分量和体现程序运行资源使用量的随机性变化的随机分量;
确定模块, 用于针对每一种资源分量中包含的数据, 确定该资源分量的 预测函数, 并将确定的每种资源分量的预测函数相加, 得到程序运行资源总 体预测函数;
预测模块, 用于基于所述总体预测函数, 预测程序运行资源的使用情况。 进一步地, 在本实施例中, 所述趋势分量的预测函数可以为将所述趋势 分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为自变量 的线性函数或非线性函数;
所述季节分量的预测函数可以为 St=S 其中, i=t mod T, t为预测时间,
T为程序运行资源使用周期, Si为 t所属的所述季节分量的程序运行资源使用 周期的第 i个数据;
所述随机分量的预测函数可以为一个常数,所述常数为所述随机分量的一 个上分位点。
进一步地, 在本实施例中, 所述确定模块可以具体用于根据以下公式确 定程序运行资源总体预测函数:
Figure imgf000038_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, Τ为程序运行资源使用周期; ( μ +k a )为 所述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
进一步地, 在本实施例中, 所述预测模块具体用于:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
进一步地, 在本实施例中, 在每个程序运行资源使用周期内釆集程序运 行资源使用量的次数相同。
进一步地, 在本实施例中, 所述程序运行资源使用周期为根据程序运行 资源使用量的周期性规律设定的周期。
如图 5 所示, 为本发明实施例提供的预测程序运行资源使用情况的方法 流程图, 包括:
S501 : 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用 量; 程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的 周期;
S502: 将釆集的程序运行资源使用量分解成不同种资源分量, 所述不同 种资源分量为根据程序运行资源的使用规律, 将程序运行资源分解成的具有 不同变化规律的组成部分;
S503 : 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 根据确定的每种资源分量的预测函数确定程序运行资源总体预测函数;
S504: 基于确定的总体预测函数, 预测程序运行资源的使用情况。
本发明实施例中的程序运行资源可以是内存资源, 也可以是程序运行需 要的文件句柄、 信号量、 数据库连接池、 或线程池等软件资源; 本发明实施 例预测程序运行资源使用情况的目标对象可以是不同层级的, 如主机、 虚拟 机、 进程、 进程子模块、 进程的内存分区等。
本发明实施例的基本思想是根据程序运行资源的使用规律, 将程序运行 资源分解成具有不同变化规律的组成部分, 即不同的资源分量, 对每种资源 分量分别进行拟合和估计, 确定每种资源分量的预测函数, 再将确定的每种 资源分量的预测函数进行整合, 得到程序运行资源的总体预测函数, 根据该 总体预测函数预测将来程序运行资源的使用情况。
较佳地, 步骤 S502之前, 还包括:
确定釆集的程序运行资源使用量总周期数或总次数不小于设定的阔值, 和 /或当前程序运行资源占用率不小于设定的阔值,和 /或当前中央处理器 CPU 占用率小于设定的阔值, 和 /或当前时间在设定的时间范围内。
较佳地, 分解成的资源分量包括周期性变化的季节分量和随机性变化的 随机分量; 或
分解成的资源分量包括体现程序运行资源使用量的变化趋势的趋势分量 和随机性变化的随机分量; 或
分解成的资源分量包括体现程序运行资源使用量的变化趋势的趋势分 量、 周期性变化的季节分量和随机性变化的随机分量;
其中, 趋势分量的预测函数为将该趋势分量中包含的数据进行线性拟合 或非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数;
季节分量的预测函数为 S1 其中, i=t mod T, t为预测时间, T为程序运 行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行资源 使用量;
随机分量的预测函数为根据所述随机分量中包含的数据的均值和标准 差, 确定的一个置信上限。
作为另外一种选择, 所述趋势分量的预测函数可以为将所述趋势分量中 包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为自变量的线性 函数或非线性函数;
所述季节分量的预测函数可以为 St=S 其中, i=t mod T, t为预测时间, T为程序运行资源使用周期, Si为 t所属的所述季节分量的程序运行资源使用 周期的第 i个数据;
所述随机分量的预测函数可以为一个常数,所述常数为所述随机分量的一 个上分位点。
进一步地, 在该实施例中, 所述根据确定的每种资源分量的预测函数确 定程序运行资源总体预测函数, 可以包括: 将确定的每种资源分量的预测函 数相加, 得到程序运行资源总体预测函数。
进一步地, 在该实施例中, 可以根据以下公式确定程序运行资源总体预 测函数:
Figure imgf000040_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, Τ为程序运行资源使用周期; ( μ +k a )为 所述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。 进一步地, 在该实施例中, 在每个程序运行资源使用周期内釆集程序运 行资源使用量的次数相同。
在具体实施过程中, 可以根据程序运行资源的使用规律, 将程序运行资 源分解成季节分量和随机分量, 或趋势分量和随机分量, 或趋势分量、 季节 分量和随机分量, 其中, 趋势分量是体现程序运行资源使用量的变化趋势的 分量, 季节分量表示程序运行资源使用量具有周期性变化规律的量, 随机分 量表示程序运行资源使用量随机性变化的量。
在具体实施过程中, 若将程序运行资源使用量分解成趋势分量、 季节分 量和随机分量, 可以釆用时间序列分解方法, 如经典分解方法或 STL分解方 法等。 下面以经典分解方法为例, 详细说明将程序运行资源使用量分解成趋 势分量、 季节分量和随机分量的步骤:
假设一个周期内釆集的程序运行资源使用量次数为奇数 N, 针对釆集的 一次程序运行资源使用量, 将该次之前釆集的(N-1 ) /2次程序运行资源使用 量、 该次之后釆集的 (N-l ) /2次程序运行资源使用量、 及该次釆集的程序运 行资源使用量相加, 并除以一个周期内釆集的程序运行资源使用量的总次数, 得到该次釆集的程序运行资源使用量对应的趋势分量的数值; 将该次釆集的 程序运行资源使用量与对应的趋势分量的数值相减, 得到该次釆集的程序运 行资源使用量对应的季节分量和随机分量的和值, 在此基础上确定每个周期 对应次釆集的程序运行资源使用量对应的季节分量和随机分量的和值的平均 值, 将该平均值作为每个周期对应次釆集的程序运行资源使用量对应的季节 分量的数值, 也即, 不同周期的季节分量的数值相同; 最后, 将该次釆集的 程序运行资源使用量减去对应的趋势分量和季节分量, 得到该次釆集的程序 运行资源使用量对应的随机分量。
如图 6 所示, 为本发明实施例釆用经典的时间序列分解方法将程序运行 资源使用量分解成趋势分量、 季节分量和随机分量的示意图; 图中的横纵坐 标值只作为示意, 这里不作关于单位等的具体说明, 该图共对应 6个周期的 程序运行资源使用量, 每个周期内分别釆集 96次程序运行资源资源使用量。 较佳地, 在资源分量包括趋势分量、 季节分量和随机分量时, 根据以下 公式确定程序运行资源总体预测函数:
Figure imgf000042_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为趋势分量的预测函数, a和 b为常数; ( μ +k a )为随机分量的预测函数, 其中, μ为随机分量中包 含的数据的均值, σ为随机分量中包含的数据的标准差, k为常数。
在具体实施过程中, 趋势分量的预测函数可以是上述公式中的线性函数, 也可以是拟合得到的非线性函数, 如二次函数、 指数函数、 对数函数、 多项 式、 Gompertz、 Logistic„ 根据上述对季节分量特点的分析, 每个周期的季节 分量数据是相同的, 因此, 可取一个周期的季节分量用于预测将来程序运行 资源使用量, 本发明实施例中, 季节分量的预测函数为 Sl 其中, i=t mod T , mod表示 t除以 T取余数, t为预测时间, T为程序运行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行资源使用量,在进行预测时, 确定预测时间 t对应的为程序运行资源使用周期的第几个程序运行资源使用 量, 根据确定的 S1 确定 t对应的季节分量数据; 对于随机分量, 虽然不能预 测未来某个时间随机分量的精确值, 但可根据已有的随机分量数据, 确定随 机分量的均值 μ和标准差 σ , 然后用某个置信上限, 如 μ +k a , k为常数, 作 为随机分量的一个估计值。
较佳地, 上述步骤 S504中, 基于确定的总体预测函数, 预测程序运行资 源的使用情况, 包括:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
在具体实施过程中, 根据确定的总体预测函数, 即可预测程序运行资源 的使用情况, 如令上述 Rt等于设定的程序运行资源使用量阔值, 可得到程序 运行资源使用量将来达到设定阔值的时间, 令上述 Rt等于总的可用程序运行 资源, 可得到程序运行资源耗尽时的时间, 令 t等于设定的未来某个时间, 即 可得到在未来的时间 t时的程序运行资源使用量。
下面将列举一个较典型的预测程序运行资源使用情况的实施方式。
如图 7 所示, 为本发明较佳的实施例提供的预测程序运行资源使用情况 的方法流程图, 包括:
S701 : 在每个程序运行资源使用周期内以设定频率釆集多次程序运行资 源使用量;
S702: 判断釆集的程序运行资源使用量总周期数或总次数是否不小于设 定的阔值, 若是, 则进入步骤 S703 , 否则, 返回步骤 S701 ;
在具体实施过程中, 还可以设置其它判断条件, 如当前程序运行资源占 用率是否不小于设定的阔值, 当前中央处理器 CPU占用率是否小于设定的阔 值, 当前时间是否在设定的时间范围内等。
S703: 将釆集的程序运行资源使用量分解成体现程序运行资源使用量的 变化趋势的趋势分量、 周期性变化的季节分量和随机性变化的随机分量;
S704: 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 根据确定的每种资源分量的预测函数确定程序运行资源总体预测函数;
在具体实施过程中, 趋势分量的预测函数可以为将该趋势分量中包含的 数据进行线性拟合或非线性拟合, 得到的以预测时间为自变量的线性函数或 非线性函数; 季节分量的预测函数为 Sl 其中, i=t mod T, t为预测时间, T 为程序运行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序 运行资源使用量; 随机分量的预测函数为根据所述随机分量中包含的数据的 均值和标准差, 确定的一个置信上限。
S705: 根据确定的总体预测函数, 预测在将来设定时间的程序运行资源 使用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用 量将来达到设定阔值的时间。 在具体实施过程中, 可以将本发明实施例判断程序运行资源泄漏和预测 程序运行资源使用情况的方法结合, 判断程序运行资源泄漏的过程和预测程 序运行资源使用情况的过程可以同时进行, 也可以先后进行。 下面以程序运 行资源中的内存资源为例, 列举一个判断内存泄漏和预测内存使用情况的方 法结合应用的实施方式。 的总体方法流程图, 包括:
S801 : 在每个内存资源使用周期内以设定频率釆集多次内存使用量;
S802: 判断釆集的内存使用量总周期数或总次数是否不小于设定的阔值, 若是, 则进入步骤 S803 , 否则, 返回步骤 S801 ;
在具体实施过程中, 还可以设置其它启动检测内存泄漏的条件, 如当前 内存占用率不小于设定的阔值,当前中央处理器 CPU占用率小于设定的阔值, 当前时间在设定的时间范围内等。
S803 : 判断是否启动检测内存泄漏, 若是, 则进入步骤 S804 , 否则进入 步骤 S805;
S804: 进行内存泄漏检测, 并在检测完输出检测结果后, 进入步骤 S805; 这里, 具体检测过程可参见前述判断程序运行资源泄漏的方法, 这里不 再赘述;
S805 : 判断是否启动预测内存使用情况, 若是, 则进入步骤 S806 , 否则, 返回步骤 S801 ;
S806: 预测内存使用情况, 并在预测完后输出预测结果。
这里, 具体预测过程可参见前述预测程序运行资源使用情况的方法, 这 里不再赘述。
如图 9 所示, 为本发明实施例提供的预测程序运行资源使用情况的装置 结构示意图, 包括:
釆集模块 91 , 用于在每个程序运行资源使用周期内釆集至少一次程序运 行资源使用量, 并将釆集到的程序运行资源使用量传输至分解模块 92; 程序 运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 分解模块 92 , 用于接收釆集模块 91釆集的程序运行资源使用量, 并将釆 集的程序运行资源使用量分解成不同种资源分量, 将每种资源分量中包含的 数据传输至确定模块 93 , 这里不同种资源分量为根据程序运行资源的使用规 律, 将程序运行资源分解成的具有不同变化规律的组成部分;
确定模块 93 ,用于接收分解模块 92分解得到的每种资源分量中包含的数 据, 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数, 并根 据确定的每种资源分量的预测函数确定程序运行资源总体预测函数, 将确定 的总体预测函数传输至预测模块 94;
预测模块 94 , 用于接收确定模块 93确定的总体预测函数, 并基于所述总 体预测函数, 预测程序运行资源的使用情况。
进一步地, 在该实施例中, 所述分解模块可以具体用于将釆集的程序运 行资源使用量分解成体现程序运行资源使用量的周期性变化的季节分量和体 现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程 序运行资源使用量的随机性变化的随机分量。
进一步地, 在该实施例中, 所述趋势分量的预测函数可以为将所述趋势 分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为自变量 的线性函数或非线性函数;
所述季节分量的预测函数可以为 St=S 其中, i=t mod T, t为预测时间, T为程序运行资源使用周期, Si为 t所属的所述季节分量的程序运行资源使用 周期的第 i个数据; 所述随机分量的预测函数可以为一个常数,所述常数为所述随机分量的一 个上分位点。
进一步地, 在该实施例中, 所述确定模块用于根据确定的每种资源分量 的预测函数确定程序运行资源总体预测函数时, 可以具体用于: 将确定的每 种资源分量的预测函数相加, 得到程序运行资源总体预测函数。
进一步地, 在该实施例中, 所述确定模块用于根据确定的每种资源分量 的预测函数确定程序运行资源总体预测函数时, 可以具体用于: 根据以下公 式确定程序运行资源总体预测函数:
Figure imgf000046_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, Τ为程序运行资源使用周期; ( μ +k a )为 所述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
较佳地, 确定模块 93还用于, 在釆集模块 91将釆集的程序运行资源使 用量分解成不同种资源分量之前, 确定釆集的程序运行资源使用量总周期数 或总次数不小于设定的阔值, 和 /或当前程序运行资源占用率不小于设定的阔 值, 和 /或当前中央处理器 CPU 占用率小于设定的阔值, 和 /或当前时间在设 定的时间范围内。
较佳地, 分解模块 92分解后的资源分量包括周期性变化的季节分量和随 机性变化的随机分量; 或
分解模块 92分解后的资源分量包括体现程序运行资源使用量的变化趋势 的趋势分量和随机性变化的随机分量; 或
分解模块 92分解后的资源分量包括体现程序运行资源使用量的变化趋势 的趋势分量、 周期性变化的季节分量和随机性变化的随机分量;
其中, 趋势分量的预测函数为将趋势分量中包含的数据进行线性拟合或 非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数; 季节分量的预测函数为 S1 其中, i=t mod T, t为预测时间, T为程序运 行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行资源 使用量;
随机分量的预测函数为根据随机分量中包含的数据的均值和标准差, 确 定的一个置信上限。
较佳地, 确定模块 93具体用于在分解模块 92分解的资源分量包括趋势 分量、 季节分量和随机分量时, 根据以下公式确定程序运行资源总体预测函 数:
Figure imgf000047_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; ( μ +k a ) 为所述随机分量的预测函数, 其中, μ为所 述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数。
较佳地, 预测模块 94具体用于:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
进一步地, 在该实施例中, 在每个程序运行资源使用周期内釆集程序运 行资源使用量的次数相同。
如图 10所示, 为本发明实施例提供的预测程序运行资源使用情况的装置 结构图, 包括:
处理器 101 ,用于在每个程序运行资源使用周期内釆集至少一次程序运行 资源使用量, 并将釆集的程序运行资源使用量分解成不同种资源分量, 这里 不同种资源分量为根据程序运行资源的使用规律, 将程序运行资源分解成的 具有不同变化规律的组成部分; 所述程序运行资源使用周期为根据程序运行 资源使用量的周期性规律设定的周期; 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数, 并根据确定的每种资源分量的预测函数确定程 序运行资源总体预测函数, 基于确定的总体预测函数, 预测程序运行资源的 使用情况;
存储器 102 ,用于存储每次釆集的程序运行资源使用量及确定的每种资源 分量的预测函数和程序运行资源总体预测函数。
进一步地, 在该实施例中, 所述将釆集的程序运行资源使用量分解成不 同种资源分量, 包括: 将釆集的程序运行资源使用量分解成体现程序运行资 源使用量的周期性变化的季节分量和体现程序运行资源使用量的随机性变化 的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋 势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程 序运行资源使用量的随机性变化的随机分量。
进一步地, 在该实施例中, 所述趋势分量的预测函数为将所述趋势分量 中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为自变量的线 性函数或非线性函数;
所述季节分量的预测函数为 St=S 其中, i=t mod T, t为预测时间, T 为程序运行资源使用周期, Si为 t所属的所述季节分量的程序运行资源使用周 期的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上 分位点。
进一步地, 在该实施例中, 所述根据确定的每种资源分量的预测函数确 定程序运行资源总体预测函数, 包括: 将确定的每种资源分量的预测函数相 加, 得到程序运行资源总体预测函数。
进一步地, 在该实施例中, 根据以下公式确定程序运行资源总体预测函 数:
Figure imgf000049_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; i=t mod T, Τ为程序运行资源使用周期; ( μ +k a )为 所述随机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
较佳地, 处理器 101 还用于, 在将釆集的程序运行资源使用量分解成不 同种资源分量之前, 确定釆集的程序运行资源使用量总周期数或总次数不小 于设定的阔值, 和 /或当前程序运行资源占用率不小于设定的阔值, 和 /或当前 中央处理器 CPU 占用率小于设定的阔值, 和 /或当前时间在设定的时间范围 内。
较佳地, 资源分量包括周期性变化的季节分量和随机性变化的随机分量; 或
资源分量包括体现程序运行资源使用量的变化趋势的趋势分量和随机性 变化的随机分量; 或
资源分量包括体现程序运行资源使用量的变化趋势的趋势分量、 周期性 变化的季节分量和随机性变化的随机分量;
其中, 趋势分量的预测函数为将趋势分量中包含的数据进行线性拟合或 非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数;
季节分量的预测函数为 S1 其中, i=t mod T, t为预测时间, T为程序运 行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行资源 使用量;
随机分量的预测函数为根据随机分量中包含的数据的均值和标准差, 确 定的一个置信上限。
较佳地, 处理器 101 具体用于在资源分量包括趋势分量、 季节分量和随 机分量时, 根据以下公式确定程序运行资源总体预测函数:
Figure imgf000050_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测 函数, a和 b为常数; ( μ +k a ) 为所述随机分量的预测函数, 其中, μ为所 述随机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常数。
较佳地, 处理器 101具体用于:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使 用量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量 将来达到设定阔值的时间。
如图 11所示, 为本发明实施例检测资源泄漏、 预测资源使用情况的装置 部署示意图;
在具体实施过程中, 如需检测目标系统的某个监控对象是否存在程序运 行资源泄漏和 /或预测该监控对象的程序运行资源使用情况, 则可针对该监控 对象部署一个本发明实施例装置, 如需检测目标系统的多个监控对象是否存 在程序运行资源泄漏和 /或预测多个监控对象的程序运行资源使用情况, 则可 针对每个监控对象部署一个本发明实施例的装置。
在具体实施过程中, 本装置既可以在线部署, 即数据釆集和数据分析均 在目标系统进行, 也可以将在线部署和离线部署结合, 即仅在目标系统釆集 程序运行资源使用量, 而数据分析, 即具体的判断程序运行资源泄漏和 /或预 测程序运行资源使用情况的过程在线下进行。
下面, 以内存资源为例, 详细说明本发明实施例检测资源泄漏、 预测资 源使用情况的装置与目标系统之间的交互过程:
目标系统通过本装置的配置文件设置相关参数, 如一个周期内釆集的内 存使用量次数, 泄漏检测的显著性水平, 即上述实施方式中的 α , 随机分量 的预测函数的 k值, 启动判断是否存在内存泄漏的内存使用率或使用量阔值 等等; 目标系统向本装置注册获取内存使用量的钩子函数, 以便本装置在运行 过程中调用该函数釆集目标监控对象的内存使用量;
目标系统向本装置注册进行检测预测结果处理的钩子函数, 以便本装置 调用该函数将检测和预测结果通知给目标系统, 目标系统根据该结果做相应 处理, 如通知告警、 主备倒换、 进程重启、 操作系统重启、 机器重启等; 目标系统通过定时任务周期性地调用本装置提供的对外接口函数, 本装 置的对外接口函数调用目标系统注册给本装置的获取内存使用量的钩子函数 釆集监控对象的内存使用量, 将釆集到的数据存入内存中, 并利用釆集到的 数据执行内存泄漏检测和预测内存使用情况的过程。
本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或 计算机程序产品。 因此, 本发明可釆用完全硬件实施例、 完全软件实施例、 或结合软件和硬件方面的实施例的形式。 而且, 本发明可釆用在一个或多个 其中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘 存储器、 CD-ROM、 光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、 装置(系统)、 和计算机程序产 品的流程图和 /或方框图来描述的。 应理解可由计算机程序指令实现流程图 和 /或方框图中的每一流程和 /或方框、 以及流程图和 /或方框图中的流程 和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器, 使得通 过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流 程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的 装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设 备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存储器 中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个流程或 多个流程和 /或方框图一个方框或多个方框中指定的功能。 这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的 处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图 一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的步 骤。
尽管已描述了本发明的优选实施例, 但本领域内的技术人员一旦得知了 基本创造性概念, 则可对这些实施例作出另外的变更和修改。 所以, 所附权 利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。 发明的精神和范围。 这样, 倘若本发明的这些修改和变型属于本发明权利要 求及其等同技术的范围之内, 则本发明也意图包含这些改动和变型在内。

Claims

权 利 要 求 书
1、 一种预测程序运行资源使用情况的方法, 其特征在于, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 将釆集的程序运行资源使用量分解成: 体现程序运行资源使用量的变化趋 势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程序 运行资源使用量的随机性变化的随机分量; 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 将确定的每种资源分量的预测函数相加, 得到程序运行资源总体预测函数; 基于确定的总体预测函数, 预测程序运行资源的使用情况。
2、 如权利要求 1所述的方法, 其特征在于, 所述趋势分量的预测函数为将 所述趋势分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为 自变量的线性函数或非线性函数; 所述季节分量的预测函数为 st=Si, 其中, i=t mod T, t为预测时间, T为程 序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期的第 i个数据; 所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上分 位点。
3、 如权利要求 1或 2所述的方法, 其特征在于, 根据以下公式确定程序运 行资源总体预测函数:
Figure imgf000053_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测函 数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所述随 机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述 随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
4、 如权利要求 1-3中任一项所述的方法, 其特征在于, 基于确定的总体预 测函数, 预测程序运行资源的使用情况, 包括: 根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使用 量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量将来 达到设定阔值的时间。
5、 如权利要求 1-4中任一项所述的方法, 其特征在于, 在每个程序运行资 源使用周期内釆集程序运行资源使用量的次数相同。
6、 如权利要求 1-5中任一项所述的方法, 其特征在于, 所述程序运行资源 使用周期为根据程序运行资源使用量的周期性规律设定的周期。
7、 一种预测程序运行资源使用情况的装置, 其特征在于, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量; 分解模块,用于将釆集的程序运行资源使用量分解成: 体现程序运行资源使 用量的变化趋势的趋势分量、 体现程序运行资源使用量的周期性变化的季节分 量和体现程序运行资源使用量的随机性变化的随机分量; 确定模块, 用于针对每一种资源分量中包含的数据, 确定该资源分量的预 测函数, 并将确定的每种资源分量的预测函数相加, 得到程序运行资源总体预 测函数; 预测模块, 用于基于所述总体预测函数, 预测程序运行资源的使用情况。
8、 如权利要求 7所述的装置, 其特征在于, 所述趋势分量的预测函数为将 所述趋势分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间为 自变量的线性函数或非线性函数; 所述季节分量的预测函数为 st=Si , 其中, i=t mod T , t为预测时间, T为程 序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期的第 i个数据; 所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上分 位点。
9、 如权利要求 7或 8所述的装置, 其特征在于, 所述确定模块具体用于根 据以下公式确定程序运行资源总体预测函数:
Figure imgf000055_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测函 数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所述随 机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述 随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
10、 如权利要求 7-9中任一项所述的装置, 其特征在于, 所述预测模块具体 用于: 根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使用 量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量将来 达到设定阔值的时间。
11、 如权利要求 7-10中任一项所述的装置, 其特征在于, 在每个程序运行 资源使用周期内釆集程序运行资源使用量的次数相同。
12、 如权利要求 7-11 中任一项所述的装置, 其特征在于, 所述程序运行资 源使用周期为根据程序运行资源使用量的周期性规律设定的周期。
13、 一种判断程序运行资源泄漏的方法, 其特征在于, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程 序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 针对每两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运行 资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其中在 后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期内对应 次釆集的时间与在前周期的起始时间的时间差在一个预设范围内, 其中, 所述 预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔中的最小时间间 隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内每相邻两次釆 集的时间间隔中的最小时间间隔的时间长度范围; 在确定的各差值中, 若所述大于 0的差值总数与小于 0的差值总数之差大 于设定的阔值, 则确定存在程序运行资源泄漏, 其中, 所述阔值的范围为大于 或等于 0,并且小于或等于确定的各差值中大于 0的差值总数与小于 0的差值总 数之和的 70%。
14、 一种判断程序运行资源泄漏的方法, 其特征在于, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程 序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 针对每两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运行 资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其中在 后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期内对应 次釆集的时间与在前周期的起始时间的时间差在一个预设范围内, 其中, 所述 预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔中的最小时间间 隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期内每相邻两次釆 集的时间间隔中的最小时间间隔的时间长度范围; 确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z; 若 Z大于设定的阔值, 则确定存在程序运行资源泄漏; 其中, 根据以下公式确定所述大于 0的差值总数与小于 0的差值总数之差 s'的统计量 Z:
若"≥10 , 则
Figure imgf000057_0001
; 其中, n为程序运行资源源使用周期的个数;
Figure imgf000057_0002
Z = 0 , sf = o
( +i)
1/2 S' < 0
VAR(S')
否则, VAR (S,) =∑VAR (Si )
Figure imgf000057_0003
二 1 Rlk为在第 k 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1个程 序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序运行资 源使用周期内釆集程序运行资源使用量的次数; 所述阔值为根据所述统计量 Z的概率分布确定的分位值 (
15、 一种判断程序运行资源泄漏的装置, 其特征在于, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量, 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的 次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规 律设定的周期; 确定模块, 用于针对每两个程序运行资源使用周期, 确定在后周期内每次 釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量 的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和 在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围 内, 其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔 中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期 内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围; 判断模块, 用于在确定的各差值中大于 0的差值总数与小于 0的差值总数 之差大于设定的阔值时, 确定存在程序运行资源泄漏, 其中, 所述阔值的范围 为大于或等于 0,并且小于或等于确定的各差值中大于 0的差值总数与小于 0的 差值总数之和的 70%。
16、 一种判断程序运行资源泄漏的装置, 其特征在于, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量, 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的 次数相同; 所述程序运行资源使用周期为根据程序运行资源使用量的周期性规 律设定的周期; 确定模块, 用于针对每两个程序运行资源使用周期, 确定在后周期内每次 釆集的程序运行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量 的差值, 其中在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和 在前周期内对应次釆集的时间与在前周期的起始时间的时间差在一个预设范围 内, 其中, 所述预设范围为: 小于所述在前周期内每相邻两次釆集的时间间隔 中的最小时间间隔的时间长度范围, 或者, 所述预设范围为: 小于所述在后周期 内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围; 判断模块, 用于确定所述大于 0的差值总数与小于 0的差值总数之差的统 计量 Z; 若 Z大于设定的阔值, 则确定存在程序运行资源泄漏; 其中, 所述判断模块具体用于根据以下公式确定所述大于 0 的差值总数与 小于 0的差值总数之差 s'的统计量 Z:
若"≥10 , 则
Figure imgf000059_0001
; 其中, n为程序运行资源源使用周期的个数;
S' > 0
Figure imgf000059_0002
Z = 0 , sf = o
( +i)
1/2 S' < 0
VAR(S')
否则, S, , VAR (S') =∑ VAR (S, )
Figure imgf000059_0003
二 1 ; Rlk为在第 k 个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1个程 序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序运行资 源使用周期内釆集程序运行资源使用量的次数; 所述阔值为根据所述统计量 Z的概率分布确定的分位值。
17、 一种判断程序运行资源泄漏的方法, 其特征在于, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 其中, 在每个程序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程 序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 针对任意两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运 行资源使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 其中 在后周期内每次釆集的时间与在后周期的起始时间的时间差, 和在前周期内对 应次釆集的时间与在前周期的起始时间的时间差在一个预设范围内;
根据在确定的各差值中大于 0的差值总数与小于 0的差值总数之差, 判断 是否存在程序运行资源泄漏。
18、 如权利要求 17所述的方法, 其特征在于, 所述预设范围为: 小于所述 在前周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围, 或 者, 所述预设范围为:小于所述在后周期内每相邻两次釆集的时间间隔中的最小 时间间隔的时间长度范围。
19、 如权利要求 17所述的方法, 其特征在于, 根据所述大于 0的差值总数 与小于 0的差值总数之差, 判断是否存在程序运行资源泄漏, 包括:
若所述大于 0的差值总数与小于 0的差值总数之差大于设定的阔值, 则确 定存在程序运行资源泄漏。
20、 如权利要求 19所述的方法, 其特征在于, 所述阔值的范围为大于或等 于 0,并且小于或等于确定的各差值中大于 0的差值总数与小于 0的差值总数之 和的 70%。
21、 如权利要求 17所述的方法, 其特征在于, 根据所述大于 0的差值总数 与小于 0的差值总数之差, 判断是否存在程序运行资源泄漏, 包括:
确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏。
22、 如权利要求 21所述的方法, 其特征在于, 根据以下公式确定所述大于 0的差值总数与小于 0的差值总数之差 S'的统计量 Z: 若??≥10, 则 Ϊ7Τ; 其中, η为程序运行资源使用周期的个数;
VAR(S/)
'-ι) 1/2 S'>0 z = 0 s'=o
否则,
( +i)
, S'<0
VAR(Sf) 其中, = ΐί ί η( — 7U S' = , VAR(S/)=∑VAR(Si); Rlk为在第 k
l 1 l 二 1 二 1
个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1个程 序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序运行资 源使用周期内釆集程序运行资源使用量的次数。
23、 如权利要求 21所述的方法, 其特征在于, 所述阔值为根据所述统计量 Z的概率分布确定的分位值。
24、 一种判断程序运行资源泄漏的装置, 其特征在于, 包括:
釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量, 并将釆集的程序运行资源使用量传输至确定模块, 其中, 在每个程 序运行资源使用周期内釆集程序运行资源使用量的次数相同; 所述程序运行资 源使用周期为根据程序运行资源使用量的周期性规律设定的周期;
确定模块, 用于接收所述釆集模块每次釆集的程序运行资源使用量, 并针 对任意两个程序运行资源使用周期, 确定在后周期内每次釆集的程序运行资源 使用量, 与在前周期内对应次釆集的程序运行资源使用量的差值, 并将确定的 各差值传输至判断模块, 其中在后周期内每次釆集的时间与在后周期的起始时 间的时间差, 和在前周期内对应次釆集的时间与在前周期的起始时间的时间差 在一个预设范围内;
判断模块, 用于接收所述确定模块确定的各差值, 并根据在确定的各差值 中大于 0的差值总数与小于 0的差值总数之差, 判断是否存在程序运行资源泄 漏。
25、 如权利要求 24所述的装置, 其特征在于, 所述预设范围为: 小于所述 在前周期内每相邻两次釆集的时间间隔中的最小时间间隔的时间长度范围, 或 者, 所述预设范围为:小于所述在后周期内每相邻两次釆集的时间间隔中的最小 时间间隔的时间长度范围。
26、 如权利要求 24所述的装置, 其特征在于, 所述判断模块具体用于: 若所述大于 0的差值总数与小于 0的差值总数之差大于设定的阔值, 则确 定存在程序运行资源泄漏。
27、 如权利要求 26所述的装置, 其特征在于, 所述阔值的范围为大于或等 于 0,并且小于或等于确定的各差值中大于 0的差值总数与小于 0的差值总数之 和的 70%
28、 如权利要求 24所述的装置, 其特征在于, 所述判断模块具体用于: 确定所述大于 0的差值总数与小于 0的差值总数之差的统计量 Z;
若 Z大于设定的阔值, 则确定存在程序运行资源泄漏。
29、 如权利要求 28所述的装置, 其特征在于, 所述判断模块具体用于根据 以下公式确定所述大于 0的差值总数与小于 0的差值总数之差 S'的统计量 Z:
Figure imgf000062_0001
若《≥10, 则 z = \ 其中, n为程序运行资源使用周期的个数;
VAR(S') '― 1)
1/2 S' > 0
VAR{Sf)
Z 二 0 s' = o
否则,
( + i)
, S' < 0
VAR(Sf) 其中, = ; Rlk为在第 k
Figure imgf000062_0002
个程序运行资源使用周期内釆集的第 i次程序运行资源使用量; ι为在第 1个程 序运行资源使用周期内釆集的第 i次程序运行资源使用量; m为一个程序运行资 源使用周期内釆集程序运行资源使用量的次数。
30、 如权利要求 28所述的装置, 其特征在于, 所述阔值为根据所述统计量 Z的概率分布确定的分位值。
31、 一种预测程序运行资源使用情况的方法, 其特征在于, 包括: 在每个程序运行资源使用周期内釆集至少一次程序运行资源使用量; 所述 程序运行资源使用周期为根据程序运行资源使用量的周期性规律设定的周期; 将釆集的程序运行资源使用量分解成不同种资源分量, 所述不同种资源分 量为根据程序运行资源的使用规律, 将程序运行资源使用量分解成的具有不同 变化规律的组成部分;
针对每一种资源分量中包含的数据, 确定该资源分量的预测函数; 根据确定的每种资源分量的预测函数确定程序运行资源总体预测函数; 基于确定的总体预测函数, 预测程序运行资源的使用情况。
32、 如权利要求 31所述的方法, 其特征在于, 所述将釆集的程序运行资源 使用量分解成不同种资源分量, 包括: 将釆集的程序运行资源使用量分解成体 现程序运行资源使用量的周期性变化的季节分量和体现程序运行资源使用量的 随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋势 的趋势分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋势 的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程序运 行资源使用量的随机性变化的随机分量。
33、 如权利要求 32所述的方法, 其特征在于, 所述趋势分量的预测函数为 将所述趋势分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间 为自变量的线性函数或非线性函数;
所述季节分量的预测函数为 st=Si , 其中, i=t mod T , t为预测时间, T为程 序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上分 位点。
34、 如权利要求 31所述的方法, 其特征在于, 所述根据确定的每种资源分 量的预测函数确定程序运行资源总体预测函数, 包括: 将确定的每种资源分量 的预测函数相加, 得到程序运行资源总体预测函数。
35、 如权利要求 33或 34所述的方法, 其特征在于, 根据以下公式确定程 序运行资源总体预测函数:
Figure imgf000064_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测函 数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所述随 机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述 随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
36、 如权利要求 31所述的方法, 其特征在于,
所述资源分量包括周期性变化的季节分量和随机性变化的随机分量; 或 所述资源分量包括体现程序运行资源使用量的变化趋势的趋势分量和随机 性变化的随机分量; 或
所述资源分量包括体现程序运行资源使用量的变化趋势的趋势分量、 周期 性变化的季节分量和随机性变化的随机分量;
其中, 所述趋势分量的预测函数为将所述趋势分量中包含的数据进行线性 拟合或非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数; 所述季节分量的预测函数为 , 其中, i=t mod T , t为预测时间, T为程序 运行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行资源 使用量;
所述随机分量的预测函数为根据所述随机分量中包含的数据的均值和标准 差, 确定的一个置信上限。
37、 如权利要求 36所述的方法, 其特征在于, 在所述资源分量包括趋势分 量、 季节分量和随机分量时, 根据以下公式确定程序运行资源总体预测函数:
Figure imgf000065_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测函 数, a和 b为常数; ( μ +k a )为所述随机分量的预测函数, 其中, μ为所述随 机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常 数。
38、 如权利要求 31所述的方法, 其特征在于, 基于确定的总体预测函数, 预测程序运行资源的使用情况, 包括:
根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使用 量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量将来 达到设定阔值的时间。
39、 如权利要求 31 -38中任一项所述的方法, 其特征在于, 在每个程序运行 资源使用周期内釆集程序运行资源使用量的次数相同。
40、 一种预测程序运行资源使用情况的装置, 其特征在于, 包括: 釆集模块, 用于在每个程序运行资源使用周期内釆集至少一次程序运行资 源使用量, 并将釆集到的程序运行资源使用量传输至分解模块; 所述程序运行 资源使用周期为根据程序运行资源使用量的周期性规律设定的周期;
分解模块, 用于接收所述釆集模块釆集的程序运行资源使用量, 并将釆集 的程序运行资源使用量分解成不同种资源分量, 将每种资源分量中包含的数据 传输至确定模块, 所述不同种资源分量为根据程序运行资源的使用规律, 将程 序运行资源分解成的具有不同变化规律的组成部分;
确定模块, 用于接收所述分解模块分解得到的每种资源分量中包含的数据, 针对每一种资源分量中包含的数据, 确定该资源分量的预测函数, 并根据确定 的每种资源分量的预测函数确定程序运行资源总体预测函数, 将确定的总体预 测函数传输至预测模块;
预测模块, 用于接收所述确定模块确定的总体预测函数, 并基于所述总体 预测函数, 预测程序运行资源的使用情况。
41、 如权利要求 40所述的装置, 其特征在于, 所述分解模块具体用于将釆 集的程序运行资源使用量分解成体现程序运行资源使用量的周期性变化的季节 分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋势 的趋势分量和体现程序运行资源使用量的随机性变化的随机分量; 或
将釆集的程序运行资源使用量分解成体现程序运行资源使用量的变化趋势 的趋势分量、 体现程序运行资源使用量的周期性变化的季节分量和体现程序运 行资源使用量的随机性变化的随机分量。
42、 如权利要求 41所述的装置, 其特征在于, 所述趋势分量的预测函数为 将所述趋势分量中包含的数据进行线性拟合或非线性拟合, 得到的以预测时间 为自变量的线性函数或非线性函数;
所述季节分量的预测函数为 st=Si , 其中, i=t mod T , t为预测时间, T为程 序运行资源使用周期, 为 t所属的所述季节分量的程序运行资源使用周期的第 i个数据;
所述随机分量的预测函数为一个常数,所述常数为所述随机分量的一个上分 位点。
43、 如权利要求 40所述的装置, 其特征在于, 确定模块用于根据确定的每 种资源分量的预测函数确定程序运行资源总体预测函数时, 具体用于: 将确定 的每种资源分量的预测函数相加, 得到程序运行资源总体预测函数。
44、 如权利要求 42或 43所述的装置, 其特征在于, 确定模块用于根据确 定的每种资源分量的预测函数确定程序运行资源总体预测函数时, 具体用于: 根据以下公式确定程序运行资源总体预测函数:
Figure imgf000066_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测函 数, a和 b为常数; i=t mod T, T为程序运行资源使用周期; ( μ +k a )为所述随 机分量的预测函数, 其中, μ为所述随机分量中包含的数据的均值, σ为所述 随机分量中包含的数据的标准差, k为常数, k的范围为 (0, 6]。
45、 如权利要求 40所述的装置, 其特征在于,
所述分解模块分解后的资源分量包括周期性变化的季节分量和随机性变化 的随机分量; 或
所述分解模块分解后的资源分量包括体现程序运行资源使用量的变化趋势 的趋势分量和随机性变化的随机分量; 或
所述分解模块分解后的资源分量包括体现程序运行资源使用量的变化趋势 的趋势分量、 周期性变化的季节分量和随机性变化的随机分量;
其中, 所述趋势分量的预测函数为将所述趋势分量中包含的数据进行线性 拟合或非线性拟合, 得到的以预测时间为自变量的线性函数或非线性函数; 所述季节分量的预测函数为 , 其中, i=t mod T , t为预测时间, T为程序 运行资源使用周期, 为 t对应的程序运行资源使用周期的第 i个程序运行资源 使用量;
所述随机分量的预测函数为根据所述随机分量中包含的数据的均值和标准 差, 确定的一个置信上限。
46、 如权利要求 45所述的装置, 其特征在于, 所述确定模块具体用于在所 述分解模块分解的资源分量包括趋势分量、 季节分量和随机分量时, 根据以下 公式确定程序运行资源总体预测函数:
Figure imgf000067_0001
式中, Rt为程序运行资源总体预测函数: (a+bt )为所述趋势分量的预测函 数, a和 b为常数; ( μ +k a )为所述随机分量的预测函数, 其中, μ为所述随 机分量中包含的数据的均值, σ为所述随机分量中包含的数据的标准差, k为常 数。
47、 如权利要求 40所述的装置, 其特征在于, 所述预测模块具体用于: 根据确定的所述总体预测函数, 预测在将来设定时间的程序运行资源使用 量, 和 /或预测程序运行资源耗尽时的时间, 和 /或预测程序运行资源使用量将来 达到设定阔值的时间。
48、 如权利要求 40-47中任一项所述的装置, 其特征在于, 在每个程序运行 资源使用周期内釆集程序运行资源使用量的次数相同。
PCT/CN2014/080271 2013-05-21 2014-06-19 判断资源泄漏、预测资源使用情况的方法及装置 WO2014187431A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP14801434.3A EP2911060B1 (en) 2013-05-21 2014-06-19 Method and device for determining resource leakage and for predicting resource usage state
US14/922,595 US9846601B2 (en) 2013-05-21 2015-10-26 Method and apparatuses for determining a leak of resource and predicting usage of resource

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310190659.3A CN104182332B (zh) 2013-05-21 2013-05-21 判断资源泄漏、预测资源使用情况的方法及装置
CN201310190659.3 2013-05-21

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/922,595 Continuation US9846601B2 (en) 2013-05-21 2015-10-26 Method and apparatuses for determining a leak of resource and predicting usage of resource

Publications (1)

Publication Number Publication Date
WO2014187431A1 true WO2014187431A1 (zh) 2014-11-27

Family

ID=51932975

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080271 WO2014187431A1 (zh) 2013-05-21 2014-06-19 判断资源泄漏、预测资源使用情况的方法及装置

Country Status (4)

Country Link
US (1) US9846601B2 (zh)
EP (1) EP2911060B1 (zh)
CN (1) CN104182332B (zh)
WO (1) WO2014187431A1 (zh)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9495395B2 (en) 2013-04-11 2016-11-15 Oracle International Corporation Predictive diagnosis of SLA violations in cloud services by seasonal trending and forecasting with thread intensity analytics
US9785719B2 (en) * 2014-07-15 2017-10-10 Adobe Systems Incorporated Generating synthetic data
CN106708605B (zh) * 2015-07-14 2021-08-24 腾讯科技(深圳)有限公司 一种检测资源泄漏的方法及装置
US10901852B2 (en) 2015-11-02 2021-01-26 Apple Inc. Restoring virtual network function (VNF) performance via VNF reset of lifecycle management
US10289347B2 (en) * 2016-04-26 2019-05-14 Servicenow, Inc. Detection and remediation of memory leaks
US11327797B2 (en) 2016-05-09 2022-05-10 Oracle International Corporation Memory usage determination techniques
WO2018018575A1 (en) * 2016-07-29 2018-02-01 Microsoft Technology Licensing, Llc Detection of computing resource leakage in cloud computing architectures
CN107179950B (zh) * 2017-06-29 2020-10-27 努比亚技术有限公司 一种应用进程处理方法、移动终端以及计算机可读存储介质
CN107957950B (zh) * 2017-12-08 2020-08-25 锐捷网络股份有限公司 一种系统资源泄露的检测方法和装置
US11036608B2 (en) * 2019-09-27 2021-06-15 Appnomic Systems Private Limited Identifying differences in resource usage across different versions of a software application
CN111078537B (zh) * 2019-11-29 2023-09-22 珠海金山数字网络科技有限公司 Unity游戏bundle包资源划分的评估方法
US11269748B2 (en) * 2020-04-22 2022-03-08 Microsoft Technology Licensing, Llc Diagnosing and mitigating memory leak in computing nodes
WO2022018466A1 (en) * 2020-07-22 2022-01-27 Citrix Systems, Inc. Determining server utilization using upper bound values
CN112416793A (zh) * 2020-12-01 2021-02-26 新华三人工智能科技有限公司 一种内存泄漏检测方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1766847A (zh) * 2004-10-27 2006-05-03 中兴通讯股份有限公司 一种计算机系统处理资源监视与预警方法
CN1774095A (zh) * 2004-11-08 2006-05-17 华为技术有限公司 基站系统中防止内部资源泄露的方法
US20070067758A1 (en) * 2005-09-21 2007-03-22 Piotr Findeisen Identifying sources of memory retention
WO2012122672A1 (en) * 2011-03-15 2012-09-20 Telefonaktiebolaget L M Ericsson (Publ) Detection on resource leakage

Family Cites Families (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6691067B1 (en) * 1999-04-07 2004-02-10 Bmc Software, Inc. Enterprise management system and method which includes statistical recreation of system resource usage for more accurate monitoring, prediction, and performance workload characterization
US6993458B1 (en) * 2000-11-07 2006-01-31 International Business Machines Corporation Method and apparatus for preprocessing technique for forecasting in capacity management, software rejuvenation and dynamic resource allocation applications
US6810495B2 (en) 2001-03-30 2004-10-26 International Business Machines Corporation Method and system for software rejuvenation via flexible resource exhaustion prediction
EP1468361A1 (en) * 2001-12-19 2004-10-20 Netuitive Inc. Method and system for analyzing and predicting the behavior of systems
US7577943B2 (en) * 2003-10-24 2009-08-18 Microsoft Corporation Statistical memory leak detection
US7487321B2 (en) * 2004-04-19 2009-02-03 Cisco Technology, Inc. Method and system for memory leak detection
US7293142B1 (en) * 2004-04-19 2007-11-06 Cisco Technology, Inc. Memory leak detection system and method using contingency analysis
US7908606B2 (en) * 2005-05-20 2011-03-15 Unisys Corporation Usage metering system
US20070136402A1 (en) * 2005-11-30 2007-06-14 International Business Machines Corporation Automatic prediction of future out of memory exceptions in a garbage collected virtual machine
US8312062B1 (en) * 2006-03-29 2012-11-13 Emc Corporation Automatic resource leak detection
US8793289B2 (en) * 2006-04-28 2014-07-29 Sap Ag Method and system for detecting memory leaks and copying garbage collection files
US7774741B2 (en) * 2006-05-22 2010-08-10 Microsoft Corporation Automatically resource leak diagnosis and detecting process within the operating system
US7730364B2 (en) * 2007-04-05 2010-06-01 International Business Machines Corporation Systems and methods for predictive failure management
US7793161B2 (en) * 2007-05-29 2010-09-07 International Business Machines Corporation Method and apparatus to anticipate memory exhaustion in an open services gateway initiative environment
CN101539870A (zh) 2008-03-21 2009-09-23 中兴通讯股份有限公司 内存泄漏检测装置及方法
CN101615143B (zh) 2008-06-27 2013-04-17 国际商业机器公司 用于内存泄漏诊断的方法和装置
JP2010072854A (ja) * 2008-09-17 2010-04-02 Canon Inc 情報処理装置の支援装置、支援方法、およびコンピュータプログラム
CN101599048B (zh) * 2009-07-01 2012-02-22 福建星网锐捷网络有限公司 一种内存监控的方法和装置
CN102200943B (zh) * 2010-03-25 2014-12-03 腾讯科技(深圳)有限公司 一种基于后台自动检测cpu使用率的方法和设备
US9064048B2 (en) * 2011-02-17 2015-06-23 Red Hat, Inc. Memory leak detection
US20120266026A1 (en) * 2011-04-18 2012-10-18 Ramya Malanai Chikkalingaiah Detecting and diagnosing misbehaving applications in virtualized computing systems
US9104563B2 (en) * 2012-02-09 2015-08-11 Microsoft Technology Licensing, Llc Self-tuning statistical resource leak detection

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1766847A (zh) * 2004-10-27 2006-05-03 中兴通讯股份有限公司 一种计算机系统处理资源监视与预警方法
CN1774095A (zh) * 2004-11-08 2006-05-17 华为技术有限公司 基站系统中防止内部资源泄露的方法
US20070067758A1 (en) * 2005-09-21 2007-03-22 Piotr Findeisen Identifying sources of memory retention
WO2012122672A1 (en) * 2011-03-15 2012-09-20 Telefonaktiebolaget L M Ericsson (Publ) Detection on resource leakage

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2911060A4 *

Also Published As

Publication number Publication date
US9846601B2 (en) 2017-12-19
CN104182332A (zh) 2014-12-03
US20160041848A1 (en) 2016-02-11
CN104182332B (zh) 2017-09-29
EP2911060B1 (en) 2018-08-08
EP2911060A1 (en) 2015-08-26
EP2911060A4 (en) 2016-06-08

Similar Documents

Publication Publication Date Title
WO2014187431A1 (zh) 判断资源泄漏、预测资源使用情况的方法及装置
CN107247651B (zh) 云计算平台监测预警方法和系统
WO2017045553A1 (zh) 一种任务分配方法和系统
US8799916B2 (en) Determining an allocation of resources for a job
Chen et al. Failure prediction of jobs in compute clouds: A google cluster case study
US9471383B2 (en) Task allocation in a computing environment
CN103970587B (zh) 一种资源调度的方法、设备和系统
CN108038040A (zh) 计算机集群性能指标检测方法、电子设备及存储介质
US20130318538A1 (en) Estimating a performance characteristic of a job using a performance model
CN105979532B (zh) 一种业务处理系统的性能容量分析预警方法及装置
US11972301B2 (en) Allocating computing resources for deferrable virtual machines
CN106528318B (zh) 线程死循环检测方法和装置
US8832839B2 (en) Assessing system performance impact of security attacks
CN106933673B (zh) 调整组件逻辑线程数量的方法及装置
EP4189542A1 (en) Sharing of compute resources between the virtualized radio access network (vran) and other workloads
CN110618861A (zh) 一种Hadoop集群节能系统
CN108255710B (zh) 一种脚本的异常检测方法及其终端
CN115145709A (zh) 低碳大数据人工智能方法和医康养生态系统
CN112073517B (zh) 一种分布式数据传输优化方法、系统及相关设备
Zhao et al. Software maintenance optimization based on Stackelberg game methods
CN111782480B (zh) 磁盘使用率监测方法、装置、系统和介质
CN113807850B (zh) 一种共识节点的状况评估方法、装置及电子设备
Mudalige et al. Predictive analysis and optimisation of pipelined wavefront computations
US9092263B2 (en) Method for generating an optimised hardware/software partitioning of embedded systems using a plurality of control appliances
Kamyabpour et al. A study on Modeling of Dependency between Configuration Parameters and Overall Energy Consumption in Wireless Sensor Network (WSN)

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 2014801434

Country of ref document: EP

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14801434

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE