CA2389168C - A method for garbage collection of unused methods - Google Patents

A method for garbage collection of unused methods Download PDF

Info

Publication number
CA2389168C
CA2389168C CA002389168A CA2389168A CA2389168C CA 2389168 C CA2389168 C CA 2389168C CA 002389168 A CA002389168 A CA 002389168A CA 2389168 A CA2389168 A CA 2389168A CA 2389168 C CA2389168 C CA 2389168C
Authority
CA
Canada
Prior art keywords
methods
regenerated
virtual machine
threads
computer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
CA002389168A
Other languages
French (fr)
Other versions
CA2389168A1 (en
Inventor
Joakim Dahlstedt
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oracle International Corp
Original Assignee
BEA Systems Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BEA Systems Inc filed Critical BEA Systems Inc
Publication of CA2389168A1 publication Critical patent/CA2389168A1/en
Application granted granted Critical
Publication of CA2389168C publication Critical patent/CA2389168C/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99951File or database maintenance
    • Y10S707/99956File allocation
    • Y10S707/99957Garbage collection

Abstract

A method for improving the effectiveness of a data processing application when using a virtual machine, wherein the program includes a large number of methods, i.e. program sections, that are stored in the memory of the computer used, and wherein the program uses a garbage collecting procedure. The invention is characterised by analysing in a first step all so called thread stacks with respect to the procedures required thereby; causing each of said requisite methods to be regenerated in a second step, wherein occurring references to a method prior to the regeneration are replaced with references to regenerated methods; and by erasing all non-regenerated methods in a third step and placing corresponding memory space at the disposal of the program.

Description

A METHOD FOR GARBAGE COLLECTION OF UNUSED METHODS
Field of the Invention The present invention relates to a method of improving the effectiveness of a data processing application.

More specifically, the invention is concerned with increasing the data processing rate in virtual machines, and then particularly with respect to the Java program language.

The invention is not restricted to Java, but can be applied with many program languages, although the invention is described below primarily with reference to Java.

The method is intended for use with adaptive optimisation of a program. In adaptive optimisation, the program is restructured and different parts of the program are optimised as the program is run. The general problem of increasing data processing capacity resides in the rapid creation of new memory sites, since the longer the program is run, the more memory space is required.
Related Art Java and other dynamic program languages include an automatic memory management.
This means that the programmer need not keep an account of those parts of the memory that are used. The virtual machine carries out a so-called garbage collection from time to time, meaning, in principle, that the virtual machine scans the entire memory and finds which objects have been stored in the memory and which the program can no longer address. These parts of the memory are returned for later use.

Java also includes methods for so called thread management methods. Thus, Java incorporates a system for supporting or simulating the simultaneous processing of two or more programs. The thread management can be divided into two parts. One part concerns the manner in which different threads are structured in a controlled manner.
Another part is concerned with which threads shall be run and which threads shall be passive and wait to be run.
In order to further increase effectiveness and place occupied memory space at the disposal of the program, it is not sufficient to solely optimise the memory with respect to the objects.
Summary of the Invention The present invention thus relates to a method of improving the effectiveness of a data processing application when using a virtual machine, where the program includes many methods, i.e. program sections, that are stored in the memory of the computer used, and where garbage collecting is used by said program, wherein the inventive method is characterised by a first step in which all so-called thread stacks are analysed with respect to methods required thereby; a second step in which each of the methods required is caused to be regenerated where occurrent references to a method are replaced with reference to regenerated methods prior to the regeneration of a method; and by a third step in which all non-regenerated methods are erased, wherein the corresponding memory space is placed at the disposal of said program.

Brief Description of the Drawings The present invention will now be described in more detail partly with reference to an exemplifying embodiment of the invention shown on to the accompanying drawing, in which -Figure 1 is a block diagram;
-Figure 2 illustrates old methods; and -Figure 3 illustrates methods regenerated in accordance with the invention.
Detailed Description of the Preferred Embodiments Figure 1 shows that a Java virtual machine, JVM, can be used to run different data programs 1, 2, 3, regardless of whether the operative system is WinNT, LINUX, Solaris or some other system. As mentioned above, although Java is a very popular program language, the present invention is not restricted to this language but can be applied to all object-orientated and platform-independent corresponding program languages.

The present invention thus relates to a method of improving the effectiveness of a data processing application when using a virtual machine, wherein the program includes a large number of methods, i. e. program sections, that are stored in the memory of the computer used, and wherein a garbage collecting process is used by the program.
It is previously known to garbage collect objects and therewith erase objects that are no longer in current use thereby placing corresponding memory capacity at disposal.

In large systems, many methods, i.e. program sections, are used one or a few times, or methods are applied for a short period of time and then left unused.

In the case of Java and corresponding programs, new methods are loaded and old methods left unused.
Furthermore, adaptive optimisation results in the optimisation and re-optimisation of methods placed in the memory, where old methods are left unused.

When optimising lock mechanism selection and garbage collection selection, it is necessary to replace all used methods that use old mechanisms with new mechanisms.
According to the invention, all so called thread stacks are analysed with respect to the methods required, in a first step of the inventive method. In a second step, each of the methods required is regenerated, where occurrent references to a method are replaced with references to regenerated methods prior to said regeneration. In a third step, all non-regenerated methods are erased and the corresponding memory space placed at the disposal of the program.

This procedure does not only clean-out unused methods, but also results in a reorganisation between those methods that have been regenerated, so as to direct references of the methods immediately to a regenerated method instead of proceeding via an old method that is no longer used.

This is illustrated in Figures 2 and 3, of which Figure 2 illustrates old methods and Figure 3 illustrates used regenerated methods. Three methods foo, apa and bar are shown in Figure 2. Foo starts on the memory address 4711. Apa starts on the address 4714 and bar starts on the address 4720.
Analysis of the thread stacks shows that only the methods foo and bar are used, and consequently foo and bar have not been referenced to the method apa.

The method foo and bar are regenerated to those methods illustrated in Figure 3. In this case, the methods foo and bar are recreated precisely, although with the difference that the methods obtain new addresses and that then the foo reference to bar points to the new bar address 4903.

All old methods, i.e. the methods in Figure 2, are erased and the memory spaces previously occupied by these methods are vacated for further use.

When garbage collection of objects takes place, running of the program normally stops while garbage collection takes place. Running of the program is restarted subsequent to the garbage collection and to the erasure of objects that are not in use.
Such a method can be used when applying the present invention.
However, it is very much preferred to use the following method instead.

When practicing the inventive method, one thread is stopped at a time whilst the program is running, wherewith methods used for a stopped thread are transferred to a list and the thread then restarted. The methods in the list are then regenerated and stored. All threads are later caused to be stopped at the same time, subsequent to having treated all threads in this way, namely so that all used methods relating to the threads concerned have been regenerated. All methods that have not been regenerated are erased and all threads are restarted with the regenerated methods.

This method obviates the need to stop running the program, since the regeneration takes place intermittently.
As before mentioned, lock mechanisms are used in Java and corresponding languages.
Different lock mechanisms can be selected. The important thing is to select the lock mechanism that is the most effective in preventing more than one thread having access to a given object at the same time as another thread.
A synchronisation problem exists when several threads desire access to one and the same object or source. In order to solve this problem in Java, each thread endeavours to reach the source lock. The source lock mechanism can be used in various ways. The effectiveness of different lock mechanisms will depend on how threads endeavour to obtain access to synchronised sources.

According to a preferred embodiment, when locking mechanisms are used the most effective locking mechanisms are identified in a step prior to said first step, and the methods that use a thus identified locking mechanism are regenerated.

With respect to garbage collecting algorithms, these also need to be selected.
Many object orientated languages use garbage collection. This means that the programmer need not instruct the system explicitly that a certain object is no longer required.
The system is responsible for this detection, and reclaims the part of the memory occupied by the object.
A number of different algorithms have been proposed for effective implementation of this detection and reclaim. It has been found that different algorithms are best for different applications. The choice of the best garbage collecting algorithm for the program application being run is highly significant in achieving maximum execution rate in respect of the program concerned.

According to another preferred embodiment of the invention, when different garbage collecting algorithms are used the allocation and length of life of the various objects are determined in a step prior to said first method step, whereafter the most effective garbage collecting algorithm is caused to be identified and the methods constituting the requisite garbage collecting algorithms are regenerated and remaining garbage collecting algorithms then erased.

Application of the preferred embodiments provides a highly effective method for optimising codes, threads and memory management, where a generic feature resides in the identification and regeneration of methods so as to not load the system with unused methods.

Claims (15)

THE EMBODIMENTS OF THE INVENTION IN WHICH AN EXCLUSIVE
PROPERTY OR PRIVILEGE IS CLAIMED ARE DEFINED AS FOLLOWS:
1. A process for optimizing distribution of software methods within the memory space of a computer system or virtual machine, wherein said virtual machine includes one or more threads, comprising the steps of:
determining, within a set of methods originally distributed within the memory space of said virtual machine, a selection of said methods to be regenerated, wherein said step of determining includes analyzing the thread stacks to determine those methods currently required by the threads;
creating regenerated methods, and replacing references to each method in the selection with references to the regenerated method, wherein said step of creating regenerated methods includes stopping the threads and recreating at an alternate memory address a copy of the methods required by that thread; and, erasing those methods that have not been regenerated, and releasing the portion of memory space occupied by the non-regenerated methods.
2. The process of claim 1 wherein the step of determining is used to determine an optimal locking mechanism to be used with the selection of methods.
3. The process of claim 1 wherein the step of erasing uses a stop and copy method of garbage collection.
4. The process of claim 1 wherein the step of erasing uses a mark and sweep method of garbage collection.
5. The process of claim 1 wherein the step of erasing uses a mark and compact method of garbage collection.
6. The process of claim 1 wherein the virtual machine is a component of an application server that comprises:
a computer machine including a processor;
an operating system for communicating between the computer machine and a virtual machine;

a virtual machine, including said original set of methods and said regenerated methods, and threads associated therewith; and, an application server for hosting applications that can use said original set of methods and said regenerated methods provided by the virtual machine.
7. A process for optimizing distribution of software methods within the memory space of a computer system or virtual machine, comprising the steps of:

determining within a set of methods originally present within the memory space a subset of said methods to be kept, said step of determining includes analyzing the threads to determine those methods currently required by the threads;
creating a copy of the subset of methods to be kept, and patching references to each original method in the subset to the new copy of that method; and, erasing all other methods and releasing the memory space occupied by the erased methods.
8. A computer readable memory containing instructions stored therein which when executed by a computer causes the computer to perform the steps of:
optimizing distribution of methods within a memory space of the computer or virtual machine, further comprising the steps of determining a selection of methods to be regenerated, wherein said step of determining includes analyzing threads to determine the methods currently required by the threads;

creating regenerated methods by recreating at alternate memory addresses the methods required by the threads, and replacing references to each method with references to the regenerated method; and, erasing all non-regenerated methods and releasing the memory space occupied by the non-regenerated methods.
9. The computer readable memory of claim 8 further comprising instructions for stopping the threads prior to recreating the methods, and restarting the threads subsequent to the methods being regenerated.
10. The computer readable memory of claim 8 wherein the step of determining is used to determine an optimal locking mechanism to be used with the method.
11. The computer readable memory of claim 8 wherein the step of erasing uses a stop and copy method of garbage collection.
12. The computer readable memory of claim 8 wherein the step of erasing uses a mark and sweep method of garbage collection.
13. The computer readable memory of claim 8 wherein the step of erasing uses a mark and compact method of garbage collection.
14. The computer readable memory of claim 8 wherein the virtual machine is a component of an application server that comprises:
a computer machine including a processor;
an operating system for communicating between the computer machine and a virtual machine;
a virtual machine, including a number of methods and threads associated therewith; and, an application server for hosting applications that can use the methods provided by the virtual machine.
15. A process for optimizing distribution of methods within the memory space of a computer system or virtual machine, comprising the steps of:
selecting, from a plurality of original methods, a set of methods to be regenerated;
regenerating the set of methods, including creating a new set of methods copied from the set to be regenerated, and replacing references to the original set of methods with corresponding references to the new set of methods; and erasing all methods in the plurality of original methods that were not regenerated, and releasing the portion of memory space occupied by the non regenerated methods.
CA002389168A 1999-10-28 2000-10-27 A method for garbage collection of unused methods Expired - Lifetime CA2389168C (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
SE9903890-3 1999-10-28
SE9903890A SE514318C2 (en) 1999-10-28 1999-10-28 Process for streamlining a data processing process using a virtual machine and using a garbage collection procedure
PCT/SE2000/002096 WO2001031455A1 (en) 1999-10-28 2000-10-27 A method for garbage collection of unused methods

Publications (2)

Publication Number Publication Date
CA2389168A1 CA2389168A1 (en) 2001-05-03
CA2389168C true CA2389168C (en) 2009-10-06

Family

ID=20417516

Family Applications (1)

Application Number Title Priority Date Filing Date
CA002389168A Expired - Lifetime CA2389168C (en) 1999-10-28 2000-10-27 A method for garbage collection of unused methods

Country Status (11)

Country Link
US (2) US7194494B1 (en)
EP (1) EP1240589B1 (en)
JP (1) JP4150518B2 (en)
KR (1) KR20020070270A (en)
CN (1) CN100382047C (en)
AT (1) ATE402443T1 (en)
AU (1) AU768181B2 (en)
CA (1) CA2389168C (en)
DE (1) DE60039628D1 (en)
SE (1) SE514318C2 (en)
WO (1) WO2001031455A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005018425A (en) * 2003-06-26 2005-01-20 Matsushita Electric Ind Co Ltd Program conversion method, program and storage medium
JP4569926B2 (en) * 2003-06-30 2010-10-27 パナソニック株式会社 Garbage collection system
EP1622009A1 (en) * 2004-07-27 2006-02-01 Texas Instruments Incorporated JSM architecture and systems
DE102007026693A1 (en) 2007-06-08 2008-12-11 Robert Bosch Gmbh Method and device for reorganizing data in a storage system, in particular for control devices in motor vehicles
CA2700217C (en) * 2010-04-01 2011-07-19 Ibm Canada Limited - Ibm Canada Limitee Write barrier elision for reference arrays
US10175998B2 (en) * 2016-07-31 2019-01-08 Oracle International Corporation Container-based language runtime loading an isolated method
CN114265670B (en) * 2022-03-02 2022-09-23 阿里云计算有限公司 Memory block sorting method, medium and computing device

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4797810A (en) * 1986-06-26 1989-01-10 Texas Instruments Incorporated Incremental, multi-area, generational, copying garbage collector for use in a virtual address space
US5088036A (en) * 1989-01-17 1992-02-11 Digital Equipment Corporation Real time, concurrent garbage collection system and method
US5293614A (en) * 1991-04-08 1994-03-08 Texas Instruments Incorporated System and method for hard real-time garbage collection requiring a write barrier but no read barrier
US5355483A (en) * 1991-07-18 1994-10-11 Next Computers Asynchronous garbage collection
DE69332696T2 (en) * 1992-06-15 2003-08-21 Microsoft Corp Computer method and system for memory management
US5692193A (en) * 1994-03-31 1997-11-25 Nec Research Institute, Inc. Software architecture for control of highly parallel computer systems
US6463581B1 (en) * 1996-10-03 2002-10-08 International Business Machines Corporation Method for determining reachable methods in object-oriented applications that use class libraries
US6041179A (en) * 1996-10-03 2000-03-21 International Business Machines Corporation Object oriented dispatch optimization
US5915255A (en) 1997-04-23 1999-06-22 Sun Microsystems, Inc. Method and apparatus for referencing nodes using links
US5873105A (en) * 1997-06-26 1999-02-16 Sun Microsystems, Inc. Bounded-pause time garbage collection system and method including write barrier associated with a source instance of a partially relocated object
ATE239253T1 (en) * 1997-12-19 2003-05-15 Microsoft Corp INCREMENTAL FREE MEMORY COLLECTOR
US6654951B1 (en) * 1998-12-14 2003-11-25 International Business Machines Corporation Removal of unreachable methods in object-oriented applications based on program interface analysis

Also Published As

Publication number Publication date
AU1563201A (en) 2001-05-08
EP1240589B1 (en) 2008-07-23
DE60039628D1 (en) 2008-09-04
ATE402443T1 (en) 2008-08-15
WO2001031455A1 (en) 2001-05-03
CN100382047C (en) 2008-04-16
SE9903890D0 (en) 1999-10-28
CA2389168A1 (en) 2001-05-03
KR20020070270A (en) 2002-09-05
US7194494B1 (en) 2007-03-20
US20070073794A1 (en) 2007-03-29
SE9903890L (en) 2001-02-12
JP2003513356A (en) 2003-04-08
AU768181B2 (en) 2003-12-04
EP1240589A1 (en) 2002-09-18
CN1402847A (en) 2003-03-12
JP4150518B2 (en) 2008-09-17
SE514318C2 (en) 2001-02-12

Similar Documents

Publication Publication Date Title
EP0881576B1 (en) Method and apparatus for generational garbage collection in a shared heap memory by means of multiple processor units
US8245239B2 (en) Deterministic runtime execution environment and method
US7650370B2 (en) System and method for regeneration of methods and garbage collection of unused methods
US7962707B2 (en) Apparatus and method for deterministic garbage collection of a heap memory
KR100541174B1 (en) Data processor with localised memory reclamation
US7263700B1 (en) Serially, reusable virtual machine
US6185581B1 (en) Train-algorithm-based garbage collector employing fixed-size remembered sets
US7024436B2 (en) Computer system with two heaps in contiguous storage
US7103723B2 (en) Priority-based code cache management
US6415302B1 (en) Train-algorithm-based garbage collector employing farthest-forward-car indicator
US7685182B2 (en) Interleaved garbage collections
JP3560535B2 (en) Method and system for detecting and coalescing free space during garbage collection
EP1560119B1 (en) Method and apparatus for adaptive garbage collection
US6804765B2 (en) Computer system with multiple heaps
US20050081190A1 (en) Autonomic memory leak detection and remediation
US20070073794A1 (en) Method for garbage collection of unused methods
US20020056019A1 (en) Computer system with heap reset
JP2003323336A (en) Heap memory control method and computer system using this method
WO2002054249A1 (en) Methods and apparatus for optimizing garbage collection
US8478738B2 (en) Object deallocation system and method
US8176286B2 (en) Memory recycling in computer systems
CN116339965A (en) Garbage recycling method and electronic equipment
Martin Garbage collection in java
Examination II Low Pause-Time Garbage Collection

Legal Events

Date Code Title Description
EEER Examination request
MKEX Expiry

Effective date: 20201027