Memory leak verification device, memory leak verification method, and program
The memory leak verification device rapidly detects leaks by managing memory areas, measuring usage, and comparing pre- and post-release values to identify memory leaks in processes with gradual increases.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- NISSIN ELECTRIC CO LTD
- Filing Date
- 2024-11-26
- Publication Date
- 2026-06-05
AI Technical Summary
Existing memory leak verification methods are impractical due to their reliance on threshold-based determinations that take a long time to detect gradual memory usage increases and can misidentify processes with low memory usage as leak-free.
A memory leak verification device and method that involves managing memory areas, measuring usage, and performing a gradual increase in memory usage to trigger a release process, followed by determining memory leaks based on pre- and post-release usage comparisons.
Enables rapid detection of memory leaks, effectively identifying leaks in processes with low initial memory usage and avoiding false negatives.
Smart Images

Figure 2026092281000001_ABST
Abstract
Description
Technical Field
[0006] , , , , , , , , , ,
[0001] The present invention relates to a memory leak verification apparatus, a memory leak verification method, and a program.
Background Art
[0002] As a technique related to the verification of memory leaks, there is an invention disclosed in the following patent documents. In Patent Document 1, the difference between the representative value of the memory usage amount in the current period and the representative value of the memory usage amount in the past period is estimated as the increase amount of the memory leak, and the leak increase rate is obtained from the increase amount of the memory leak and the time difference between the current period and the past period. It is disclosed that a warning is issued when the leak increase rate exceeds a predetermined upper limit increase rate.
[0003] Further, in Patent Document 2, the survival time, which is the time elapsed since the memory area used by the program was secured, is obtained, and the program is compared with a reference time determined in advance as a threshold value to detect a program in which a memory leak may have occurred.
[0004] Further, in Patent Document 3, the computer resource usage amount of the process is obtained, the number of times of updating the maximum value of the computer resource usage amount is counted, and based on the number of times of updating the maximum value, the presence or absence of a release leak of the computer resource is determined.
Prior Art Documents
Patent Documents
[0005]
Patent Document 1
Patent Document 2
Patent Document 3
Summary of the Invention
Problems to be Solved by the Invention
[0006] Methods based on memory usage cannot make a determination until a predetermined threshold is exceeded, and processes where memory usage increases gradually take a long time to exceed that threshold, making them impractical as verification methods.
[0007] Furthermore, methods based on the rate of memory increase may misidentify processes that experience a gradual increase in memory usage and subsequently develop memory leaks, as processes below a predetermined threshold are judged as having no memory leaks.
[0008] One aspect of the present invention aims to provide a technique that can verify whether or not a memory leak has occurred in a short period of time. [Means for solving the problem]
[0009] To solve the above problems, a memory leak verification device according to one aspect of the present invention comprises: a memory area management unit that manages memory areas used by multiple processes; a memory usage measurement unit that measures the memory usage of each of the multiple processes; a first process that gradually increases the memory usage and causes the memory area management unit to perform a memory release process; and a determination unit that determines whether a memory leak has occurred in a second process based on the memory usage of the second process to be verified, as measured by the memory usage measurement unit in response to the memory release process.
[0010] To solve the above problems, a memory leak verification method according to one aspect of the present invention includes the steps of: managing a memory area used by multiple processes; measuring the memory usage of each of the multiple processes; gradually increasing the memory usage to perform a memory release process; and determining whether a memory leak is occurring in the process under verification based on the memory usage of the process under verification measured in response to the memory release process.
[0011] To solve the above problems, a program according to one aspect of the present invention causes a computer to execute: a process for managing a memory area used by multiple processes; a process for measuring the memory usage of each of the multiple processes; a process for gradually increasing the memory usage and causing the computer to perform a memory release process; and a process for determining whether a memory leak is occurring in the process under verification based on the memory usage of the process under verification measured in response to the memory release process. [Effects of the Invention]
[0012] According to one aspect of the present invention, it is possible to verify whether or not a memory leak has occurred in a short period of time. [Brief explanation of the drawing]
[0013] [Figure 1] This figure shows an example configuration of a memory leak verification device according to one embodiment of the present invention. [Figure 2] This is a flowchart illustrating the processing procedure of a memory leak verification device according to one embodiment of the present invention. [Figure 3] This diagram illustrates the results of verifying whether or not a memory leak has occurred. [Modes for carrying out the invention]
[0014] [Embodiment 1] Hereinafter, an embodiment relating to one aspect of the present invention (hereinafter also referred to as "this embodiment") will be described based on the drawings. In the drawings, the same or corresponding parts are denoted by the same reference numerals, and their descriptions will not be repeated.
[0015] (Configuration of Memory Leak Verification Device 1) Figure 1 is a block diagram showing the configuration of the main parts of the memory leak verification device 1 according to this embodiment. The memory leak verification device 1 comprises a memory 11, a memory area management unit 12, a memory usage measurement unit 13, and a determination unit 14.
[0016] The memory 11 stores programs, parameters, and data used in each part of the memory leak verification device 1. For example, by a processor (not shown) executing the program stored in the memory 11, a first process (hereinafter also referred to as a dummy process) 111 and a second process (hereinafter also referred to as a process to be verified) 112 are realized.
[0017] The memory area management unit 12 manages memory areas used by a plurality of processes and, for example, corresponds to garbage collection in Windows (registered trademark), etc. The memory area management unit 12 has a mechanism for automatically releasing memory areas that the program no longer uses.
[0018] Normally, the user needs to explicitly allocate memory and release the memory that has finished being used, but this often involves mistakes and causes memory leaks and crashes. The memory area management unit 12 automates this and performs a so-called memory release process of automatically recovering and releasing unnecessary memory during the execution of the program. With this mechanism, the user can concentrate on coding without being distracted by memory management.
[0019] The memory usage measurement unit 13 measures information related to the performance of the computer and, for example, corresponds to the performance monitor in Windows (registered trademark), etc. In this embodiment, the memory usage measurement unit 13 mainly measures the memory usage of the memory 11 used by each process.
[0020] The first process (dummy process) 111 gradually increases the memory usage amount used by its own process to cause the memory area management unit 12 to perform a memory release process. Since the memory release process is a high load, the memory area management unit 12 may not perform the memory release process when there is a margin in the memory capacity.
[0021] When there is no margin in the memory capacity, the memory area management unit 12 must perform the memory release process even if it is under high load, otherwise there will be a leak. Therefore, increasing the memory usage by the dummy process 111 will forcibly prompt the memory release process.
[0022] The memory usage measurement unit 13 also measures the memory usage of the second process (the process to be verified) 112, and stores the memory usage of the second process in the memory 11 in time series.
[0023] After the memory release process by the memory area management unit 12 is executed, the determination unit 14 acquires the memory usage of the process 112 to be verified before and after the memory release process from the memory 11. Then, the determination unit 14 compares the memory usage of the process 112 to be verified before and after the memory release process, and determines whether the memory area used by the process 112 to be verified has been released.
[0024] For example, if the memory usage of the process 112 to be verified after the memory release process is less than the memory usage of the process 112 to be verified before the memory release process, the determination unit 14 determines that no memory leak has occurred in the process 112 to be verified.
[0025] Also, if the memory usage of the process 112 to be verified after the memory release process is increased or unchanged compared to the memory usage of the process 112 to be verified before the memory release process, the determination unit 14 determines that the memory area used by the process 112 to be verified has not been released, and determines that a memory leak has occurred in the process 112 to be verified.
[0026] (Processing flow of the memory leak verification device 1) Figure 2 is a flowchart illustrating the processing procedure of a memory leak verification device 1 according to one embodiment of the present invention. First, a processor (not shown) executes a first process (dummy process) 111 (S11). Then, the first process (dummy process) 111 increases the memory usage (S12).
[0027] Next, the determination unit 14 determines whether or not the memory release process has been performed by the memory area management unit 12 (S13). If the memory release process has not been performed (S13, No), the process returns to step S12 and the subsequent processes are repeated.
[0028] Furthermore, if memory deallocation has been performed (S13, Yes), the memory usage measurement unit 13 measures the memory usage of the second process (the process under verification) 112 and stores the measured memory usage in memory 11 (S14).
[0029] Next, the determination unit 14 obtains and compares the memory usage of the second process (the process under verification) 112 from the memory 11 before and after the memory release process is performed (S15). If the memory usage of the second process 112 after the memory release process is reduced compared to the memory usage of the second process 112 before the memory release process is performed (S15, Yes), the determination unit 14 determines that no memory leak has occurred in the second process 112 (S16).
[0030] Furthermore, if the memory usage of the second process (the process under verification) 112 after the memory release process has been performed has not increased or changed compared to the memory usage of the second process 112 before the memory release process was performed (S15, No), the determination unit 14 determines that the memory area used by the second process 112 has not been released and that a memory leak has occurred in the second process 112 (S17).
[0031] Figure 3 illustrates the results of verifying whether or not a memory leak has occurred. In Figure 3, the horizontal axis represents time, and the vertical axis represents the memory usage of the process under verification (ProcMng) 112 or the dummy process 111. The solid line represents the memory usage of the dummy process 111, and the dotted line represents the memory usage of the process under verification 112.
[0032] As shown in Figure 3, the dummy process 111 gradually increases its memory usage to 1GB, 2GB, and 3GB. When the dummy process 111's memory usage reaches 2GB, the memory area management unit 12 performs a memory release process. As a result of this memory release process, the memory area used by the process under verification (ProcMng) 112 is released, and the memory usage of the process under verification 112 decreases. In this way, when the memory usage of the process under verification 112 decreases as a result of the memory release process, it is determined that no memory leak has occurred in the process under verification 112.
[0033] On the other hand, if the memory usage of process 112 under verification does not decrease despite memory release operations being performed, it is determined that a memory leak is occurring in process 112 under verification.
[0034] (Effects of Memory Leak Verification Device 1) As described above, according to the memory leak verification device 1 of this embodiment, the first process 111 gradually increases the memory usage and causes the memory area management unit 12 to perform a memory release process. Then, the determination unit 14 determines whether a memory leak has occurred in the second process 112 based on the memory usage of the second process 112 being verified, as measured by the memory usage measurement unit 13, in response to the memory release process.
[0035] Therefore, it is possible to verify whether or not a memory leak is occurring in a short period of time. Furthermore, this method is effective for processes where memory usage is low at the beginning of execution and gradually increases.
[0036] [Examples of implementation using software] The control block of the memory leak verification device 1 may be implemented by logic circuits (hardware) formed on an integrated circuit (IC chip) or the like, or by software.
[0037] In the latter case, the memory leak verification device 1 includes a computer that executes instructions for a program, which is software that implements each function. This computer includes, for example, one or more processors and a computer-readable recording medium that stores the program. The object of the present invention is achieved when the processor reads the program from the recording medium and executes it in the computer. For example, a CPU (Central Processing Unit) can be used as the processor. As the recording medium, a "tangible medium that is not temporary," such as ROM (Read Only Memory), can be used, as well as tape, disk, card, semiconductor memory, programmable logic circuit, etc. It may also further include RAM (Random Access Memory) for deploying the program. Furthermore, the program may be supplied to the computer via any transmission medium capable of transmitting the program (such as a communication network or broadcast wave). In one aspect of the present invention, the program can also be realized in the form of a data signal embedded in a carrier wave, which is embodied by electronic transmission.
[0038] 〔summary〕 A memory leak verification device according to embodiment 1 of the present invention comprises: a memory area management unit that manages memory areas used by multiple processes; a memory usage measurement unit that measures the memory usage of each of the multiple processes; a first process that gradually increases the memory usage and causes the memory area management unit to perform a memory release process; and a determination unit that determines whether a memory leak has occurred in a second process based on the memory usage of the second process to be verified, as measured by the memory usage measurement unit in response to the memory release process.
[0039] In the memory leak verification device according to aspect 2 of the present invention, in aspect 1, the determination unit determines that a memory leak has occurred in the second process if the memory area used by the second process is not released by the memory release process.
[0040] In the memory leak verification device according to embodiment 3 of the present invention, in embodiment 2, the determination unit compares the memory usage of the second process before and after the memory release process is performed to determine whether the memory area used by the second process has been released.
[0041] A memory leak verification method according to aspect 4 of the present invention includes the steps of: managing a memory area used by a plurality of processes; measuring the memory usage of each of the plurality of processes; gradually increasing the memory usage to cause a memory release process; and determining whether a memory leak has occurred in the second process based on the memory usage of the process to be verified measured in response to the memory release process.
[0042] The memory leak verification method according to aspect 5 of the present invention, in aspect 4 above, determines that a memory leak has occurred in the process under verification if the memory area used by the process under verification is not released by the memory release process in the determination step.
[0043] The memory leak verification method according to embodiment 6 of the present invention, in the determination step described in embodiment 5, compares the memory usage of the process under verification before and after the memory release process is performed to determine whether the memory area used by the process under verification has been released.
[0044] A program according to aspect 7 of the present invention causes a computer to perform the following: a process for managing a memory area used by multiple processes; a process for measuring the memory usage of each of the multiple processes; a process for gradually increasing the memory usage and performing a memory release process; and a process for determining whether a memory leak is occurring in the process under verification based on the memory usage of the process under verification measured in response to the memory release process.
[0045] In the program according to aspect 8 of the present invention, in the determination process described in aspect 7, if the memory area used by the process under verification is not released by the memory release process, it is determined that a memory leak has occurred in the process under verification.
[0046] In the program according to aspect 9 of the present invention, in the determination process described in aspect 8, the program compares the memory usage of the process under verification before and after the memory release process is performed to determine whether the memory area used by the process under verification has been released.
[0047] [Additional Notes] The present invention is not limited to the embodiments described above, and various modifications are possible within the scope of the claims. Embodiments obtained by appropriately combining the technical means disclosed in different embodiments are also included in the technical scope of the present invention. [Explanation of Symbols]
[0048] 1. Memory Leak Verification Device 11 memory 12 Memory Area Management Unit 13. Memory usage measurement unit 14 Judgment section 111 The First Process 112 Second Process
Claims
1. A memory area management unit that manages memory areas used by multiple processes, A memory usage measurement unit that measures the memory usage of each of the aforementioned multiple processes, A first process that gradually increases memory usage and causes the memory area management unit to perform memory release processing, A memory leak verification device comprising: a determination unit that determines whether a memory leak has occurred in a second process based on the memory usage of the second process to be verified, as measured by the memory usage measurement unit in response to the memory release process.
2. The determination unit determines that a memory leak has occurred in the second process if the memory area used by the second process is not released by the memory release process. The memory leak verification device according to claim 1.
3. The determination unit compares the memory usage of the second process before and after the memory release process is performed to determine whether the memory area used by the second process has been released. The memory leak verification device according to claim 2.
4. Steps to manage memory regions used by multiple processes, The steps include measuring the memory usage of each of the aforementioned multiple processes, The steps include gradually increasing memory usage to trigger memory release processing, A memory leak verification method comprising the step of determining whether a memory leak has occurred in the process under verification based on the amount of memory used by the process under verification measured in response to the memory release process.
5. In the determination step described above, if the memory area used by the process under verification is not released by the memory release process, it is determined that a memory leak has occurred in the process under verification. The memory leak verification method according to claim 4.
6. In the determination step, the memory usage of the process under verification before and after the memory release process is performed is compared to determine whether the memory area used by the process under verification has been released. The memory leak verification method according to claim 5.
7. On the computer, The process of managing memory regions used by multiple processes, A process for measuring the memory usage of each of the aforementioned multiple processes, A process that gradually increases memory usage and triggers memory release, A program that performs a process to determine whether a memory leak has occurred in the process under verification, based on the amount of memory used by the process under verification measured in response to the memory deallocation process.
8. In the process for making the determination, if the memory area used by the process under verification is not released by the memory release process, it is determined that a memory leak has occurred in the process under verification. The program according to claim 7.
9. In the process for making the determination, the memory usage of the process under verification before and after the memory release process is performed is compared to determine whether the memory area used by the process under verification has been released. The program according to claim 8.