Computer-implemented method, computer system, and computer-readable storage medium
By taking memory usage snapshots and least squares linear fitting methods in computer systems, the memory leak problem in computer systems is solved and system stability and performance is improved.
Patent Information
- Application Number
- CN202210375196.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-10-28
- Filing Date
- 2022-04-11
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2042-04-11
AI Technical Summary
There is a memory leak problem in computer systems, resulting in a degradation of system performance. It is difficult for the existing technology to effectively predict and resolve memory leaks, especially in a multi-process environment, which may cause the system to crash or need to be restarted.
By taking a snapshot of memory usage based on a predetermined time interval in a computer system, the increase in private memory and shared memory of the calculation process is calculated using the least squares linear fitting method to calculate the possibility of memory leakage and compare it with the predetermined threshold. If the threshold is exceeded, Perform correction actions to resolve memory leaks.
Effectively predict and mitigate memory leaks, avoid system crashes, improve system performance, avoid unnecessary process restarts, and improve system stability.
Smart Images

Figure CN116048767B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates generally to the field of data management and more particularly to a method and system for predicting and mitigating memory leaks in a computer system. Summary of the invention
[0002] According to an aspect of the present disclosure, a computer-implemented method is provided, comprising: determining a first snapshot and a second snapshot of memory usage of a process in a computing system based on a predetermined time interval, wherein, for a corresponding process, a corresponding snapshot in the first snapshot and the second snapshot indicates memory usage corresponding to a memory type, the memory type including a private memory and a shared memory; for a process common to the first snapshot and the second snapshot, calculating a likelihood of a memory leak for the process and the memory type, calculating the likelihood comprising calculating a least squares linear fit based on: an increase in the amount of heap memory and private memory used by the process; an increase in the amount of shared memory used by the process; and an increase in the total amount of the private memory and the shared memory used by the process; comparing the calculated likelihood for the process with a predetermined threshold; and in response to determining that the calculated likelihood for the process exceeds the predetermined threshold, performing a corrective action in the computing system to resolve the memory leak for the process.
[0003] According to another aspect of the present disclosure, a computer system is provided, comprising: a processor; and a non-transitory storage medium, the non-transitory storage medium being coupled to the processor and storing instructions, the instructions, when executed on the processor, causing the computer system to perform the following operations: determining a first snapshot and a second snapshot of memory usage of a process in the computer system based on a predetermined time interval, wherein, for a corresponding process, a corresponding snapshot in the first snapshot and the second snapshot indicates memory usage corresponding to a memory type, the memory type including a private memory and a shared memory; for a process common to the first snapshot and the second snapshot, calculating a likelihood of a memory leak for a process and a memory type based on: an increase in an amount of heap memory used by the process; an increase in an amount of private memory used by the process, wherein the private memory used by the process includes the heap memory and memory-mapped file input / output memory; an increase in an amount of shared memory used by the process; and an increase in a total amount of the private memory and the shared memory used by the process; comparing the calculated likelihood for the process with a predetermined threshold; and in response to determining that the calculated likelihood for the process exceeds the predetermined threshold, initiating a corrective action to resolve a memory leak for the process.
[0004] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, the non-transitory computer-readable storage medium storing instructions that, when executed by a computer, cause the computer to perform the following operations: determining a first snapshot and a second snapshot of memory usage of a process in a computing system based on a predetermined time interval, wherein, for a corresponding process, a corresponding snapshot in the first snapshot and the second snapshot indicates memory usage corresponding to a memory type, the memory type including a private memory and a shared memory; for a process common to the first snapshot and the second snapshot, calculating a likelihood of a memory leak for the process and the memory type based on the following items: an increase in the amount of heap memory and private memory used by the process; an increase in the amount of shared memory used by the process; and and an increase in the total amount of the private memory and the shared memory used by the process; comparing the calculated likelihood for the process to a predetermined threshold; in response to determining that the calculated likelihood for the process exceeds the predetermined threshold, initiating corrective action to resolve a memory leak associated with the process; and causing information to be displayed for the common process including: an increase or decrease in the amount of proportional set size (PSS) shared memory used by the process; an increase or decrease in the amount of heap memory used by the process; an increase or decrease in the amount of private memory used by the process; an increase or decrease in the amount of shared memory used by the process; and an increase in the total amount of the private memory and the shared memory used by the process. BRIEF DESCRIPTION OF THE DRAWINGS
[0005] Figure 1 An environment with entities and communications that facilitate predicting and mitigating memory leaks in a computer system according to one aspect of the present application is illustrated.
[0006] Figure 2 A table depicting various types of memory used by a process is illustrated in accordance with an aspect of the present application.
[0007] Figure 3 A flow chart illustrating a method of facilitating prediction and mitigation of memory leaks in a computer system according to an aspect of the present application is presented.
[0008] Figure 4A A flow chart illustrating a method of facilitating prediction and mitigation of memory leaks in a computer system including steps 1 to 4 as described herein according to an aspect of the present application is presented.
[0009] Figure 4B A flow chart illustrating a method of facilitating prediction and mitigation of memory leaks in a computer system including steps 5 to 12 as described herein according to an aspect of the present application is presented.
[0010] Figure 4CA flow chart illustrating a method of facilitating prediction and mitigation of memory leaks in a computer system including steps 13 to 15 as described herein according to an aspect of the present application is presented.
[0011] Figure 5A Results of steps 1 to 8 of the described method according to one aspect of the present application are presented.
[0012] Figure 5B The results of step 11 of the described method according to one aspect of the present application are presented, including a list of processes with increased total memory usage.
[0013] Figure 5C The results of step 13 of the method described according to one aspect of the present application are presented, including a list of the progress of the total memory usage increase and the calculated criteria and health status.
[0014] Figure 6 A graph depicting memory usage over time and metric calculations from data points between two memory snapshots according to an aspect of the present application is presented.
[0015] Figure 7 A computer system that facilitates predicting and mitigating memory leaks in a computer system according to an aspect of the present application is illustrated.
[0016] Figure 8 An apparatus for facilitating prediction and mitigation of memory leaks in a computer system according to an aspect of the present application is illustrated.
[0017] In the drawings, like reference numerals refer to the same drawing elements. DETAILED DESCRIPTION
[0018] The following description is presented to enable any person skilled in the art to make and use the various aspects and examples, and is provided in the context of a specific application and its requirements. Various modifications to the disclosed aspects will be apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects and applications without departing from the spirit and scope of the present disclosure. Therefore, the various aspects described herein are not limited to the aspects shown, but are intended to be consistent with the maximum scope consistent with the principles and features disclosed herein.
[0019] A computing system may include multiple processes running simultaneously. Each process may consume memory of the computing system. If the memory usage of a particular process grows to exceed a certain threshold (e.g., exceeds a limit), the system may need to end and restart the process to avoid completely restarting the system. Although many computing systems may run in a redundant manner (e.g., using active devices and standby devices), it may be desirable to avoid moving from an active device to a standby device to handle a significant memory leak caused by one (or more) processes.
[0020] The described aspects of the present application provide a system that can monitor the use of memory by the entire system and by individual processes, and can predict whether observed memory growth may lead to potential memory leaks. The system can then perform corrective actions to resolve the identified memory leaks.
[0021] The described system may use a memory usage snapshot tool that may determine snapshots of memory usage of processes in a computing system based on predetermined and configurable time intervals (e.g., every 30 minutes, every hour, every 2 hours, etc.). The system or user may configure or change the time intervals in real time. The term "user" in this disclosure may refer to an administrator, an administrative user, or other user who is authorized to access memory snapshots, receive notifications of memory leaks, and perform corrective actions. If memory usage begins to grow faster over time, the system or user may reduce the interval between snapshots to allow the system to capture these "faster leaks" before they affect the operation of the entire system. The system may also move between two different snapshots by using a sliding window or a jumping window, where each window may include configurable parameters to adjust the behavior based on system characteristics.
[0022] Each snapshot can indicate information about a set of processes running at a corresponding time. For example, a first snapshot can indicate memory usage corresponding to various types of memory used for a given process and memory usage of various segments of random access memory (RAM) disk memory. The two types are common memory, which can include process memory and files in a RAM-based file system (e.g., Linux's tmpfs). The system can treat process memory and RAM disk memory as separate memory spaces, even though both types can reside in physical RAM memory. RAM disk memory (i.e., file-backed memory) can be subdivided into separate spaces of various fixed sizes that can be configured. Each of these spaces can store specific types of files, such as log files, temporary files, and configuration files.
[0023] Each process can use two basic types of memory: private memory; and shared memory, as described below. Figure 2Described. Private memory can include heap memory and memory-mapped file input / output (I / O). Shared memory can include shared libraries and shared memory, which is memory shared between multiple processes.
[0024] The described aspects of the system may include various steps based on obtaining and storing memory snapshots, as described below with respect to Figure 1 and Figure 3 as well as FIG. 4A to FIG. 4C The system may display certain results to the user, including results based on an increase or decrease in memory usage based on the type of memory used for a process, a group of processes, a system, or other data grouping. FIG. 5A to FIG. 5C An example of displaying results is described. Based on the stored or displayed information, the system can also calculate an indicator that indicates the likelihood of a memory leak for a given process and / or the memory type used by a given process. The indicator can be based on a predetermined number of time units and can be calculated using a least squares linear fit based on the increase in the amount of each type of memory used by the process or system. The system can define a set of ranges to indicate health status or severity levels, and can trigger a notification when the health status or severity level (based on a given calculated indicator) falls within a certain range (e.g., by comparing the calculated indicator to a predefined range or a predetermined threshold). As described herein, these ranges can be predefined or configured by the user or set to default values. The system can send a notification to the user, for example as an alert. The notification can cause the system or user to perform corrective actions to resolve a memory leak associated with a particular process, for example, terminating and restarting the process, or notifying / reporting the problem.
[0025] Facilitates communication to predict and mitigate memory leaks
[0026] Figure 1An environment 100 with entities and communications that facilitate prediction and mitigation of memory leaks in a computer system according to one aspect of the present application is illustrated. Environment 100 may include: device 102, associated user 112, and associated display screen 114; device 104 and associated or included storage device 105; and devices 106, 107, and 108. User 112 may be an administrative user, a network administrator, or other user authorized to perform operations associated with the user described herein. Devices 102, 104, and 106 to 108 may communicate with each other via network 110. Device 102 may be a client computing device, such as a laptop computer, a mobile phone, a smart phone, a tablet computer, a desktop computer, and a handheld device. Devices 102, 104, and 106 to 108 may be computing devices (e.g., servers, networking entities, and communication devices), and may include multiple processes running at any given time. Devices 106 to 108 may provide redundancy for each other, for example, device 106 may be configured as an active device, and device 107 may be configured as an associated standby device.
[0027] During operation, device 104 may take or obtain snapshots of memory usage of processes running in devices 106, 107, and 108 (operation 120), via, for example, communications 150, 152, and 154, by using a memory usage snapshot tool or other similar functionality. Device 104 may obtain these snapshots at predetermined time intervals that may be set by the system or configured by user 112 or another administrative user. The time intervals may also be set to default values or dynamically changed while the processes are running, and device 104 may take or obtain real-time memory snapshots. Device 104 may store the snapshots (operation 122), for example, in storage device 105. In some aspects, devices 106, 107, and 108 may be independent devices that store their own memory snapshots and make their own decisions based on the data in those snapshots.
[0028] Display 114 may include, indicate or display various information to user 112, including actionable gadgets and selectable lists or elements 160 to 182, which can be activated or acted upon to send commands to device 104. That is, user 112 can perform action 113 to activate any of the elements indicated in display 114. For example, user 112 may wish to view a memory snapshot (element 160) of device 106. User 112 may also specify (using elements 160 and 162 and other optional elements not shown) to view snapshots from device 106 within a certain time period. User 112 may also select certain snapshots to view snapshots of memory usage, such as taken at a certain time and for a process in a certain device. User 112 may cause device 102 to send a view / select snapshot 124 command to device 104 via an activation element on display 114.
[0029] Device 104 may receive command 124 (as a view / select snapshot 126 command) and may return the requested snapshot 128 in response. Device 102 may receive snapshot 128 (as snapshot 130) and may display the requested snapshot on display 114. As part of responding to command 124 / 126 to select and return a snapshot, device 104 may also perform a comparative accounting (operation 132) (corresponding to steps 1 to 8 of the method described herein) on two snapshots taken at different times, which may cause the accounting results (steps 1 to 8) to be displayed on display 114 (element 164). Based on the stored / selected snapshots, device 104 may determine the memory increase / decrease by memory type for each process and system (operation 134). Device 104 may return memory change information 138 to device 102. The device 102 can receive the memory change information 138 (as the memory change information 140) and can display on the display 114: a list of processes that increased by memory type (corresponding to step 9) (element 166); a list of common processes that increased instance counts (between a pair of snapshots) (corresponding to step 10) (element 168); a list of common processes that increased total memory usage (corresponding to step 11) (element 170); and a list of common processes that decreased total memory usage (corresponding to step 12) (element 172).
[0030] Device 104 may also calculate metrics and health (e.g., severity level) for each process listed in elements 166 to 172, and may send metrics / health 142 information back to device 102. Device 102 may receive metrics / health 142 (as metrics / health 144) and may display a list of common processes with increased memory usage by memory type and metrics and health (corresponding to step 13) on display 114 (element 174). Display 114 may also include a list of common processes with decreased memory usage by memory type and metrics and health (not shown), as well as metrics and health of cumulative memory usage by memory type for each data point in each process (corresponding to step 14) (element 176). In addition, display 114 may include metrics and health for file-backed memory segments (corresponding to step 15) (element 178). FIG. 4A to FIG. 4C Steps 1 to 15 are described, wherein the following FIG. 5A to FIG. 5C Some example displays (similar to display elements 164 to 178) are depicted.
[0031] In viewing or obtaining the metrics and health, the system or user 112 may determine to perform corrective action to resolve a memory leak associated with a given process running on the device 106, for example, by sending a restart process command for the given process via element 180, or by performing an action associated with the given process via element 182. By identifying, terminating, and restarting a given process that is detected as a memory leak in the device 106, the system may both efficiently handle the detected memory leak of the given process and avoid switching from the active device 106 to the standby device 107, which may result in improved performance and efficiency of the overall system.
[0032] Memory type
[0033] Figure 2 A table 200 depicting various types of memory used by a process is illustrated according to an aspect of the present application. The table 200 indicates four quadrants and may include private memory 202 and shared memory 204, where each memory type is associated with anonymous (non-file-backed) memory 212 or file-backed memory 214. Each memory page of a process may have only one of the four classifications in the quadrants of the table 200 at a time. Each quadrant may indicate an example of a system call that may cause the creation of memory corresponding to that quadrant.
[0034] For example: a malloc() call can cause the creation of private anonymous (non-file-backed) memory, such as heap memory; an mmap(PRIVATE,ANON) call can cause the creation of private memory that is also anonymous (non-file-backed and has no name or file descriptor attached); and an mmap(PRIVATE,fd) call can cause the creation of private memory that is file-backed with a file descriptor (such as memory-mapped file input / output (I / O)). If the system allocates memory on the heap (for example, by using malloc()), both the heap and private memory will increase. If the system allocates memory by using mmap(), heap usage remains the same, while private memory increases.
[0035] As another example: the POSIX shm_open() call can cause the creation of a shared memory object that opens shared memory but may not be saved to a file; the mmap(SHARED,ANON) call can cause the creation of anonymous (non-file-backed) shared memory; and the mmap(SHARED,fd) call can cause the creation of file-backed shared memory with a file descriptor.
[0036] The term "private memory" refers to memory that can be allocated based on the above calls, and can include heap memory. As described above, since heap memory usage can be included in the usage of private memory, an increase in heap memory can result in an increase in private memory. However, an increase in private memory does not result in an increase in heap memory usage. The term "shared memory" refers to memory that can be allocated based on the above calls, and can include memory shared by two or more processes. The term "proportional set size" (PSS) shared memory refers to the proportional amount of memory used by a given process compared to the total memory usage. If no other processes or programs are using, for example, a portion of 100K of shared memory, the shared PSS memory of the process that is using that portion of 100K of shared memory may increase. As other processes or programs begin to use shared memory, shared memory usage may increase, while shared PSS memory usage may decrease.
[0037] Methods to facilitate the prediction and mitigation of memory leaks
[0038] Figure 3A flowchart 300 is presented that illustrates a method for facilitating prediction and mitigation of memory leaks in a computer system according to an aspect of the present application. During operation, a system determines a first snapshot and a second snapshot of memory usage of a process in a computing system based on a predetermined time interval, wherein, for a respective process, the respective snapshot indicates memory usage corresponding to a memory type, the memory type including private memory and shared memory (operation 302). For the process common to the first snapshot and the second snapshot, the system calculates a likelihood of a memory leak for the respective process and memory type based on: an increase in the amount of heap memory and private memory used by the process; an increase in the amount of shared memory used by the process; and an increase in the total amount of private memory and shared memory used by the process (operation 304). The system compares the calculated likelihood for the process with a predetermined threshold (operation 306). If the calculated metric for the process exceeds the predetermined threshold (decision 308), the system performs a corrective action to resolve a memory leak associated with the process (operation 310). If the calculated metric for the process does not exceed the predetermined threshold (decision 308), the operation returns.
[0039] Figure 4AA flowchart 400 illustrating a method of facilitating prediction and mitigation of memory leaks in a computer system including steps 1 to 4 as described herein according to an aspect of the present application is presented. During operation, the system obtains the total process memory usage from a first snapshot ("snapshot 1") and places it in a variable called "total_file_1", and obtains the total process memory usage from a second snapshot ("snapshot 2") and places it in a variable called "total_file_2" (step 1, operation 402). For all processes that are present in snapshot 1 but not in snapshot 2, the system sums the total memory usage (private + shared) into an accumulator called "memory_file_1_only" (step 2, operation 404). For all processes that are present in snapshot 2 but not in snapshot 1, the system sums the total memory usage (private + shared) into an accumulator called "memory_file_2_only" (step 3, operation 406). For all processes common to snapshot 1 and snapshot 2, the system determines the increase or decrease in private memory of each process (step 4, operation 408). Step 4 may include: step 4A, operation 410; and step 4B, operation 412. If the amount of private memory used has increased, the system performs the following operations: the system sums the increase in private memory into an accumulator called "private_increase" (step 4A1); if the process's heap memory has increased, the system adds the process to a list of processes with increased heap memory (step 4A2); and if the process's PSS shared memory has increased, the system adds the process to a list of processes with increased PSS shared memory (step 4A3) (step 4A, operation 410). If the private memory has decreased, the system sums the decrease in private memory into an accumulator called "private_decrease" (step 4B, operation 412), and the operation Figure 4B Continue from label A of .
[0040] Figure 4BA flowchart 420 illustrating a method for facilitating prediction and mitigation of memory leaks in a computer system including steps 5 to 12 as described herein according to an aspect of the present application is presented. For all processes common to snapshot 1 and snapshot 2, the system sums all increases in shared memory into an accumulator called "shared_increase" (step 5, operation 422). For all processes common to snapshot 1 and snapshot 2, the system sums all decreases in shared memory into an accumulator called "shared_decrease" (step 6, operation 424). Subsequently, the system calculates the net change in total memory usage for snapshot 1, for example: total_file_1 = total_file_1 + memory_file_2_only - memory_file_1_only + private_increase - private_decrease + shared_increase - shared_decrease (step 7, operation 426). The system verifies that all changes in memory usage between snapshot 1 and snapshot 2 have been accounted for (e.g., total_file_1 equals total_file_2) (step 8, operation 428). If the change is not accounted for, i.e., the system determines that there is a difference between the newly calculated net change of total_file_1 and the newly calculated net change of total_file_2, the system can generate a notification to the user, and the user can take corrective action to identify or resolve the cause of the difference (not shown). Figure 5A An example of information displayed as a result of steps 1 to 8 is described.
[0041] The system displays a list of processes with increased memory usage (as identified in step 4, operation 408 and step 5, operation 422), including processes with increases in the following memory types: private memory; heap memory; shared memory; shared PSS memory; and total memory (private + shared) (step 9, operation 430). Figure 5B An example of displaying a list of processes common to both snapshots whose memory usage has increased is described. The system also displays a list of processes whose instance counts have increased, and can report processes whose instance counts exceed a predetermined threshold or number (step 10, operation 432). For all processes common to snapshot 1 and snapshot 2 whose total memory usage has increased, the system lists these processes and their increases in memory usage in descending order of total memory usage increase (step 11, operation 434), such as Figure 5B For all processes common to snapshot 1 and snapshot 2 whose total memory usage has been reduced, the system lists these processes and their memory usage reductions in ascending order of total memory usage reduction (step 12, operation 436). Figure 4C Continue at label B of .
[0042] Figure 4C A flowchart 440 is presented illustrating a method for facilitating prediction and mitigation of memory leaks in a computer system including steps 13 to 15 as described herein according to an aspect of the present application. For all processes common to snapshot 1 and snapshot 2 whose total memory usage has increased, the system calculates metrics (likelihood of memory leak) and health status (severity level) for the corresponding processes and memory types based on: the increase in private memory usage between snapshot 1 and snapshot 2; the increase in shared memory usage between snapshot 1 and snapshot 2; and the increase in the total amount of private memory usage and shared memory usage between snapshot 1 and snapshot 2 (step 13, operation 442). The system displays the calculated metrics and health status for the common processes (operation 444, as shown in Figure 1 174 of display element 174). For each data point for all processes common to snapshot 1 and snapshot 2, the system calculates metrics and health status for the sum of each type of process memory, the sum of each type of process memory including: the sum of private memory usage; the sum of shared memory usage; and the sum of total memory (private + shared) usage (step 14, operation 446). The system displays the calculated metrics and health status for the cumulative memory type (operation 448, as shown in Figure 1 446, or 450). For each file-backed memory segment, the system calculates a metric and a health status based on a predetermined watermark (step 15, operation 450). In response to determining that the calculated metric (e.g., from 442, 446, or 450) exceeds a predetermined threshold, the system (or an administrative user) performs a corrective action (operation 452), and the operation returns.
[0043] Display results of each step of the method; calculation indicators; examples of calculation indicators
[0044] Figure 5A Results 500 of steps 1 through 8 of the described method according to an aspect of the present application are presented. As shown in results 500, step 8 provides a "sanity check" of the comparative accounting of steps 1 through 7 and verifies that the memory changes between snapshot 1 and snapshot 2 have been fully accounted for without errors. In this disclosure and the accompanying drawings, the terms "kilobyte," "KB," and "KiB" may be used interchangeably.
[0045] Figure 5BResults 520 of step 11 of the method described according to one aspect of the present application are presented, including a list of processes with increased total memory usage. Results 520 may include a list of processes, and for each process, information includes: process name; amount of PSS shared memory usage between snapshot 1 and snapshot 2; amount of heap memory usage between snapshot 1 and snapshot 2; amount of private memory usage between snapshot 1 and snapshot 2; amount of shared memory usage between snapshot 1 and snapshot 2; total amount of memory (private + shared) used between snapshot 1 and snapshot 2; and percentage of total memory used by the process. For example, entry 522 for a process named "httpd" indicates the following information by memory usage type between snapshot 1 and snapshot 2: PSS shared memory usage is 0.0KB; heap memory usage is 7780.0KB; private memory usage is 13060.0KB; shared memory usage is 8.0KB; total amount of memory (private + shared) usage is 13068.0KB; and total memory used by the process is 86.29%. Results 520 are displayed in descending order of increasing total memory usage (13068.0 to 1.0). In some aspects, results 520 may be displayed in ascending or descending order based on data in any column depicted in results 520.
[0046] Figure 5C The result 540 of step 13 of the method described according to one aspect of the present application is presented, including a list of processes with increased total memory usage and calculated indicators and health status. The result 540 may include a list of processes, and for each process, information includes: process name; amount of PSS shared memory usage between snapshot 1 and snapshot 2; amount of heap memory usage between snapshot 1 and snapshot 2; amount of private memory usage between snapshot 1 and snapshot 2; amount of shared memory usage between snapshot 1 and snapshot 2; an indicator indicating the possibility of a memory leak for the process, and the indicator is calculated for the process based on the data points between snapshot 1 and snapshot 2 using, for example, a least squares linear fit (as described below with respect to Figure 6 as described); and the health state or health condition as an indication of severity.
[0047] The metric may be based on a predetermined number of time units (e.g., hours or days) required for the system, and the health status may be based on a plurality of predefined ranges based on a predetermined number of time units. For example, a typical maintenance contract for a computing system may require a firmware upgrade every two years, and during every two years of operation time, the computing system may be expected to operate continuously for the two-year period. Thus, a network administrator or other administrative user may set any metric that is less than a predetermined threshold of two years to a "critical" range of health status, meaning that a process metric calculation that produces a "time to run out of memory" or "time to fill up memory" of less than 2 years may be marked as "critical". As described below, the system may calculate a metric as time to fill up memory based on current memory usage, total memory capacity, and a memory safety threshold, and a calculated memory leak rate (in kilobytes / hour) for a given process. Once the metric is calculated, the system may compare the metric to a predetermined threshold (or thresholds) and determine which predefined category range applies to the calculated metric. For example: a metric that is less than 2 years old may be associated with a "critical" health status; a metric that is between 2 and 5 years old may be associated with a "warning" health status; and a metric that is more than 5 years old may be associated with a "good" health status. A greater or lesser number of ranges and associated categories may be used and configured by the system or an administrative user. Additionally, each health condition may be associated with an action to be automatically performed (e.g., restarting a process) or may be reported to an administrative user in a notification (e.g., allowing the administrative user to determine whether to perform a corrective action such as restarting a process).
[0048] As an example, entry 542 for a process named "httpd" indicates the following information by memory usage type between snapshot 1 and snapshot 2: PSS shared memory usage is 0.0KB; heap memory usage is 7780.0KB; private memory usage is 13060.0KB; shared memory usage is 8.0KB; the index is 1.61 (e.g., in years); and the corresponding health status is "critical". Results 540 are displayed in ascending order of the calculated index values (1.61 to 4042.60). In some aspects, results 540 can be displayed in ascending or descending order based on the data in any column depicted in results 540.
[0049] Recall that the two types of common memory can include process memory and files in a RAM-based file system (e.g., Linux's tmpfs), and the system can treat these two memory types as separate memory spaces, even though both types can reside in physical RAM memory. For RAM disk memory, the system can calculate the likelihood of a memory leak associated with a file-backed memory segment and the associated health status based on a predetermined watermark. The watermark can be, for example, a percentage ranging from 0% (completely empty) to 100% (completely full). The system can configure the watermark (i.e., the predetermined watermark) to be a certain percentage below 100% so that those memory leaks can be caught and mitigated long before they will cause system failures. The configurable watermark can be determined based on historical data, industry standards, specific device-related information, and any other characteristics.
[0050] Figure 6 A graph 600 is presented depicting memory usage over time and metric calculations based on data points between two memory snapshots according to an aspect of the present application. Graph 600 includes an x-axis representing elapsed time (in hours) 604 and a y-axis representing memory usage (in KB) 602. Arrows 612, 614, 616, and 618 may indicate the time points at which the accounting snapshots were taken. The data points between each set of arrows may be used to calculate a linear fit slope, metric, and health. Line 610 may indicate a best fit line through the data between the snapshots.
[0051] In one example for calculating the metric for process A, assume the following: the current memory usage of process A is 70,540KB; the total available memory size is 1,021,740KB; and the memory safety threshold is set to 250,000KB. The memory safety threshold may represent or indicate the amount of buffer before the system will fill up memory.
[0052] Suppose that process A is determined to be leaking memory at a rate of 20KB per hour, as determined from individual snapshots and a least squares linear fit calculated (e.g., Figure 6). The system can calculate the metric by calculating the “time to fill up memory” as follows: (total memory size – memory safety threshold – current memory usage of process A) / memory leak rate: (1,021,740–250,000–70,540) / 20 = 35,060.0 hours, which yields 35,060.0 hours / (24 hours / day × 365 days / year = 8,760 hours / year) = 4.0 years. The system can apply, for example, the thresholds described previously (related to a two-year frequency of required firmware upgrades), with ranges of: “less than 2 years (critical)”; “between 2 and 5 years (warning)”; and “more than 5 years (good)”. Therefore, the determined time to fill up memory for process A (i.e., the calculated metric of 4.0 years) falls within the range for a health state of “warning”, and no immediate corrective action is required. The system can record process A in a list of processes that need to be monitored (e.g., by taking snapshots more frequently or at shorter time intervals). The system may perform other reporting or monitoring tasks related to determining that the calculated indicator for process A is "warning".
[0053] In another example for calculating the metric for process B, assume the following: the current memory usage of process B is 70,540KB; the total available memory size is 1,021,740KB; and the memory safety threshold is set to 250,000KB. Assume that process B is determined to leak memory at a rate of 1,024KB per hour (this is determined as described above). The system can calculate the metric by calculating the "time to fill up memory" as follows: (total memory size - memory safety threshold - current memory usage of process B) / memory leak rate: (1,021,740 - 250,000 - 70,540) / 1,024 = 685 hours, which yields: 685 hours / (24 × 365 = 8,760) hours / year = 0.078 years. Because the determined time to fill memory for process B (i.e., the calculated metric of 0.078 years) is less than 2 years, which corresponds to the range of a health status of "critical", the system can determine that process B falls within the range of a health status of "critical". This indicates that immediate corrective action is required. The system can notify or alert an administrative user of the "critical" health status of process B. The system and / or the user can perform corrective action, such as terminating process B, or terminating and restarting process B. The system can also perform other logging or monitoring tasks related to determining that the calculated metric for process B is "critical".
[0054] Computer systems and devices
[0055] Figure 7A computer system 700 is illustrated that facilitates prediction and mitigation of memory leaks in a computer system according to one aspect of the present application. The computer system 700 includes a processor 702, a volatile memory 706, and a storage device 708. The volatile memory 706 may include, for example, a random access memory (RAM) used as a managed memory, and may be used to store one or more memory pools. The storage device 708 may include a persistent storage device that may be managed or accessed via the processor 702. In addition, the computer system 700 may be coupled to peripheral input / output (I / O) user devices 710, such as a display device 711, a keyboard 712, and a pointing device 714. The storage device 708 may store an operating system 716, a content processing system 718, and data 736.
[0056] The content processing system 718 may include instructions that, when executed by the computer system 700, may cause the computer system 700 or the processor 702 to perform the methods and / or processes described in the present disclosure. Specifically, the content processing system 718 may include instructions for receiving and sending data packets, requests, and commands (communication module 720).
[0057] The content processing system 718 may further include instructions for determining a first snapshot and a second snapshot of memory usage of a process in the computing system based on a predetermined time interval, wherein, for a respective process, the respective snapshot indicates memory usage corresponding to a memory type (including private memory and shared memory) (snapshot obtaining module 722). The content processing system 718 may include instructions for calculating, for a process common to the first snapshot and the second snapshot, a likelihood of a memory leak for the process and the memory type based on the following: an amount of heap memory, private memory, shared memory, and an increase in the total amount of private memory and shared memory used by the process (metric calculation module 726). The content processing system 718 may include instructions for comparing the calculated likelihood for the process with a predetermined threshold (health determination module 728). The content processing system 718 may include instructions for performing a corrective action to resolve a memory leak associated with the process in response to determining that the calculated likelihood for the process exceeds the predetermined threshold (health determination module 728) (action execution module 734).
[0058] The content processing system 718 may include a method for verifying that all changes in memory usage between the first snapshot and the second snapshot have been accounted for (e.g., regarding Figure 4A , Figure 4B and Figure 5AThe content processing system 718 may include instructions for displaying information including the following for processes in the common process: an increase or decrease in the amount of proportional set size (PSS) shared memory used by the process; an increase or decrease in the amount of heap memory used by the process; an increase or decrease in the amount of private memory used by the process; an increase or decrease in the amount of shared memory used by the process; and an increase in the total amount of private memory and shared memory used by the process (process display module 730), as well as information about the total amount of shared memory used by the process. Figure 4B , Figure 4C , Figure 5B and Figure 5C Instructions for the calculated likelihood and associated health status for each process as described in steps 11 to 14 (memory usage display module 732).
[0059] Data 736 may include any data required as input or generated as output by the methods and / or processes described in the present disclosure. Specifically, data 736 may store at least: two or more snapshots; types of memory usage; the amount of memory of a certain type (including heap memory, private memory, shared memory, PSS shared memory, and total memory) used; processes; a list of processes; an increase or decrease in the amount of memory usage; a probability or indicator; a health state; a health state; a severity level; a predetermined threshold; a corrective action; an indicator of whether the change in memory usage between two snapshots was successfully verified; a calculation; a sum; ascending or descending order; a group of processes; a data point; a time; an elapsed time; a predetermined time interval; one or more indicators; a predetermined number of time units; a quantity; a comparison; a predefined range based on a time unit; a least squares linear fitting method; an indicator of a memory segment backed by a process, a group of processes, a system including a process, and a file; and a predetermined watermark.
[0060] Figure 8 An apparatus 800 for facilitating prediction and mitigation of memory leaks in a computer system according to an aspect of the present application is illustrated. The apparatus 800 may include a plurality of units or devices that may communicate with each other via wired, wireless, quantum optical, or electrical communication channels. The apparatus 800 may be implemented using one or more integrated circuits and may include, for example, Figure 8 The units or devices shown in the figure may be fewer or more units or devices. In addition, the apparatus 800 may be integrated into a computer system, or implemented as a separate one or more devices capable of communicating with other computer systems and / or devices.
[0061] The apparatus 800 may also include a non-volatile storage system or a memory management unit. The apparatus 800 may include a device configured to perform similar Figure 7The modules or units 802-816 of the functions or operations of the modules 720-734 of the computer system 700 include: a communication unit 802; a snapshot acquisition unit 804; a snapshot accounting unit 806; an indicator calculation unit 808; a health determination unit 810; a process display unit 812; a memory usage display unit 814; and an action execution unit 816.
[0062] In general, the disclosed aspects provide a system that facilitates predicting and mitigating memory leaks in a computer system. In one aspect, during operation, the system determines a first snapshot and a second snapshot of memory usage of a process in the computing system based on a predetermined time interval, wherein, for a respective process, the respective snapshot indicates memory usage corresponding to a memory type (including private memory and shared memory). The system calculates a likelihood of a memory leak for the process and the memory type based on the following for the process common to the first snapshot and the second snapshot: an increase in the amount of heap memory and private memory used by the process; an increase in the amount of shared memory used by the process; and an increase in the total amount of private memory and shared memory used by the process. The system compares the calculated likelihood for the process to a predetermined threshold. In response to determining that the calculated likelihood for the process exceeds the predetermined threshold, the system (or a user) performs a corrective action to resolve a memory leak associated with the process.
[0063] In a variation of this aspect, the system verifies that all changes in memory usage between the first snapshot and the second snapshot have been accounted for by performing a first set of calculations including: determining an increase or decrease in private memory for a common process; determining an increase or decrease in heap memory for a common process; determining an increase or decrease in proportional set size (PSS) shared memory for a common process; summing increases in shared memory for a common process; and summing decreases in shared memory for a common process. The system calculates a net change in total memory usage for the first snapshot based on the first set of calculations. The system verifies that the calculated net change for the first snapshot matches the total memory usage for the second snapshot.
[0064] In another variation of this aspect, the system displays information for a common process including: an increase or decrease in the amount of proportional set size (PSS) shared memory used by the process; an increase or decrease in the amount of heap memory used by the process; an increase or decrease in the amount of private memory used by the process; an increase or decrease in the amount of shared memory used by the process; and an increase in the total amount of private and shared memory used by the process.
[0065] In a further variation, the information is displayed based on at least one of: descending order based on an increase in the total amount of private memory and shared memory used by the process; and ascending order based on a decrease in the total amount of private memory and shared memory used by the process.
[0066] In a further variation, descending order is used to display a first group of common processes, where the total amount of private memory and shared memory used by each process increases, and ascending order is used to display a second group of common processes, where the total amount of private memory and shared memory used by each process decreases.
[0067] In a further variation, the displayed information further includes a calculated likelihood and associated health status for at least one of: a process for which the amount of private memory used by it increased; a process for which the amount of shared memory used by it increased; a process for which the total amount of private and shared memory used by it increased; the sum of private memory usage for data points in each process; the sum of shared memory usage for data points in each process; and the sum of total memory usage for data points in each process, which total memory usage includes private memory usage and shared memory usage.
[0068] In a further variation, the likelihood comprises an indicator based on a predetermined number of time units, and the associated health state is based on a comparison of the calculated likelihood for the process to a predetermined threshold and comprises a plurality of predefined ranges based on the predetermined number of time units.
[0069] In further variations, the displayed information further includes a calculated likelihood and an associated health state of the system associated with at least one of: the first snapshot and the second snapshot; and a common progression.
[0070] In a further variation, calculating the likelihood includes calculating a least squares linear fit based on an increase in the amount of heap memory, private memory, shared memory, and total private memory and shared memory used by the process.
[0071] In a further variation, the system calculates a likelihood of a memory leak associated with a file-backed memory segment and an associated health status based on a predetermined watermark.
[0072] The data structures and codes described in this detailed description are typically stored on a computer-readable storage medium, which can be any device or medium that can store code and / or data for use by a computer system. Computer-readable storage media include, but are not limited to, volatile memory, non-volatile memory, magnetic and optical storage devices (such as disk drives, tapes, CDs (compact disks), DVDs (digital versatile disks or digital video disks)), or other media capable of storing computer-readable media now known or later developed.
[0073] The methods and processes described in the detailed description section may be embodied as code and / or data that may be stored in a computer-readable storage medium as described above. When a computer system reads and executes the code and / or data stored on a computer-readable storage medium, the computer system executes the methods and processes embodied as data structures and code and stored in the computer-readable storage medium.
[0074] In addition, the above methods and processes may be included in a hardware device or apparatus. For example, the hardware device or apparatus may include, but is not limited to, an application specific integrated circuit (ASIC) chip, a field programmable gate array (FPGA), a dedicated or shared processor that executes a specific software program or a piece of code at a specific time, and other programmable logic devices now known or later developed. When the hardware device or apparatus is activated, the hardware module executes the methods and processes included therein.
[0075] The foregoing description of various aspects has been presented for purposes of illustration and description only. The foregoing description is not intended to be exhaustive or to limit the various aspects described herein to the disclosed forms. Accordingly, many modifications and variations will be apparent to those skilled in the art. In addition, the above disclosure is not intended to limit the various aspects described herein. The scope of the various aspects described herein is defined by the appended claims.
Claims
1. A computer-implemented method comprising: determining, based on a predetermined time interval, a first snapshot and a second snapshot of memory usage of a process in the computing system, wherein, for a corresponding process, a corresponding one of the first snapshot and the second snapshot indicates memory usage corresponding to a memory type, the memory type comprising private memory and shared memory; For a common process of the first snapshot and the second snapshot, a probability of a memory leak for a process and a memory type is calculated, wherein the probability calculation includes calculating a least square linear fit based on the following items: an increase in the amount of heap memory and private memory used by the process; an increase in the amount of shared memory used by the process; and an increase in the total amount of said private memory and said shared memory used by said process; comparing the calculated likelihood for the process to a predetermined threshold; and In response to determining that the calculated likelihood for the process exceeds the predetermined threshold, corrective action is performed in the computing system to resolve the memory leak for the process.
2. The method of claim 1, further comprising verifying that all changes in memory usage between the first snapshot and the second snapshot have been accounted for by: A set of calculations is performed, the set of calculations comprising: determining an increase or decrease in private memory of the common process; determining an increase or decrease in heap memory of the common process; determining an increase or decrease in a proportional set size (PSS) shared memory of the common process; summing the increases in shared memory of the common processes; as well as summing the reductions of the shared memory of the common processes; calculating a net change in total memory usage of the first snapshot based on the set of calculations; and Verify that the calculated net change of the first snapshot matches the total memory usage of the second snapshot.
3. The method of claim 1, further comprising: Displays information including the following: an increase or decrease in the amount of proportional set size (PSS) shared memory used by the process; an increase or decrease in the amount of said heap memory used by said process; an increase or decrease in the amount of said private memory used by said process; an increase or decrease in the amount of said shared memory used by said process; as well as An increase in the total amount of the private memory and the shared memory used by the process.
4. The method of claim 3, wherein: The information is displayed based on at least one of the following: in descending order based on increasing total amounts of the private memory and the shared memory used by the process; or In ascending order based on decreasing total amounts of the private memory and the shared memory used by the processes.
5. The method according to claim 4, in, The descending order is used to display a first group of common processes, wherein the total amount of private memory and shared memory used by each process in the common processes increases, and The ascending order is used to display a second group of common processes, wherein the total amount of the private memory and the shared memory used by each process in the common processes decreases.
6. The method of claim 3, wherein: The displayed information further includes the calculated likelihood and associated health status for the process.
7. The method of claim 1, further comprising: An associated health state for the process is determined based on a comparison of the calculated likelihood for the process to the predetermined threshold.
8. The method of claim 1, wherein: The calculated likelihood of the memory leak for the process and the memory type is based on a time to fill up memory of the memory type.
9. The method of claim 8, wherein: The time to fill up the memory of the memory type is based on a current memory usage of the memory of the memory type, a total memory capacity of the memory of the memory type, and a memory safety threshold of the memory of the memory type.
10. The method of claim 1, further comprising: A probability of a memory leak associated with a file-backed memory segment and an associated health status based on a predetermined watermark is calculated.
11. A computer system comprising: processor; as well as a non-transitory storage medium coupled to the processor and storing instructions that, when executed on the processor, cause the computer system to: determining, based on a predetermined time interval, a first snapshot and a second snapshot of memory usage of a process in the computer system, wherein, for a corresponding process, a corresponding one of the first snapshot and the second snapshot indicates memory usage corresponding to a memory type, the memory type comprising private memory and shared memory; For a common process of the first snapshot and the second snapshot, a probability of a memory leak for the process and the memory type is calculated based on the following items: an increase in the amount of heap memory used by the process; an increase in an amount of private memory used by the process, wherein the private memory used by the process includes the heap memory and memory mapped file input / output memory; an increase in the amount of shared memory used by the process; and an increase in the total amount of said private memory and said shared memory used by said process; comparing the calculated likelihood for the process to a predetermined threshold; and In response to determining that the calculated likelihood for the process exceeds the predetermined threshold, corrective action is initiated to resolve the memory leak for the process.
12. The computer system of claim 11, wherein: When executed, the instructions cause the computer system to verify that all changes in memory usage between the first snapshot and the second snapshot have been accounted for by: A set of calculations is performed, the set of calculations comprising: determining an increase or decrease in private memory of the common process; determining an increase or decrease in heap memory of the common process; determining an increase or decrease in a proportional set size (PSS) shared memory of the common process; summing the increases in shared memory of the common processes; and summing the reductions of the shared memory of the common processes; calculating a net change in total memory usage of the first snapshot based on the set of calculations; and Verify that the calculated net change of the first snapshot matches the total memory usage of the second snapshot.
13. The computer system of claim 11, wherein: The instructions, when executed, cause the computer system to: Displays information including the following: an increase or decrease in the amount of proportional set size (PSS) shared memory used by the process; an increase or decrease in the amount of said heap memory used by said process; an increase or decrease in the amount of said private memory used by said process; an increase or decrease in the amount of said shared memory used by said process; as well as An increase in the total amount of the private memory and the shared memory used by the process.
14. The computer system of claim 13, wherein: The displayed information further includes the calculated likelihood and associated health status for the process.
15. The computer system of claim 11, wherein: The instructions, when executed, cause the computer system to: An associated health state for the process is determined based on a comparison of the calculated likelihood for the process to the predetermined threshold.
16. The computer system of claim 11, wherein: The calculated likelihood of the memory leak for the process and the memory type is based on a time to fill up memory of the memory type.
17. The computer system of claim 11, wherein: Calculating the likelihood includes calculating a least squares linear fit based on an increase in the amount of heap memory used by the process, an increase in the amount of private memory used by the process, an increase in the amount of shared memory used by the process, and an increase in the total amount of the private memory and the shared memory used by the process.
18. A non-transitory computer-readable storage medium storing instructions that, when executed by a computer, cause the computer to: Determining a first snapshot and a second snapshot of memory usage of a process in a computing system based on a predetermined time interval, wherein: For a corresponding process, a corresponding snapshot of the first snapshot and the second snapshot indicates a memory usage corresponding to a memory type, the memory type including a private memory and a shared memory; For a common process of the first snapshot and the second snapshot, a probability of a memory leak for the process and the memory type is calculated based on the following items: an increase in the amount of heap memory and private memory used by the process; an increase in the amount of shared memory used by the process; and an increase in the total amount of said private memory and said shared memory used by said process; comparing the calculated likelihood for the process to a predetermined threshold; In response to determining that the calculated likelihood for the process exceeds the predetermined threshold, initiating corrective action to resolve a memory leak associated with the process; and Causes display of information including the following items for the common process: an increase or decrease in the amount of proportional set size (PSS) shared memory used by the process; an increase or decrease in the amount of said heap memory used by said process; an increase or decrease in the amount of said private memory used by said process; an increase or decrease in the amount of said shared memory used by said process; as well as An increase in the total amount of the private memory and the shared memory used by the process.
19. The non-transitory computer readable storage medium of claim 18, wherein: The calculated likelihood of the memory leak for the process and the memory type is based on a time to fill up memory of the memory type.
20. The non-transitory computer readable storage medium of claim 19, wherein: The time to fill up the memory of the memory type is based on a current memory usage of the memory of the memory type, a total memory capacity of the memory of the memory type, and a memory safety threshold of the memory of the memory type.
