# US 11,119,911 B2 · Garbage collection method and device

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

- Number: US 11,119,911 B2
- Document ID: US11119911B2
- Status: Granted
- Kind: B2
- Application number: 16/085,510
- Filed: 2017-03-07
- Published: 2019-06-27
- Granted: 2021-09-14
- Earliest claimed: 2016-03-17
- Assignees: Alibaba Group Holding Limited
- Applicants: Alibaba Group Holding Limited
- Inventors: Jie Zhang; Chen Zhang; Le He; Yingjie Shi; Yan Huang
- Web page: https://patentgrep.com/patent/US11119911B2

## CPC

- G06F 12/0253: {Garbage collection, i.e. reclamation of unreferenced memory}
- G06F 16/1727: {Details of free space management performed by the file system (saving storage space on storage systems G06F3/0608; management of blocks in storage devices G06F3/064)}
- G06F 2212/1044: Space efficiency improvement
- G06F 2212/702: Conservative garbage collection
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Heterogeneous garbage types are collected by scanning all of the service items to identify all of the service types that are included within the service items, identifying garbage collection components that correspond with the service types, and then collecting garbage for the corresponding target service types by using the corresponding garbage collection components.

## Claims

### Claim 1

A method of garbage collection comprising:
scanning all service items to generate a first list of scanned service items, the service items including applications stored on a storage media, each service item including one or more target service types, the first list of scanned service items including a number of target service types, the target service types including functions provided by the applications;
determining a number of target components such that each target service type has a corresponding target component, the number of target components including a number of garbage collecting logics such that each target component has a corresponding garbage collecting logic, each garbage collecting logic being different; and
collecting garbage for each target service type on the first list of scanned service items using the target component that corresponds with each target service type to collect heterogeneous garbage types.

### Claim 2 (depends on 1)

The method according to claim 1, further comprising obtaining a list of listed service types and a list of listed components for collecting garbage that corresponds with the list of listed service types such that each listed service type has a corresponding listed component for collecting garbage.

### Claim 3 (depends on 2)

The method according to claim 2, wherein determining a number of target components includes, for each target service type on the first list of scanned service items, matching a target service type to a listed service type on the first list of listed service types, and associating the listed component that corresponds with the listed service type with the target service type to generate a first list of target components for collecting garbage that corresponds with the target service types on the first list of scanned service items such that each target service type has a corresponding target component.

### Claim 4 (depends on 3)

The method according to claim 3, further comprising establishing a collection component that corresponds to all the service types having the same garbage collection logic, wherein all the service types having the same garbage collection logic share and reuse the corresponding collection component.

### Claim 5 (depends on 3)

The method according to claim 3, further comprising:
re-scanning all of the service items to generate a second list of scanned service items, the second list of scanned service items including a number of target service types;
determining if a target service type present on the second list of scanned service items is absent from the first list of scanned service items; and
for each new target service type present on the second list of scanned service items and absent from the first list of scanned service types,
matching a new target service type to a listed service type on the list of listed service types;
associating the listed component that corresponds with the listed service type with the new target service type as a new target component; and
adding the new target component to the first list of target components to generate a second list of target components for collecting garbage that corresponds with the target service types on the second list of scanned service items such that each target service type on the second list of scanned service items has a corresponding target component on the second list of target components.

### Claim 6 (depends on 3)

The method according to claim 3, further comprising:
re-scanning all of the service items to generate a second list of scanned service items, the second list of scanned service items including a number of target service types;
determining if a target service type present in the first list of scanned service items is absent from the second list of scanned service items; and
for each deleted target service type present on the first list of scanned service items and absent from the second list of scanned service items, determining if a deleted target service type shares a target component with any other target service type.

### Claim 7 (depends on 3)

The method according to claim 3, wherein collecting garbage for each target service type on the first list of scanned service items using the target components includes:
treating the target service types included in each service item as a task and allocating each task to all the corresponding target components;
loading all the corresponding target components;
allocating thread pools needed by each of the corresponding target components; and
starting the corresponding target components to use the allocated thread pools to execute the garbage collection logic to perform garbage collection for corresponding target service types.

### Claim 8 (depends on 7)

The method according to claim 7, further comprising, while collecting garbage for the corresponding target service types, monitoring a garbage collection progress and using the monitored garbage collection progress as a checkpoint.

### Claim 9 (depends on 8)

The method according to claim 8, further comprising, when a breakpoint occurs in the garbage collection process, performing breakpoint recovery by using the checkpoint closest to the breakpoint time.

### Claim 10

A garbage collection apparatus, comprising:
a memory; and
a processor coupled to the memory to execute instructions stored in the memory, the processor to:
scan all service items to generate a first list of scanned service items, the service items including applications stored on a storage media, each service item including one or more target service types, the first list of scanned service items including a number of target service types, the target service types including functions provided by the applications;
determine a number of target components such that each target service type has a corresponding target component, the number of target components including a number of garbage collecting logics such that each target component has a corresponding garbage collecting logic, each garbage collecting logic being different; and
collect garbage for each target service type on the first list of scanned service items using the target component that corresponds with each target service type to collect heterogeneous garbage types.

### Claim 11 (depends on 10)

The apparatus according to claim 10, wherein the processor to further obtain a list of listed service types and a list of listed components for collecting garbage that corresponds with the list of listed service types such that each listed service type has a corresponding listed component for collecting garbage.

### Claim 12 (depends on 11)

The apparatus according to claim 11, wherein to determine a number of target components, the processor to further, for each target service type on the first list of scanned service items, match a target service type to a listed service type on the first list of listed service types, and associate the listed component that corresponds with the listed service type with the target service type to generate a first list of target components for collecting garbage that corresponds with the target service types on the first list of scanned service items such that each target service type has a corresponding target component.

### Claim 13 (depends on 12)

The apparatus according to claim 12, wherein the processor to further:
re-scan all of the service items to generate a second list of scanned service items, the second list of scanned service items including a number of target service types;
determine if a target service type present in the second list of scanned service items is absent from the first list of scanned service items; and
for each new target service type present on the second list of scanned service items and absent from the first list of scanned service types,
match a new target service type to a listed service type on the list of listed service types;
associate the listed component that corresponds with the listed service type with the new target service type as a new target component; and
add the new target component to the first list of target components to generate a second list of target components for collecting garbage that corresponds with the target service types on the second list of scanned service items such that each target service type on the second list of scanned service items has a corresponding target component on the second list of target components.

### Claim 14 (depends on 12)

The apparatus according to claim 12, wherein the processor to further:
re-scan all of the service items to generate a second list of scanned service items, the second list of scanned service items including a number of target service types;
determine if a target service type present in the first list of scanned service items is absent from the second list of scanned service items; and
for each deleted target service type present on the first list of scanned service items and absent from the second list of scanned service items, determine if a deleted target service type shares a target component with any other target service type.

### Claim 15 (depends on 10)

The apparatus according to claim 10, further comprising:
a scanner, configured to obtain target service types comprised in all service items, wherein different service types correspond to different collection components;
a scheduler, configured to determine target collection components corresponding to each of the target service types; and
an executor, configured to collect garbage for the corresponding target service types by using each of the target collection components,
wherein the executor is further configured to establish corresponding collection components for different service types before the scanner obtains the service types comprised in all service items, wherein one service type corresponds to at least one collection component,
wherein the executor is specifically configured to establish a collection component that corresponds to all the service types having the same garbage collection logic, and respectively establish corresponding collection components for each of the other service types, wherein all the service types having the same garbage collection logic share and reuse the corresponding collection component.

### Claim 16 (depends on 15)

The apparatus according to claim 15, wherein the scanner is specifically configured to scan all the service items and generate a service item list based on a scanning result, wherein the service item list comprises the target service types comprised in all the service items.

### Claim 17 (depends on 16)

The apparatus according to claim 16, wherein the scheduler is specifically configured to do the following: after the scanner generates the service item list, judge whether a new target service type exists in the service item list; and when it is judged that a new target service type exists, obtain a new target collection component corresponding to the new target service type.

### Claim 18 (depends on 17)

The apparatus according to claim 17, wherein the scheduler is further specifically configured to do the following: when it is judged that no new target service type exists, obtain deleted target service types of each service item according to the service item list; judge whether the target collection component corresponding to the deleted target service type is shared and reused by other target service types in the service item list; delete the target collection component corresponding to the deleted service type when it is judged that the target collection component corresponding to the deleted service type is not shared and reused; determine corresponding target collection components for other target service types in the service item list, wherein the other target service types refer to target service types other than the new target service types and the deleted target service types in the service item list; and treat the target service types comprised in each service item as a task and allocate the tasks to the executor.

### Claim 19 (depends on 15)

The apparatus according to claim 15, wherein the executor is specifically configured to receive the tasks allocated by the scheduler, allocate the tasks to all the corresponding target collection components, load all the target collection components, allocate thread pools needed by the target collection components, and start the target collection components to use the allocated thread pools to execute the garbage collection logic to perform garbage collection for the corresponding target service types.

### Claim 20 (depends on 19)

The apparatus according to claim 19, further comprising:
a faulty processor, configured to do the following: in the process of using the target collection components to collect garbage for the corresponding target service types, monitor a garbage collection progress and using the monitored garbage collection progress as a checkpoint.

### Claim 21 (depends on 20)

The apparatus according to claim 20, wherein the faulty processor is further configured to perform, when a breakpoint occurs in the garbage collection process, breakpoint recovery by using the checkpoint closest to the breakpoint time.

### Claim 22

A non-transitory computer-readable storage medium having embedded therein program instructions, which when executed by a processor causes the processor to execute a method of unlocking a shared object, the method comprising:
scanning all service items to generate a first list of scanned service items, the service items including applications stored on a storage media, each service item including one or more target service types, the first list of scanned service items including a number of target service types, the target service types including functions provided by the applications;
determining a number of target components such that each target service type has a corresponding target component, the number of target components including a number of garbage collecting logics such that each target component has a corresponding garbage collecting logic, each garbage collecting logic being different; and
collecting garbage for each target service type on the first list of scanned service items using the target component that corresponds with each target service type to collect heterogeneous garbage types.

### Claim 23 (depends on 22)

The medium according to claim 22, wherein the method further comprises obtaining a list of listed service types and a list of listed components for collecting garbage that corresponds with the list of listed service types such that each listed service type has a corresponding listed component for collecting garbage.

### Claim 24 (depends on 23)

The medium according to claim 23, wherein determining a number of target components includes, for each target service type on the first list of scanned service items, matching a target service type to a listed service type on the first list of listed service types, and associating the listed component that corresponds with the listed service type with the target service type to generate a first list of target components for collecting garbage that corresponds with the target service types on the first list of scanned service items such that each target service type has a corresponding target component.

### Claim 25 (depends on 24)

The medium according to claim 24, wherein the method further comprises establishing a collection component that corresponds to all the service types having the same garbage collection logic, wherein all the service types having the same garbage collection logic share and reuse the corresponding collection component.

### Claim 26 (depends on 24)

The medium according to claim 24, wherein the method further comprises:
re-scanning all of the service items to generate a second list of scanned service items, the second list of scanned service items including a number of target service types;
determining if a target service type present in the second list of scanned service items is absent from the first list of scanned service items; and
for each new target service type present on the second list of scanned service items and absent from the first list of scanned service types,
matching a new target service type to a listed service type on the list of listed service types;
associating the listed component that corresponds with the listed service type with the new target service type as a new target component; and
adding the new target component to the first list of target components to generate a second list of target components for collecting garbage that corresponds with the target service types on the second list of scanned service items such that each target service type on the second list of scanned service items has a corresponding target component on the second list of target components.

### Claim 27 (depends on 24)

The medium according to claim 24, wherein the method further comprises:
re-scanning all of the service items to generate a second list of scanned service items, the second list of scanned service items including a number of target service types;
determining if a target service type present in the first list of scanned service items is absent from the second list of scanned service items; and
for each deleted target service type present on the first list of scanned service items and absent from the second list of scanned service items, determining if a deleted target service type shares a target component with any other target service type.
