# US 12,217,074 B2 · Selective injection of GC safepoints for JNI invocations

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,217,074 B2
- Document ID: US12217074B2
- Status: Granted
- Kind: B2
- Application number: 17/082,250
- Filed: 2020-10-28
- Published: 2022-04-28
- Granted: 2025-02-04
- Earliest claimed: 2020-10-28
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Michihiro Horie; Kazunori Ogata; Hiroshi Horii
- Web page: https://patentgrep.com/patent/US12217074B2

## CPC

- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 8/4434: {Reducing the memory space required by the program code}
- G06F 9/45504: {Abstract machines for program code execution, e.g. Java virtual machine [JVM], interpreters or emulators}
- G06F 9/5077: {Logical partitioning of resources; Management or configuration of virtualized resources (specific details on emulation or internal functioning of virtual machines G06F9/455)}
- G06F 12/0253: {Garbage collection, i.e. reclamation of unreferenced memory}
- G06F 12/0269: {Incremental or concurrent garbage collection, e.g. in real-time systems (G06F12/0261 takes precedence)}
- G06F 2009/45575: {Starting, stopping, suspending or resuming virtual machine instances}
- G06F 2009/45583: {Memory management, e.g. access or allocation}
- G06F 2009/45591: {Monitoring or debugging support}
- G06F 2209/5022: Workload threshold
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented method is provided for managing Garbage Collection (GC) safepoints. The method includes determining whether a GC safepoint for a target native method can be removed by checking a heap occupancy ratio prior to executing the target native method. The method further includes removing the GC safepoint responsive to the heap occupancy ratio prior to executing the target native method being less than a threshold occupancy amount percentage. The method also includes determining whether the GC safepoint for the target native method can be removed by checking a most recent GC pause time. The method additionally includes removing the GC safepoint responsive to the most recent GC pause time being shorter by a threshold pause time amount percentage than an execution time of the target native method.

## Claims

### Claim 1

A computer-implemented method for managing Garbage Collection (GC) safepoints in a Virtual Machine (VM), comprising:
removing a GC safepoint responsive to any of low GC frequency conditions based on (i) a heap occupancy ratio, determined by calculating a proportion of used memory to total available heap memory, prior to executing a target native method being less than a threshold occupancy amount percentage and (ii) a most recent GC pause time being shorter by a threshold pause time amount percentage than an execution time of the target native method; and
reducing operational interruptions and latency caused by utilizing full memory fences at the GC safepoint by performing garbage collection with the GC safepoint under high GC frequency conditions, as conditions other than low GC frequency conditions, determined to enhance performance of an application, and removing low GC frequency safepoints determined to be unnecessary to avoid utilization of the full memory fences that degrade performance of the application, the removing low GC frequency safepoints being executed by the VM automatically based on the heap occupancy ratio and the most recent GC pause time.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the threshold occupancy amount percentage is modifiable via a virtual machine parameter at virtual machine startup.

### Claim 3 (depends on 1)

The computer-implemented method of claim 1, wherein the threshold pause time amount percentage is modifiable via a virtual machine parameter at virtual machine startup.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, further comprising setting the threshold occupancy amount and the threshold pause time amount via respective virtual machine parameters at virtual machine startup.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, wherein the threshold occupancy amount is set to seventy percent.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1, wherein the threshold pause time amount is set to ten percent.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, further comprising recording, by a virtual machine, an elapsed time of the target native method when the target native method is initially invoked, and repeating the method for later invocations of the target native method.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, further comprising restricting garbage collection from being performed responsive to the heap occupancy ratio prior to executing the target native method being less than the threshold occupancy amount percentage.

### Claim 9 (depends on 1)

The computer-implemented method of claim 1, further comprising determining whether the GC safepoint for the target native method can be removed by checking the most recent GC pause time responsive to the heap occupancy ratio prior to executing the target native method being any of equal to and greater than a threshold occupancy amount percentage.

### Claim 10

A computer program product for managing Garbage Collection (GC) safepoints in a Virtual Machine (VM), the computer program product comprising a non-transitory computer readable storage medium having program instructions embodied therewith, the program instructions executable by a computer to cause the computer to perform a method comprising:
removing, by a hardware processor of the computer, a GC safepoint responsive to any of low GC frequency conditions based on (i) a heap occupancy ratio, determined by calculating a proportion of used memory to total available heap memory. prior to executing a target native method being less than a threshold occupancy amount percentage and (ii) a most recent GC pause time being shorter by a threshold pause time amount percentage than an execution time of the target native method; and
reducing operational interruptions and latency caused by utilizing full memory fences at the GC safepoint by performing, by the hardware processor, garbage collection with the GC safepoint under high GC frequency conditions, as conditions other than low GC frequency conditions, determined to enhance performance of an application, and removing low GC frequency safepoints determined to be unnecessary to avoid utilization of the full memory fences that degrade performance of the application, the removing low GC frequency safepoints being executed by the VM automatically based on the heap occupancy ratio and the most recent GC pause time.

### Claim 11 (depends on 10)

The computer program product of claim 10, wherein the threshold occupancy amount percentage is modifiable via a virtual machine parameter at virtual machine startup.

### Claim 12 (depends on 10)

The computer program product of claim 10, wherein the threshold pause time amount percentage is modifiable via a virtual machine parameter at virtual machine startup.

### Claim 13 (depends on 10)

The computer program product of claim 10, wherein the method comprises setting the threshold occupancy amount and the threshold pause time amount via respective virtual machine parameters at virtual machine startup.

### Claim 14 (depends on 10)

The computer program product of claim 10, wherein the threshold occupancy amount is set to seventy percent.

### Claim 15 (depends on 10)

The computer program product of claim 10, wherein the threshold pause time amount is set to ten percent.

### Claim 16 (depends on 10)

The computer program product of claim 10, wherein the method comprises recording, by virtual machine, an elapsed time of the target native method when the target native method is initially invoked, and repeating the method for later invocations of the target native method.

### Claim 17 (depends on 10)

The computer program product of claim 10, wherein the method comprises restricting garbage collection from being performed responsive to the heap occupancy ratio prior to executing the target native method being less than the threshold occupancy amount percentage.

### Claim 18 (depends on 10)

The computer program product of claim 10, further comprising determining whether the GC safepoint for the target native method can be removed by checking the most recent GC pause time responsive to the heap occupancy ratio prior to executing the target native method being any of equal to and greater than a threshold occupancy amount percentage.

### Claim 19

A computer processing system for managing Garbage Collection (GC) safepoints in a Virtual Machine (VM), comprising:
a memory device for storing program code; and
a processor device operatively coupled to the memory device for running the program code to remove a GC safepoint responsive to any of low GC frequency conditions based on (i) a heap occupancy ratio, determined by calculating a proportion of used memory to total available heap memory, prior to executing a target native method being less than a threshold occupancy amount percentage and (ii) a most recent GC pause time being shorter by a threshold pause time amount percentage than an execution time of the target native method; and
reducing operational interruptions and latency caused by utilizing full memory fences at the GC safepoint by performing garbage collection with the GC safepoint under high GC frequency conditions, as conditions other than low GC frequency conditions, determined to enhance performance of an application, and removing low GC frequency safepoints determined to be unnecessary to avoid utilization of the full memory fences that degrade performance of the application, the removing low GC frequency safepoints being executed by the VM automatically based on the heap occupancy ratio and the most recent GC pause time.

### Claim 20 (depends on 19)

The computer processing system of claim 19, wherein any of the threshold occupancy amount percentage and the threshold pause time amount percentage are modifiable via a respective virtual machine parameter at virtual machine startup.
