# US 2012/0254838 A1 · Method and apparatus for tracing memory accesses

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

- Number: US 2012/0254838 A1
- Document ID: US20120254838A1
- Status: Published application
- Kind: A1
- Application number: 13/433,125
- Filed: 2012-03-28
- Published: 2012-10-04
- Earliest claimed: 2011-03-29
- Assignees: International Business Machines Corporation
- Inventors: Zhi Da Luo; Wei Liu
- Web page: https://patentgrep.com/patent/US20120254838A1

## CPC

- G06F 11/3476: {Data logging (G06F11/14, G06F11/2205 take precedence)}
- G06F 11/3636: {by tracing the execution of the program}
- G06F 11/3644: {by instrumenting at runtime}
- G06F 2201/865: Monitoring of software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Apparatus, computer-readable storage medium and a method executed by a computer for tracing the memory accesses of an object-oriented program comprises assigning a unique identification to each class object created from at least one class in the object-oriented program by modifying a class definition of the at least one class. In response to an unloading of one of the class objects, obtaining class unloading related information from a runtime environment of the object-oriented program and obtaining the unique identification of the unloaded class object according to the returned information. Then releasing memory space assigned to the unloaded class object for storing the memory access information of the unloaded class object.

## Claims

### Claim 1

A method executed by a computer for tracing the memory accesses of an object-oriented program, comprising:
assigning a unique identification to each class object created from at least one class in the object-oriented program by modifying a class definition of the at least one class;
in response to an unloading of one of the class objects, obtaining class unloading related information from a runtime environment of the object-oriented program and obtaining the unique identification of the unloaded class object according to the returned information; and
releasing memory space assigned to the unloaded class object for storing the memory access information of the unloaded class object.

### Claim 2 (depends on 1)

The method of claim 1, wherein the assigning a unique identification to each class object further comprises
adding an objectID data member to the definition of the at least one class, and
using an object method to assign a unique value of objectID to each object created from the at least one class.

### Claim 3 (depends on 2)

The method of claim 2, wherein said assigning a unique value of objectID further comprises one of the following methods:
setting the value of objectID as equal to a counter value in the program, wherein said counter value increases along with the class loading;
setting the value of objectID as equal to the loading time of the class;
setting the value of objectID as equal to UUID generated by the system.

### Claim 4 (depends on 1)

The method of claim 1, wherein said obtaining the unique identification of an unloaded class object comprises:
creating a weak reference object corresponding to the unloaded class object before it is unloaded;
setting an objectID of the weak reference object equal to the unique identification of said unloaded class object before it is unloaded;
adding the weak reference object to a reference queue;
calling a remove( )method in the reference queue to request the runtime environment to return the class unloading related information of the class object when the corresponding object class is unloaded and
obtaining the unique identification of the weak reference object returned from the runtime environment, to identify the unloaded class object.

### Claim 5 (depends on 1)

The method of claim 1, wherein said releasing the memory space for storing the memory access information of the unloaded class object further comprises removing the memory access information related to said unloaded class object.

### Claim 6

An apparatus for tracing memory accesses of an object-oriented program, comprising:
a code modifying unit, configured to assign a unique identification to each class object created from at least one class in the object-oriented program by modifying a class definition of the at least one class; and
a class unloading tracing unit, configured to request class object unloading related information from the runtime environment when one of the class objects is unloaded, obtain the unique identification of the unloaded class object according to the returned information, and release memory space assigned for storing memory access information of the unloaded class object.

### Claim 7 (depends on 6)

The apparatus of claim 6, wherein said code modifying unit is configured to add a data member objectID to said class definition, and to set the objectID in each class object created from the class definition to a unique identification.

### Claim 8 (depends on 7)

The apparatus of claim 7, wherein said code modifying unit is configured to execute one of the following functions:
setting objectID in each class object created from the class definition as equal to a counter value, wherein the counter value is incremented with each creation of a class object;
setting objectID in each class object created from the class definition as equal to the loading time of the class;
setting the value of objectID in each class object created from the class definition as equal to UUID generated by the system.

### Claim 9 (depends on 6)

The apparatus of claim 6, wherein said class unloading tracing unit is configured to:
create a weak reference object corresponding to an unloaded class object before it is unloaded;
set an objectID of the weak reference object equal to the unique identification of said unloaded class object before it is unloaded;
call a remove( ) method in the reference queue to request the runtime environment to return the class unloading related information of the class object when the corresponding object class is unloaded and
obtain the unique identification of the weak reference object returned from the runtime environment to identify the unloaded class object.

### Claim 10 (depends on 6)

The apparatus of claim 6, wherein said class unloading tracing unit is configured to release the memory space for storing the memory access information of the unloaded class object.

### Claim 11

A computer-readable storage medium having nontransitory program code executed by a computer for tracing the memory accesses of an object-oriented program, comprising:
program code for assigning a unique identification to each class object created from at least one class in the object-oriented program by modifying a class definition of the at least one class;
program code responsive to an unloading of one of the class objects, for obtaining class unloading related information from a runtime environment of the object-oriented program and obtaining the unique identification of the unloaded class object according to the returned information; and
program code for releasing memory space assigned to the unloaded class object for storing the memory access information of the unloaded class object.

### Claim 12 (depends on 11)

The computer-readable storage medium of claim 11, wherein the program code for assigning a unique identification to each class object further comprises
program code for adding an objectID data member to the definition of the at least one class, and
program code for using an object method to assign a unique value of objectID to each object created from the at least one class.

### Claim 13 (depends on 12)

The computer-readable storage medium of claim 12, wherein the program code for assigning a unique value of objectID further comprises one of the followings:
program code for setting the value of objectID as equal to a counter value in the program, wherein said counter value increases along with the class loading;
program code for setting the value of objectID as equal to the loading time of the class;
program code for setting the value of objectID as equal to UUID generated by the system.

### Claim 14 (depends on 11)

The computer-readable storage medium of claim 11, wherein said the program code for obtaining the unique identification of an unloaded class object further comprises:
program code for creating a weak reference object corresponding to the unloaded class object before it is unloaded;
program code for setting an objectID of the weak reference object equal to the unique identification of said unloaded class object before it is unloaded;
program code for adding the weak reference object to a reference queue;
program code for calling a remove( ) method in the reference queue to request the runtime environment to return the class unloading related information of the class object when the corresponding object class is unloaded and
program code for obtaining the unique identification of the weak reference object returned from the runtime environment, to identify the unloaded class object.

### Claim 15 (depends on 11)

The computer-readable storage medium of claim 11, wherein the program code for releasing the memory space for storing the memory access information of the unloaded class object further comprises program code for removing the memory access information related to said unloaded class object.
