# US 9,355,029 B2 · Thread-based memory management with garbage collection

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

- Number: US 9,355,029 B2
- Document ID: US9355029B2
- Status: Granted
- Kind: B2
- Application number: 13/930,931
- Filed: 2013-06-28
- Published: 2015-01-01
- Granted: 2016-05-31
- Earliest claimed: 2013-06-28
- Assignees: Sap SE
- Applicants: Sap SE
- Inventors: Martin Moser
- Web page: https://patentgrep.com/patent/US9355029B2

## CPC

- G06F 12/0253: {Garbage collection, i.e. reclamation of unreferenced memory}
- G06F 12/023: {Free address space management}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods for thread-based memory management may include activating a processing thread. The memory may include a first region and a second region with the first region having several segments. A segment of memory may be allocated for the processing thread. Data associated with an object may be stored in the segment. At the end of processing by the processing thread, a garbage collection process may be performed by the processing thread on the segment allocated to the processing thread.

## Claims

### Claim 1

A computer-implemented method for managing the allocation of memory comprising:
activating a processing thread;
allocating memory for the processing thread, wherein the allocated memory includes a first region having a plurality of segments;
determining if data associated with an object utilized by the processing thread is to be stored in the first region of the allocated memory;
determining if the data associated with the object can be stored in a first segment of the plurality of segments;
storing the data associated with the object in the first segment in response to the determination that the data associated with the object can be stored in the first segment; and
the processing thread including code performing a garbage collection process on the allocated first segment prior to termination of the processing thread.

### Claim 2 (depends on 1)

The method of claim 1 further comprising:
allocating a second segment of the plurality of segments in response to a determination that the data associated with the object cannot be stored in the first segment;
dividing the data associated with the object into a first portion of the data associated with the object and a second portion of the data associated with the object; and
storing the first portion of the data associated with the object in the first segment and storing the second portion of the data associated with the object in the second segment of the plurality of segments.

### Claim 3 (depends on 2)

The method of claim 2 further comprising:
determining if a number of segments allocated to the processing thread exceed a predetermined value.

### Claim 4 (depends on 3)

The method of claim 3 further comprising:
performing a garbage collection process on the first segment and the second segments if the number of segments allocated to the processing thread exceed the predetermined value.

### Claim 5 (depends on 3)

The method of claim 3 further comprising:
terminating the processing thread if the number of segments allocated to the processing thread exceed the predetermined value.

### Claim 6 (depends on 1)

The method of claim 1 further comprising:
determining if the data associated with the object can be stored in a second region of the allocated memory if the data associated with the object cannot be stored in the first region;
allocating the portion of the second region for storing the data associated with the object in response to the determination that the data associated with the object can be stored in the second region and in response to the determination that the data associated with the object cannot be stored in the first region; and
storing the data associated with the object at the allocated portion of the second region in response to the determination that the data associated with the object cannot be stored in the first region.

### Claim 7 (depends on 1)

The method of claim 1 further comprising:
determining if the data associated with the object can be stored in a portion of a second region of the allocated memory in response to the determination that the data associated with the object cannot be stored in the first segment; and
the processing thread performing a garbage collection process on a portion of the second region if the data associated with the object cannot be stored in the second region.

### Claim 8 (depends on 7)

The method of claim 7 further comprising:
determining if the data associated with the object can be stored in a portion of the second region after the garbage collection process;
allocating the portion of the second region for storing the data associated with the object in response to the determination that the data associated with the object can be stored in the portion; and
storing the data associated with the object at the allocated portion of the second region.

### Claim 9 (depends on 1)

The method of claim 1, wherein the garbage collection process is a mark and sweep process.

### Claim 10 (depends on 1)

The method of claim 1, wherein the garbage collection process is a copying collection process.

### Claim 11

A system comprising:
a memory having a first region that includes a plurality of segments; and
a storage device storing instructions that, when executed by a processing module of the system, cause the processing module to perform operations comprising:
activating a processing thread;
allocating a first segment of the plurality of segments for the processing thread,
determining if data associated with an object is to be stored in the memory,
determining if the data associated with the object can be stored in the allocated first segment,
determining if the plurality of segments has an allocatable second segment in response to the determination that the data associated with the object cannot be stored in the allocated first segment,
if the data associated with the object cannot be stored in the allocated first segment and the first region has an allocatable second segment:
allocating the second segment of the plurality of segments for the processing thread, and
storing the data associated with the object at the allocated portion of the second segment, and
the processing thread including code performing a garbage collection process on the first segment and the second segment prior to termination of the processing thread.

### Claim 12 (depends on 11)

The system of claim 11, wherein the operations further comprise:
determining if a number of segments allocated to the processing thread exceed a predetermined value.

### Claim 13 (depends on 12)

The system of claim 12, wherein the operations further comprise:
performing a garbage collection process on the first segment and the second segment if the number of segments allocated to the processing thread exceed the predetermined value.

### Claim 14 (depends on 12)

The system of claim 12, wherein the operations further comprise:
terminating the processing thread if the number of segments allocated to the processing thread exceed the predetermined value.

### Claim 15 (depends on 11)

The system of claim 11, wherein the operations further comprise:
if the data associated with the object cannot be stored in the allocated first segment and the first region does not have an allocatable second segment:
determining if the data associated with the object can be stored in a second region of the memory,
allocating the portion of the second region for storing the data associated with the object, and
storing the data associated with the object at the allocated portion of the second region.

### Claim 16

A non-transitory computer-readable storage device storing instructions that, when executed by a processing module, cause the processing module to perform operations comprising:
activating a processing thread;
allocating a memory for the processing thread, wherein the allocated memory includes a first region having a plurality of segments to store data for objects to be created during the processing performed by the processing thread;
storing data associated with an object in a first segment of the plurality of segments;
the processing thread including code performing a garbage collection process on the plurality of segments prior to termination of the processing thread; and
releasing the plurality of segments.

### Claim 17 (depends on 16)

The non-transitory computer-readable storage device of claim 16, storing instructions to perform operations further comprising:
determining if a number of segments of the plurality of segments allocated to the processing thread exceed a predetermined value; and
terminating the processing thread if the number of segments of the plurality of segments allocated to the processing thread exceed the predetermined value.

### Claim 18 (depends on 16)

The non-transitory computer-readable storage device of claim 16, storing instructions to perform operations further comprising:
determining if data associated with a second object can be stored in the plurality of segments,
if the data associated with a second object cannot be stored in the plurality of segments:
determining if the data associated with the second object can be stored in a portion of a second region of the allocated memory,
allocating the portion of the second region for storing the data associated with the second object, and
storing the data associated with the second object at the allocated portion of the second region.

### Claim 19 (depends on 16)

The non-transitory computer-readable storage device of claim 16, wherein the plurality of segments of the memory for the processing thread are automatically allocated by a runtime system.

### Claim 20 (depends on 19)

The non-transitory computer-readable storage device of claim 19, wherein the runtime system is a Java® runtime system.
