KR20030094658A - Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program - Google Patents

Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program Download PDF

Info

Publication number
KR20030094658A
KR20030094658A KR1020020031900A KR20020031900A KR20030094658A KR 20030094658 A KR20030094658 A KR 20030094658A KR 1020020031900 A KR1020020031900 A KR 1020020031900A KR 20020031900 A KR20020031900 A KR 20020031900A KR 20030094658 A KR20030094658 A KR 20030094658A
Authority
KR
South Korea
Prior art keywords
dynamic memory
application
collection
location
version
Prior art date
Application number
KR1020020031900A
Other languages
Korean (ko)
Inventor
이승룡
배수강
Original Assignee
이승룡
배수강
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 이승룡, 배수강 filed Critical 이승룡
Priority to KR1020020031900A priority Critical patent/KR20030094658A/en
Publication of KR20030094658A publication Critical patent/KR20030094658A/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE: A method for directly managing a dynamic memory by an application on an automated dynamic memory management based system environment is provided to realize an API(Application Programming Interface) method to directly collect a garbage object on the dynamic memory and a VM(Virtual Machine) supporting the API. CONSTITUTION: The method to collect the object no more used by the application is transferred to the system(220). In case that the system has no function to collect the selected object, the system transfers an exceptional object related to an error to the application and ignores a collection request when the collection of the dynamic memory or the object is definitely requested(211). In case that the collection method executing exceptional object is not transferred to the application, the selected object is definitely collected from the dynamic memory(231-233).

Description

자동화된 동적 메모리 관리 기반의 시스템 환경에서 어플리케이션이 직접 동적 메모리를 관리하는 방법{Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program}Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program

본 발명은 컴퓨터 환경에서 런타임 시스템의 동적 메모리를 어플리케이션이 명시적으로 관리하는 방법에 관한 것으로서, 더욱 상세하게는 자동화된 동적 메모리 기반의 런타임 시스템에서 종전의 자동화된 객체 수거 방식은 그대로 유지하면서 어플리케이션에 의해 직접 객체를 수거할 수 있는 방법을 제공함으로써 이러한 시스템에서의 성능 향상을 제공한다. 또한, 객체가 저장된 동적 메모리의 객체 정보 영역에 동일한 위치버전을 저장하고 이것을 객체참조변수 영역에 복사하여 어플리케이션이 상기의 객체를 이용 또는 접근 시에 양자의 위치버전을 비교 판단하여 그 이용여부를 허가하도록 함으로써 시스템의 안전성을 도모한다.The present invention relates to a method in which an application explicitly manages a dynamic memory of a runtime system in a computer environment, and more particularly, to an application while maintaining a conventional automated object collection method in an automated dynamic memory-based runtime system. It provides a performance improvement in these systems by providing a way to collect objects directly. In addition, the same location version is stored in the object information area of the dynamic memory in which the object is stored and copied to the object reference variable area so that the application compares the location versions of the object when using or accesses the object and permits the use thereof. By doing so, the system is secured.

컴퓨터 시스템에서 메모리는 크게 정적 메모리와 동적 메모리로 나눌 수 있는데, 이 중 동적 메모리는 다시 명시적 동적 메모리 관리와 자동화된 동적 메모리 관리로 나눌 수 있다. 명시적 동적 메모리 관리의 예는 C에서의 malloc() 함수나 farmalloc() 함수 등의 할당 관련 함수와 free() 함수의 수거 함수 등이 있다. 이들은 모두 프로그래머에 의해 명시적으로 이루어진다. 이 것의 장점은 메모리 활용의 최적화를 이룰 수 있는 반면 프로그래머가 신중하게 동적 메모리를 관리하여야 한다는 단점이 있다. 만약 관리를 제대로 해주지 않게 되면 시스템 전체에 악영향을 끼칠 수도 있기 때문이다. 한편, 자동화된 동적 메모리 관리 기법에는 주로 쓰레기 수집(Garbage Collection) 기법이 활용되고 있다. 이 기법의 장점은 프로그래머가 동적 메모리의 관리에 대하여 전혀 신경을 쓰지 않더라도 쓰레기 수집 알고리즘에 따라 앞으로 사용 가능성이 있는 객체는 보존해주고 사용 가능성이 없는 객체는 자동적으로 수거하기 때문에 프로그램의 생산성을 향상시켜주는 장점이 있다. 반면에 프로그램의 물리적인 현상만을 고려하고 있기 때문에 프로그램의 논리적인 수행 측면에서 본 어떤 객체의 보존 및 수거를 정확히 판단할 수는 없다. 즉, 동적 메모리 효율성이 100%는 도달할 수 없다는 것이다. 따라서 본 제안에서는 자동화된 동적 메모리 기법을 기반으로 한 명시적인 동적 메모리 관리 기법 즉, 하이브리드형 동적 메모리 관리 기법을 제시한다.In computer systems, memory can be largely divided into static memory and dynamic memory, of which dynamic memory can be divided into explicit dynamic memory management and automated dynamic memory management. Examples of explicit dynamic memory management include allocation-related functions such as malloc () and farmalloc () functions in C, and collection functions of the free () function. These are all done explicitly by the programmer. The advantage of this is that it can optimize memory utilization while the programmer has to manage dynamic memory carefully. If not properly managed, it may adversely affect the whole system. Meanwhile, Garbage Collection is mainly used for automated dynamic memory management. The advantage of this technique is that even if the programmer does not care at all about dynamic memory management, the garbage collection algorithm improves the productivity of the program by preserving future objects and automatically collecting unusable objects. There is an advantage. On the other hand, since it considers only the physical phenomena of the program, it is not possible to accurately determine the preservation and collection of any object from the logical execution of the program. In other words, the dynamic memory efficiency cannot reach 100%. Therefore, this paper proposes an explicit dynamic memory management scheme based on automated dynamic memory scheme, that is, a hybrid dynamic memory management scheme.

자동화된 동적 메모리 관리 기법을 이용하고 있는 자바 환경을 예로 들도록 하겠다. 수많은 객체 지향형 프로그래밍 언어 중에서도 특히 자바(JAVA)는 특별히 인터넷의 분산환경에서 사용되도록 설계된 프로그래밍 언어이다. 자바는 한 대의 컴퓨터뿐만 아니라 네트웍 상의 분산 클라이언트/서버 환경에서도 실행되는 어플리케이션 프로그램을 만드는데 모두 사용될 수 있어, 사용자가 만드는 프로그램들은 네트웍 상에서 쉽게 이식이 가능하다. 이를 위하여, 사용자가 개발한 어플리케이션 프로그램은 자바 가상머신이 설치된 서버나 클라이언트 등 어떠한 플랫폼에서든지 실행될 수 있도록 자바 바이트코드로 컴파일된다. 자바 가상머신은 이러한 바이트코드를 런타임 시스템의 하드웨어 상에서 실행될 수 있는 코드로 해석하고 그 내용을 수행한다. 이것은 명령어의 길이 등 개별 컴퓨터 플랫폼간의 차이가 인식되고,프로그램이 실행되고 있는 바로 그 위치에서 국부적으로 조정될 수 있다는 것을 의미한다. 즉, 자바 가상머신이 일단 한 플랫폼에 제공되면, 바이트코드라고 불리는 어떠한 자바 프로그램도 그 플랫폼에서 실행될 수 있다. 따라서 자바는 응용프로그램들이 각각의 플랫폼에 맞게 재작성 되거나, 다시 컴파일하지 않아도 모든 플랫폼에서 실행되는 것을 허용하도록 설계된 것이다.For example, consider a Java environment that uses automated dynamic memory management. Among many object-oriented programming languages, JAVA is a programming language specifically designed for use in the distributed environment of the Internet. Java can be used to create application programs that run not only on a single computer, but also on distributed client / server environments on the network, so user-written programs can be easily ported over the network. To this end, user-developed application programs are compiled into Java bytecode to run on any platform, such as a server or client with a Java virtual machine installed. The Java virtual machine interprets this bytecode into code that can be executed on the hardware of the runtime system and executes the contents. This means that differences between individual computer platforms, such as the length of instructions, can be recognized and adjusted locally at the exact location where the program is running. That is, once a Java virtual machine is provided on a platform, any Java program called bytecode can run on that platform. Java is therefore designed to allow applications to run on all platforms without having to be rewritten or recompiled for each platform.

자바언어의 또 다른 특징은 프로그래머가 생성한 객체에 대한 동적 메모리 관리를 자동적으로 수행해 준다는 것이다. 어플리케이션의 지속적인 객체 생성요구로 인하여 힙(heap) 메모리 즉, 동적 메모리가 완전 소진상태에 이르게 되면 가상머신내의 쓰레기 수집기(garbage collector)라는 서브 시스템은 어플리케이션이 더 이상 사용하지 않을 쓰레기 객체들을 판별해내어 이들을 자유 메모리로 환원하는 기능을 수행한다. 여기서 동적 메모리란 프로그램이 실행될 때까지는 알 수 없는 가변적인 양만큼의 데이터를 저장하기 위해, 프로그램의 프로세스가 사용할 수 있도록 미리 예약되어 있는 동적 메모리의 영역으로서 시스템내의 운영체계가 미리 일정량의 메모리공간을 힙 영역으로 할당해 둔다.Another feature of the Java language is that it automatically performs dynamic memory management on programmer-generated objects. When heap memory, or dynamic memory, is exhausted due to the application's ongoing object creation needs, a subsystem called garbage collector in the virtual machine can identify garbage objects that the application will no longer use. It serves to reduce these to free memory. Here, dynamic memory is an area of dynamic memory that is reserved in advance for use by a program's process to store a variable amount of data that is not known until the program is executed. Allocate it in the heap area.

이러한 힙에 대한 관리를 쓰레기 수집기가 자동적으로 수행해주면 프로그래머는 동적 메모리 관리에 신경을 쓰지 않고도 안전한 어플리케이션을 보다 빠르게 생성할 수 있다는 장점을 얻을 수 있지만, 이러한 자동화된 동적 메모리 관리는 실제 런타임 시에 많은 시스템 자원을 필요로 하기 때문에 시스템 자원을 낭비하여 어플리케이션의 반응이 느리다는 문제가 있다.The garbage collector automatically manages these heaps, which gives the programmer the ability to create secure applications faster without having to worry about dynamic memory management. Because system resources are required, there is a problem that the application response is slow because system resources are wasted.

또한, 이러한 쓰레기 수집기는 객체간의 참조관계를 추적하여 살아 있는 객체와 쓰레기 객체를 구별하도록 되어있지만, 이는 물리적인 현상에 근거한 것이며 논리적 현상을 고려하지 않은 것이라 문제가 있다. 예를 들어, A 객체가 B 객체를 참조하고 있는 경우, 쓰레기 수집기가 객체의 생존 여부를 판별해야 하는 시점에서 A 객체가 살아있어야 하는 객체라면 당연히 B객체도 살아남게 될 것이다. 그러나 쓰레기 수집기는 A 객체가 B 객체에 대한 참조를 단지 저장만 하고 있는 것인지 또는 참조를 이용해 향후 어떤 작업을 수행할 수 있을 것인지에 대한 판단을 내리는데 있어서 어떤 알고리즘만으로는 결정이 불가능하다. 비록 쓰레기 수집기는 B 객체를 살아있도록 보존하였지만 프로그램의 논리적인 흐름에 따라 B 객체는 어플리케이션이 종료될 때까지 전혀 A에서 가지고 있는 참조가 활용이 되지 않을 수도 있어 시스템의 메모리 자원이 낭비되며, 이는 쓰레기 수집기의 수행 주기를 단축시켜 결국 어플리케이션의 반응 속도가 느려지는 문제를 발생시킬 수 있다.In addition, such a garbage collector is designed to distinguish between living and garbage objects by tracking the reference relationship between objects, but this is based on a physical phenomenon and does not consider a logical phenomenon. For example, if object A refers to object B, then object B will survive if object A needs to be alive at the time the garbage collector must determine whether the object survives. However, the garbage collector cannot determine by any algorithm in determining whether an A object merely stores a reference to an B object or what operations it can perform in future. Although the garbage collector kept B objects alive, depending on the logical flow of the program, B objects may not use the references they have in A until the application terminates, which wastes system memory resources. This can shorten the performance cycle of the collector, which can lead to problems that slow down the application's response.

이상과 같이 쓰레기 수집기 등을 이용하는 자동화된 동적 메모리 기반의 시스템에서 어플리케이션의 명시적인 동적 메모리 또는 객체의 수거가 지원되고 있지 않기 때문에 제안하는 방법에서는 이를 지원할 수 있도록 하는 방안을 마련하고, 이와 같은 명시적 객체 수거로 인하여 객체참조의 일관성을 깨지는 것을 방지하기 위한 방지책을 제시한다.Since the collection of explicit dynamic memory or object of application is not supported in the automated dynamic memory based system using garbage collector as above, the proposed method provides a way to support this. Precautions are taken to prevent object collection from breaking the consistency of object references.

따라서 상기의 문제점을 극복하기 위하여 본 발명은, 어플리케이션 프로그래머가 직접 동적 메모리상의 쓸모 없는 객체를 수거할 수 있도록 응용프로그램 인터페이스 기법과 이러한 인터페이스를 지원할 수 있는 가상 머신을 구현함을 목적으로 한다. 또한, 어플리케이션 실행 시에 객체 참조와 객체 수거의 논리 불일치로 인한 시스템 불안정이 발생하지 않도록 하는 위치 버전 기법을 이용한 객체 생성 및 수거 알고리즘을 제공함을 목적으로 한다.Accordingly, an object of the present invention is to implement an application program interface technique and a virtual machine capable of supporting such an interface so that an application programmer can directly collect useless objects in dynamic memory. It is also an object of the present invention to provide an object creation and collection algorithm using a location versioning technique that prevents system instability due to logical mismatch between object reference and object collection.

도 1은 어플리케이션과 가상머신과 응용프로그램 인터페이스 관계를 나타낸 구성도.1 is a configuration diagram showing an application, a virtual machine, and an application program interface relationship.

도 2는 사용되지 않는 객체를 어플리케이션이 수거하고자 할 때의 선택객체 수거의 전체적인 흐름도.2 is a general flow diagram of collection of selected objects when an application wishes to collect unused objects.

도 3은 선택객체 수거기가 해당 선택객체를 수거하는 알고리즘을 나타낸 플로우차트.3 is a flowchart illustrating an algorithm in which a selection object collector collects the selection object.

도 4는 위치 버전이 저장된 모습을 나타낸 그림.4 is a view showing a position version is stored.

도 5는 객체 변수에 위치 버전이 저장된 모습을 나타낸 그림5 is a view showing a position version is stored in the object variable

*도면의 주요 부분에 대한 부호의 설명** Description of the symbols for the main parts of the drawings *

100: 어플리케이션 150: 가상머신100: application 150: virtual machine

160: 응용프로그램 인터페이스 170: 선택객체 수거기160: application program interface 170: selector object collector

411: 포인터 412: 위치버전411: pointer 412: position version

이러한 목적을 이루기 위하여 본 발명은, 어플리케이션이 실시간으로 실행되는 시스템 동적 메모리 내의 객체들을 어플리케이션이 직접 명시적으로 수거하는 기능을 지원하기 위하여 순수 자바로 작성된 클래스를 자바가상머신에 구비하고, 가상머신에는 어플리케이션에 의해 수거 요청된 객체를 수거하는 기능을 가지는 선택객체 수거기 및 가상머신과 어플리케이션과의 객체 수거용 인터페이스를 제공하는 응용프로그램 인터페이스가 구비된다.In order to achieve the above object, the present invention provides a Java virtual machine with a class written in pure Java in order to support a function in which an application directly collects objects in a system dynamic memory in which the application is executed in real time. A selection object collector having a function of collecting objects requested to be collected by an application, and an application program interface providing an interface for collecting an object between the virtual machine and the application.

또한, 어떤 객체(A)를 참조하는 객체참조변수(B)가 있고, A를 참조하는 또 다른 객체참조변수(C)가 있는 경우, B에 의해 참조가 되고 있는 객체(A)가 수거되었을 시에 객체참조변수 C를 이용해 이미 수거된 객체에 접근할 수 있는 경우에 발생할 수 있는 참조의 일관성이 깨지는 현상을 방지하기 위하여 위치버전 기법을 적용한다. 즉, 객체참조변수 영역과 실제 객체내용이 저장된 동적 메모리의 객체 정보 영역에 동일한 위치버전을 저장함으로써, 추후에 어플리케이션이 C를 이용하여 객체에 접근하려고 할 때 양 위치버전이 동일한가를 판단하여 해당 객체에 대한 이용허가 여부를 결정하도록 한다. 이러한 위치버전을 적용함으로써, 참조의 일관성이 깨지는 것을 막을 수 있다.In addition, if there is an object reference variable (B) referring to an object (A) and another object reference variable (C) referring to A, the object (A) referenced by B is collected. In order to prevent the inconsistency of references, which can occur when an object already collected using an object reference variable C can be accessed, the position version technique is applied. That is, by storing the same location version in the object information area of the dynamic memory where the object reference variable area and the actual object contents are stored, it is determined whether the two location versions are the same when the application later attempts to access the object using C. It is decided whether or not to use the license. By applying this location version, we can avoid breaking the consistency of the reference.

한편, 어플리케이션이 객체를 수거하고자 해당 작업 메쏘드 호출이 있는 경우, 응용프로그램 인터페이스와 선택객체 수거기는 여러 단계의 수거 알고리즘을 갖는다. 선택된 객체가 이미 자유화 된 객체인 경우에는 수거작업을 종료하고 특정 예외객체를 어플리케이션에 발생하고, 파이널라이즈(finalize) 메쏘드가 존재할 시에는 파이널라이즈 작업을 마친 후에 실질적인 객체 수거작업에 들어간다.On the other hand, when an application has a corresponding method call to collect an object, the application program interface and the selective object collector have a multi-level collection algorithm. If the selected object is already liberalized, the collection operation is terminated and a specific exception is thrown to the application. If the finalize method exists, the finalization operation is completed and the actual object collection operation is performed.

이하에서는, 도면을 참조하여 본 발명의 실시 예를 상세히 설명한다.Hereinafter, with reference to the drawings will be described an embodiment of the present invention;

도 1은 본 발명에 따른 응용프로그램 인터페이스를 어플리케이션과 가상머신 사이에서 구현한 모습을 나타낸 블록도이다. 도 1에 도시한 가상머신(150)은 선택객체 수거기(170)를 포함하고 있는 것을 예로 들었지만, 선택객체 수거기(170)와 시스템 인터페이스(162)를 갖추지 않은 가상머신(150)에도 사용자 인터페이스(160)가 적용될 수 있다. 이는 명시적인 동적 메모리 관리가 지원되는 가상머신인지 지원되지 않는 가상머신인지를 판단하여 지원되지 않는 곳에서는 어플리케이션의 요청을 무시하기 위함이다. 즉, 시스템 인터페이스(162)와 선택객체 수거기(170)를 갖추지 못한 가상머신(150)이 어플리케이션(100)으로부터 선택객체 수거 요청을 받을 시에는 응용프로그램 인터페이스(160)는 특정한 예외객체를 어플리케이션에 발생시키던지 또는 가상머신은 아무런 동작을 하지 않으면 되기 때문이다. 여기서 선택객체라 함은 어플리케이션 프로그래머가 객체를 수거하고자 명시적으로 선택한 객체를 말한다.1 is a block diagram showing an implementation of an application program interface between an application and a virtual machine according to the present invention. Although the virtual machine 150 shown in FIG. 1 includes the selection object collector 170 as an example, the user interface is also provided to the virtual machine 150 without the selection object collector 170 and the system interface 162. 160 may be applied. This is to determine whether explicit dynamic memory management is supported or unsupported, and ignore the application's request where it is not supported. That is, when the virtual machine 150 without the system interface 162 and the selection object collector 170 receives the selection object collection request from the application 100, the application program interface 160 sends a specific exception object to the application. This is because the virtual machine does not need to be operated or generated. Here, the selection object refers to the object that the application programmer explicitly selects to collect the object.

어플리케이션(100)은 자바, C#, LISP과 같은 자동화된 동적 메모리관리 기능을 지원하는 객체지향형 언어로 작성될 수 있을 뿐만 아니라 객체지향형 언어이지만 자동화된 동적 메모리관리 기능을 갖추지 않은 C++과 같은 언어에서 자동화된 동적 메모리관리기능을 라이브러리 형태로 이용하고 있는 어플리케이션들을 의미한다.The application 100 can be written not only in an object-oriented language that supports automated dynamic memory management functions such as Java, C #, and LISP, but also in an object-oriented language, such as C ++, which does not have automated dynamic memory management. It refers to applications that use dynamic memory management in the form of libraries.

가상머신(150, VM, virtual machine)은 컴파일된 응용프로그램의 바이트 코드와 실제로 프로그램의 명령어를 실행하는 마이크로프로세서(또는 하드웨어 플랫폼) 간에 인터페이스 역할을 담당하는 소프트웨어로서, 해당 하드웨어 플랫폼에서 응용프로그램이 실행될 수 있도록 명령어 집합, 레지스터들의 집합, 스택, 힙(heap), 그리고 메쏘드 영역 등을 지정한다. 이러한 가상머신은 여러 개의 서브시스템을 포함하고 있지만, 본 발명의 실시에 필요로 하는 응용프로그램 인터페이스와 선택객체 수거기만을 도시하였다.A virtual machine (150, VM) is software that acts as an interface between the byte code of a compiled application and the microprocessor (or hardware platform) that actually executes the instructions of the program. It specifies the instruction set, set of registers, stack, heap, and method area. Although such a virtual machine includes several subsystems, only the application program interface and the selective object collector required for the practice of the present invention are shown.

응용프로그램 인터페이스(150)는 어플리케이션이 가상머신에게 특정한 처리요구를 할 수 있도록 가상머신에 의해서 미리 정해진 특별한 메쏘드로서, 크게 사용자 인터페이스(161)와 시스템 인터페이스(162)로 구분된다. 본 발명에 따라 어플리케이션으로부터 선택객체 수거 메쏘드 호출이 있을 시에 이를 수령한 사용자 인터페이스(161)는, 경우에 따라서 일정한 예외객체를 어플리케이션에 보내주거나 선택객체 수거 메쏘드 호출을 시스템 인터페이스에게 전달해 준다. 어떤 동작을 취할 것인지는 시스템 인터페이스(162)의 유무로 따지며, 이 것이 존재할 경우에는 시스템 인터페이스를 호출하지만 존재하지 않는 경우에는 예외 객체를 어플리케이션에보내준다. 또한, 사용자 인터페이스(161)로부터 해당 선택객체 메쏘드 호출을 수령한 시스템 인터페이스(162) 역시 경우에 따라서, 일정한 예외객체를 사용자 인터페이스에 보내주거나 해당 선택객체 메쏘드 호출을 객체수거기에 전달해 준다. 동적 메모리를 효율적으로 관리하기 위해 본 발명에 적용되는 이러한 선택객체 수거 메쏘드 전달 또는 예외객체 발생응답에 대한 인터페이스 방법은 도 2에서 상세히 설명하도록 한다.The application program interface 150 is a special method predetermined by the virtual machine so that an application can make a specific processing request to the virtual machine. The application program interface 150 is divided into a user interface 161 and a system interface 162. According to the present invention, the user interface 161 which receives a collection of selected object collection methods from an application sends a specific exception object to the application or transmits a collection of selected object collection methods to the system interface. The action taken is determined by the presence or absence of the system interface 162. If this is present, the system interface is called, but the exception object is sent to the application if it is not present. In addition, the system interface 162 that receives the selected object method call from the user interface 161 also sends a specific exception object to the user interface or passes the selected object method call to the object collector. In order to efficiently manage the dynamic memory, an interface method for passing the selective object collection method or responding to an exception object occurrence applied to the present invention will be described in detail with reference to FIG. 2.

선택객체 수거기(170)는 종래의 쓰레기 수집기(garbage collector)의 기능과 유사하게 쓰레기를 수집하는 기능을 하지만 본질적으로 큰 차이가 있다. 종래의 쓰레기 수집기는 응용프로그램을 플랫폼 등에서 실행 시에 어플리케이션의 지속적인 객체 생성 요구로 인하여 동적 메모리가 완전 소진상태에 이르게 되면 자동적으로 어플리케이션이 더 이상 사용하지 않을 쓰레기 객체들을 판별해내어 이들을 자유 메모리로 환원시키는 기능을 하지만, 선택객체 수거기(170)는 어플리케이션의 요청이 있을 시에만 특정한 선택객체를 수거하는 기능을 한다. 즉, 선택객체 수거 요청이 있을 시에는 선택객체 수거기는 해당 객체를 수거하기 위해 네이티브 메쏘드를 호출하여 실제 동적 메모리의 객체를 수거하는 기능을 한다. 선택객체 수거기(170)내에서 선택객체를 수거하는 알고리즘은 도 3과 함께 나중에 상세히 후술하도록 한다.The selective object collector 170 functions to collect garbage similarly to the function of a conventional garbage collector, but there is a substantial difference. Conventional garbage collectors automatically identify garbage objects that the application will no longer use when dynamic memory reaches a complete state due to the continuous object creation request of the application when the application is executed on a platform, etc., and return them to free memory. However, the selection object collector 170 collects a specific selection object only at the request of an application. That is, when there is a request for collecting a selection object, the selection object collector collects an object in real dynamic memory by calling a native method to collect the object. An algorithm for collecting the selection object in the selection object collector 170 will be described later in detail with reference to FIG. 3.

도 2는 사용되지 않는 객체를 어플리케이션이 수거하고자 할 때의 선택객체 수거의 전체적인 흐름도를 도 1에서 도시한 어플리케이션, 사용자 인터페이스, 시스템 인터페이스, 선택객체 수거기와 연관하여 나타낸 그림이다.FIG. 2 is a diagram illustrating an overall flow chart of selection object collection when an application intends to collect an unused object in association with the application, user interface, system interface, and selection object collector shown in FIG. 1.

어플리케이션은 객체를 수거할 수 있는 메쏘드를 구비하고 있어 어떤 객체 하나를 수거하거나 또는 해당 객체 뿐 아니라 그 객체가 참조하고 있는 모든 객체들을 수거하고자 할 때 해당 메쏘드를 호출(210)하게 된다. 가상머신에 있는 사용자 인터페이스는 어플리케이션으로부터 호출된 메쏘드에 의해 특정한 액션을 취하게 된다. 즉, 시스템 인터페이스의 존재 유무를 점검하여 존재하는 경우에는 이를 호출하지만, 존재하지 않는 경우에는 특별한 예외 객체를 어플리케이션에게 전달하게 된다. 그리고 어플리케이션에서 수거되지 않아야 하는 특별한 객체를 수거하려고 시도하는 경우에는 선택객체 수거불가라는 예외객체를 어플리케이션에 전달(211)하고 시스템 인터페이스에게는 어떠한 메쏘드도 전달하지 않고 수거작업을 종료시키고, 반면에 그러한 특별한 객체가 아니라면 해당 수거 메쏘드를 시스템 인터페이스에 전달한다(220). 위와 같은 사용자 인터페이스를 두는 이유는 현재 자바가상머신의 경우 선택 객체 수거기가 존재하지 않기 때문이며, 향후 만약 선택 객체 수거기가 자바가상머신에 정식으로 포함된다면 사용자 인터페이스에서의 위와 같은 점검은 불필요하게 된다. 그러나 수거하지 않아야 하는 특별한 객체가 있는 경우에 대한 처리는 선택 객체 수거기가 수행할 수 있도록 해야 한다.The application is provided with a method for collecting an object, so when the user wants to collect a single object or to collect not only the object but all the objects referenced by the object, the method is called 210. The user interface in the virtual machine takes specific actions by the methods called from the application. In other words, it checks for the existence of the system interface and calls it if it exists, but if it does not exist, it sends a special exception object to the application. If an application attempts to collect a special object that should not be collected, it passes an exception 211 to the application, which says that the object is not available for collection and terminates the collection without passing any methods to the system interface, while If not, the collection method is passed to the system interface (220). The reason for having the above user interface is that there is no selection object collector in the current Java virtual machine. If the selection object collector is included in the Java virtual machine in the future, the above check in the user interface is unnecessary. However, the handling of cases where there are special objects that should not be collected should be made available to the selection object collector.

시스템 인터페이스는 일반 자바 프로그래머에게는 자바 API(Application Programming Interfaces)의 형태로 보이지만 가상머신 내부적으로는 실제로 네이티브 메소드의 형태로 구현되어진다.The system interface appears to the general Java programmer in the form of Java API (Application Programming Interfaces), but inside the virtual machine, it is actually implemented as a native method.

상기의 단계를 거쳐 사용자 인터페이스로부터 수거 요청을 전달받은(230) 선택객체 수거기는 수거 요청된 객체가 이미 자유화된 객체인 경우에는 널포인터 예외객체를 시스템 인터페이스에 보내어 어플리케이션으로 하여금 이를 수령하게 하고 수거 메쏘드 작업을 종료한다(231, 232, 233). 수거되지 않고 살아있는 정상적인 객체라면 해당 선택객체를 수거하는 작업을 하게 된다.After receiving the collection request from the user interface through the above steps, the selective object collector sends a null pointer exception object to the system interface so that the application receives the collection object when the collection requested object is already a liberated object. End the method operation (231, 232, 233). If it is a normal object that is not collected, it will collect the selected object.

도 3은 선택객체 수거기가 해당 선택객체를 수거하는 알고리즘을 나타낸 플로우차트이다.3 is a flowchart illustrating an algorithm in which the selection object collector collects the selection object.

먼저, 응용프로그램 인터페이스로부터 선택객체 수거 메쏘드를 수령한 선택객체 수거기는 수거하고자 하는 객체가 이미 자유화된 객체인가를 판단(S301)하여 이미 자유화된 객체인 경우(S301a) 널포인터 예외객체를 반환(S309)하며 작업을 종료한다. 또한 수거요청시의 객체참조변수가 가지고 있는 위치버전과 수거요청된 객체 정보 영역에 저장되어 있는 위치버전을 비교하여 서로 다른 경우에도 널포인터 예외객체를 반환하며 작업을 종료하게 된다. 그리고 자유화된 객체가 아닌 즉, 정상적으로 살아있는 객체의 경우(S301b)에는 이 것이 파이널라이즈(finalize) 메쏘드를 구비하고 있는가를 조사(S302)한다. 판단결과 해당 객체가 파이널라이즈 메쏘드를 구비하고 있지 않은 경우(S302b)에는 파이널라이즈 작업을 진행하지않고 곧바로 동적 메모리에 대한 락(lock)을 걸고(S306) 객체 수거하는 작업을 하고, 반면에 해당 객체가 파이널라이즈 메쏘드를 구비하고 있는 경우(S302a)에는 파이널라이즈 쓰레드를 수행(S303, S304, S305)한 후 동적 메모리에 대한 락을 건다(S306). 이러한 파이널라이즈 작업은, 모든 어플리케이션 쓰레드의 수행을 중단(S303)한 후파이널라이즈 작업을 담당하는 파이널라이즈 쓰레드의 수행을 재개하여 파이널라이즈 작업(S304)을 마친 후에 다시 모든 어플리케이션의 쓰레드 수행을 재개(S305)하는 단계를 거친다. 여기서 파이널라이즈 작업이란, 더 이상 참조되지 않는 객체를 회수하기 전에 해당 객체로 하여금 스스로 청소할 마지막 기회를 제공함으로써, 관련정보들을 스스로 정리할 수 있게끔 자바에서 지원되고 있는 메커니즘이다. 즉, 수거되어야 할 해당 객체가 시스템의 자원을 사용 중이었다면 이를 릴리즈(release)해 줌으로써 시스템 자원의 효율적인 사용을 꾀할 수 있게 된다.First, the selective object collector which receives the selective object collection method from the application program interface determines whether the object to be collected is already a liberalized object (S301) and returns a null pointer exception object when the object is already liberalized (S301a). S309) and ends the operation. In addition, the location version of the object reference variable in the collection request is compared with the location version stored in the requested object information area, and even if it is different, the null pointer exception object is returned and the operation ends. If the object is not a liberalized object, that is, an object that is normally alive (S301b), it is checked whether it has a finalize method (S302). If it is determined that the object does not have a finalization method (S302b), it does not proceed with the finalization operation but immediately locks the dynamic memory (S306) and collects the object. If S has a finalization method (S302a), after performing the finalization thread (S303, S304, S305) and locks the dynamic memory (S306). This finalization operation stops the execution of all application threads (S303), resumes execution of the finalization thread in charge of finalization operation, and resumes thread execution of all applications again after finishing the finalization operation (S304). S305). Finalization here is a mechanism supported in Java that allows you to organize related information yourself by giving it a last chance to clean itself before retrieving objects that are no longer referenced. In other words, if the object to be collected was using the system resources, it is possible to release the system resources for efficient use of system resources.

동적 메모리에 대한 락을 획득(S306)한 후에는 자동화된 동적 메모리 관리자에 이미 구현되어 있는 객체 자유화에 관련된 함수 즉, 실제 메모리 수준의 수거 기능을 담당하고 있는 함수를 호출하여 실제 수거 작업(S307)을 수행한 다음, 힙에 대한 락을 다시 풀어줌으로써(S308), 객체 수거 작업을 마치게 된다.After acquiring the lock on the dynamic memory (S306), a function related to object liberalization that is already implemented in the automated dynamic memory manager, that is, a function in charge of the collection function of the actual memory level is called to perform the actual collection operation (S307). Then, by unlocking the heap again (S308), the object collection is completed.

한편, 기존의 가상머신은 힙에 존재하는 객체에 접근하기 위하여 포인터를 활용하고 있다. 따라서, 객체참조 A를 선언하고 A가 특정 객체를 가리키도록 설정한 뒤, 해당 소스를 컴파일한 바이트코드를 가상머신에서 실행하면 객체참조 A는 동적 메모리 영역의 한 부분을 지시하게되고 지시된 동적 메모리 영역에는 실제 객체에 대한 내용이 들어가게 된다. 예를 들어, 객체참조 A에 의해 지시되는 객체에 144라는 정수(integer)가 들어가 있는 경우 이를 컴파일한 바이트코드가 가상머신에서 실행될 때에는 가상머신은 적당한 동적 메모리 영역 예컨대, Ox80000000에 144 값을 집어넣고 객체참조 A 자체는 Ox80000000이라는 어드레스 포인터가 저장된다. 따라서, 어플리케이션이 도 2, 도 3에서 설명한 방법에 따라 객체참조 A가 가리키는 객체를 수거하게 되면 Ox800000000에 있는 144는 지워지게 되어 해당 동적 메모리 번지는 비워진 상태로 되고, 또한 객체참조 A 역시 어드레스 포인터가 지워지고 널(null) 상태로 된다.On the other hand, existing virtual machines utilize pointers to access objects on the heap. Therefore, if you declare an object reference A, set A to point to a specific object, and then execute the bytecode that compiled the source in the virtual machine, the object reference A points to a portion of the dynamic memory area and the indicated dynamic The memory area contains the contents of the actual object. For example, if the object indicated by object reference A contains an integer of 144, when the compiled bytecode is executed in the virtual machine, the virtual machine inserts 144 into the appropriate dynamic memory area, eg, Ox80000000. The object reference A itself stores an address pointer of Ox80000000. Therefore, when the application collects the object pointed to by the object reference A according to the method described with reference to Figs. 2 and 3, 144 in Ox800000000 is erased, and the corresponding dynamic memory address becomes empty, and the object reference A also has an address pointer. It is cleared and nulled.

그러나, 다음 표 1에서의 프로그램의 플로우를 살펴보면 수거하려는 객체를 또 다른 변수가 참조하고 있는 경우에는 참조의 일관성이 깨지게 됨을 알 수 있다. 여기서, 객체참조 A, B, C는 동일한 타입의 객체를 가리킬 수 있다고 가정한다.However, if you look at the flow of the program in Table 1, you can see that the consistency of references is broken when another variable refers to the object to be collected. Here, it is assumed that the object references A, B, and C can refer to the same type of object.

public class XXXX {public class XXXX {

객체참조 A = 객체 생성............ ①Object Reference A = Create Object ............ ①

객체참조 B = 객체 생성............ ②Object Reference B = Create Object ............ ②

객체참조 A의 정수 멤버 = 144............ ③Integer member of object reference A = 144 ............ ③

객체참조 B = 객체참조 A............ ④Object Reference B = Object Reference A ............ ④

객체참조 A가 참조하는 객체 수거............ ⑤Collection of objects referenced by object reference A ............

객체참조 C = 객체 생성............ ⑥Object reference C = object creation ............ ⑥

객체참조 C의 정수 멤버 = 154............ ⑦Integer member of object reference C = 154 ............

객체참조 B의 정수 멤버 값 프린트............ ⑧Print integer member value of object reference B ......

}}

[표 1]TABLE 1

상기 표 1에서 객체참조 A에 의해 가리켜지는 객체의 수거(⑤라인) 시에 수거되는 해당 객체뿐만 아니라 그 객체에 대한 참조를 가지고 있는 모든 객체참조들도 더 이상의 어떤 객체를 가리키지 못하게 된다. 객체수거 메쏘드를 호출하여 객체참조 A가 참조하고 있던 객체를 수거한다면 이를 참조하고 있는 객체참조 B가 가리키고 있는 객체가 수거됨과 마찬가지이므로 마지막 행에서 객체참조 B가 가리키는 객체의 값을 출력할(⑧라인) 시에 널 포인터를 인식하게 된다. 따라서 참조변수의 불일치로 인한 오류를 걱정할 염려가 없다. 그러나, 객체참조 A에 의해 가리켜지고 있는 객체가 수거된 뒤 동일한 위치에 다른 객체가 생성되면 문제가 발생한다. 이는 객체참조 A에 의해 가리켜지는 객체의 수거 시에 그 객체를 참조하고 있는 객체참조 B에 대한 적절한 조치가 취해지지 않았기 때문이다. 따라서 객체참조 A에 의해 가리켜지는 객체의 수거가 있은 후에도 객체 B는 여전히 Ox80000000을 가리키고 있고 해당 위치에 새로운 객체를 생성하고 그 객체의 정수형 멤버에 154라는 값을 저장하게 되어 결국 객체참조 B는 이 전의 객체가 아닌 이후의 객체를 참조하게 됨으로써 어플리케이션 프로그래머가 의도와 다른 결과를 낳음을 알 수 있다.In Table 1, all object references that have a reference to the object as well as the object collected at the time of collection of the object indicated by the object reference A (line ⑤) no longer point to any object. If the object reference A is collected by calling the object collection method, the object pointed to by the object reference B referencing it is the same as the object pointed to. Will recognize a null pointer. Therefore, you do not have to worry about errors due to mismatches in the reference variables. However, a problem occurs when another object is created at the same location after the object pointed to by the object reference A is collected. This is because, upon collection of the object pointed to by object reference A, no appropriate action has been taken on object reference B that refers to that object. Thus, even after the collection of objects pointed to by object reference A, object B still points to Ox80000000, creates a new object at that location, and stores the value 154 in the integer member of that object. By referencing a later object rather than an object, the application programmer sees a different result than intended.

이는 Kaffe와 같은 자바가상머신이 같은 크기의 객체들을 같은 블록에 저장하는 방식을 취하고 있기 때문인데, ⑥라인에서 정수형 멤버로 154라는 값을 가지는 객체는 ①라인에서 생성되었다가 ⑤라인에서 수거된 객체와 정확히 같은 위치 즉, Ox80000000의 동적 메모리 영역에 저장되기 때문이다. 따라서, ⑥라인 이전에서 B를 참조하여 객체에 접근하려는 경우에는 널포인터 예외객체가 발생하지만(객체 B의 포인터가 가리키는 Ox80000000은 이미 내용이 수거된 상태이기 때문임), ⑥라인 이후인 ⑧라인에서 B를 참조하여 객체에 접근하려는 경우에는 ⑥라인에서 생성된 객체 즉, 객체 C의 포인터 Ox80000000과 동일한 어드레스를 가리키기 때문에 결국 Ox80000000에 저장되어 있는 154의 값을 프린트하는 것이다.This is because a Java virtual machine such as Kaffe stores objects of the same size in the same block. An object with a value of 154 as an integer member in line ⑥ is created in line ① and collected in line ⑤. Is stored in the exact same location as the dynamic memory area of Ox80000000. Therefore, if you try to access the object by referring to B before line ⑥, a null pointer exception object will occur (because Ox80000000 pointed to by object B's pointer is already collected), but at line ⑧ after line ⑥ In the case of accessing an object with reference to B, the object created in line ⑥, that is, it points to the same address as the pointer Ox80000000 of the object C, eventually prints the value of 154 stored in Ox80000000.

즉, ⑧라인에서의 객체참조 B 이용 시에 객체참조 A를 참조하여 144인 B 값을 이용하려는 프로그래머의 의도와 달리 가상머신은 객체참조 C를 참조하여 154라는 값을 이용하게 되는 문제가 생긴다. 따라서, 이를 해결하기 위해서는 어떤 객체를 수거할 때 그 객체를 참조하고 있는 또 다른 객체변수들을 모두 찾아 그들을 null값으로 수정해주는 메쏘드를 이용할 수도 있지만, 이러한 메쏘드는 참조하고 있는 모든 객체변수들을 찾기 위해 전체 힙을 검색하여야 하기 때문에 높은 오버헤드가 발생된다.That is, unlike the programmer's intention to use the B value of 144 by referring to the object reference A when using the object reference B in line (8), the virtual machine uses the value 154 by referring to the object reference C. Thus, to solve this, you can use a method that finds all other object variables referencing the object and modifies them to null values when collecting an object. High overhead is incurred because the heap must be searched.

따라서, 객체 수거 시에 과도한 오버헤드를 피하면서 동시에 프로그램 로직이 의도한 대로 정확하게 동작하도록, 객체 변수 생성 및 수거 시에 위치버전 기법을 적용하는 방법을 설명하도록 한다.Therefore, a description will be given of a method of applying the position version technique in creating and collecting object variables so as to avoid excessive overhead in collecting objects and at the same time operating program logic exactly as intended.

기존의 가상머신은 어플리케이션에서 컴파일되어 전달되어온 객체 변수를 생성할 때에는, 객체 변수 영역에 실제 변수 값이 저장된 동적 메모리상의 어드레스를 가리키는 포인터만을 저장한다. 또한, 동적 메모리상에는 해당 어드레스에 있는 객체 값 외에도 객체 정보 영역을 포함한다. 이러한 정보 영역은 객체의 색(color)이나 현재 상태 정보가 저장되는 영역으로서 사용자 어플리케이션에서는이러한 정보 영역을 제외한 나머지 영역에 접근할 수 있을 뿐이며 정보 영역은 오직 가상머신만 접근 가능한 영역이다.Existing virtual machines store only pointers to addresses in dynamic memory where the actual variable values are stored in the object variable area when creating object variables that have been compiled and passed in the application. In addition, the dynamic memory includes an object information area in addition to the object value at the corresponding address. The information area is an area in which the color or current state information of the object is stored, and the user application can access the remaining areas except the information area, and the information area is only accessible to the virtual machine.

본 발명에 의해 제안하는 위치버전 알고리즘은 위치 버전을 객체참조 영역과 동적 메모리상의 객체 정보 정보에 저장함으로써, 객체가 어플리케이션에 의해 이용될 때 각 객체의 위치버전을 비교 판단하여 객체 이용 시의 일관성을 유지하는 것이다. 즉, 객체참조에는 객체참조의 실제 값이 저장된 동적 메모리 어드레스를 가리키는 포인터 외에도 특정의 위치버전 값을 함께 저장한다. 또한 동적 메모리의 해당 어드레스 객체의 참조변수가 저당된 동적 메모리 어드레스 영역에는, 참조변수 값 외에도 상기의 위치버전을 함께 저장한다. 이들 두 버전 정보가 같은 경우 어플리케이션에서는 참조변수를 통하여 해당 객체에 접근할 수 있지만, 다른 경우에는 참조변수가 참조하고 있는 객체와 실제 객체가 다르기 때문에 가상머신이 설치되어 있는 시스템은 이에 대한 접근을 막고 널포인터 예외객체와 같은 것을 발생시켜 어플리케이션에 전달하는 것이다.The location version algorithm proposed by the present invention stores the location version in the object reference area and the object information information in the dynamic memory, thereby comparing and determining the location version of each object when the object is used by the application. To keep. That is, the object reference stores a specific location version value as well as a pointer to a dynamic memory address where the actual value of the object reference is stored. In addition, in the dynamic memory address area in which the reference variable of the corresponding address object of the dynamic memory is stored, the position version is stored together with the reference variable value. If these two version information is the same, the application can access the object through the reference variable, but in other cases, the system with the virtual machine prevents access to it because the object referenced by the reference variable is different from the actual object. It throws something like a null pointer exception object and passes it to the application.

도 4는 상기의 위치 버전이 저장되는 모습을 나타내고 있다.4 shows how the location version is stored.

데이터 구조(structure)안에 여러 객체에 대한 변수에 대해 컴파일된 바이트코드가 가상머신이 설치되어 있는 시스템에서 실행될 때에는, 객체 변수는 객체 참조 영역(413)에 저장되게 되는데, 이러한 객체 참조 영역에는 객체가 실질적으로 저장된 어드레스를 나타내는 어드레스 포인터(411)와 이 객체의 위치버전 정보(412)를 포함하게 된다. 또한, 객체가 저장된 동적 메모리 어드레스에는 실제객체 영역(421)과 이러한 객체에 대한 객체 정보영역(422)을 가진다. 이러한 정보 영역(421)에는 객체참조에 저장된 위치버전과 동일한 위치버전(412)을 갖도록 한다. 이는 객체를 관리하는 시스템이 필요에 의해 각 객체마다 추가적으로 객체 정보 영역에 위치 버전을 저장하는 것이다. 이러한 객체 정보 영역 내의 위치버전(421)은 나중에 객체가 수거되더라도 그 객체가 위치한 곳에 위치버전을 남겨 놓아 추후 이곳에 새로운 객체가 생성될 때 참조하여 그 값을 1 증가시켜 사용하게 된다.When the bytecode compiled for variables for several objects in a data structure is executed on a system with a virtual machine installed, the object variables are stored in the object reference area 413, which contains the objects It includes an address pointer 411 indicating the stored address and position version information 412 of this object. In addition, the dynamic memory address where the object is stored has an actual object area 421 and an object information area 422 for such an object. The information area 421 has the same location version 412 as the location version stored in the object reference. This is because the system that manages the object stores the location version in the object information area additionally for each object. Even if an object is collected later, the location version 421 in the object information area may leave the location version where the object is located and use it by incrementing the value by 1 when a new object is created here.

객체참조 내에 저장된 위치버전(412)과 동적 메모리의 객체 정보 영역 내에 저장된 위치버전(421)의 동일성을 이루는 방법은, 어떤 영역에 객체를 생성 또는 수거할 때에는 그 영역에 대한 위치 버전의 값을 읽어와 1 증가시키고 이것을 다시 객체 정보 영역에 저장한 뒤, 이 값을 객체 참조 영역(413)의 위치 버전 영역(412)에 저장함으로써 위치버전의 동일성을 이루게 된다.The method of establishing the identity of the location version 412 stored in the object reference and the location version 421 stored in the object information area of the dynamic memory reads the value of the location version of the area when the object is created or collected in the area. And increase it by 1 and store it again in the object information area, and then store this value in the location version area 412 of the object reference area 413 to achieve the location version identity.

이렇게 위치버전이 객체참조의 위치버전영역(412)과 동적 메모리의 객체 정보 영역(421)에 저장됨으로써, 객체참조에 저장된 위치 버전과 객체정보 영역에 저장된 위치버전이 서로 다른 경우 어플리케이션이 해당 객체참조를 통하여 동적 메모리에 저장되어 있는 객체에 접근을 할 수 없게 한다.As such, the location version is stored in the location version area 412 of the object reference and the object information area 421 of the dynamic memory, so that when the location version stored in the object reference and the location version stored in the object information area are different from each other, the application refers to the corresponding object reference. This disables access to objects stored in dynamic memory.

예를 들어, 상기 표 1에서 라인 ⑤에서 객체참조 A가 가리키는 객체가 수거될 때에 힙에 있는 객체의 정수형 멤버의 값 154는 수거되어 지워진다고 하더라도 객체 정보 영역 내의 위치 버전(여기서는 3이라고 가정함)은 그대로 남아 있게 된다. 객체참조 B가 가리키는 객체는 객체참조 A가 가리키는 객체의 수거 전에 이미객체참조 A가 가리키는 객체를 참조하므로 객체참조 B의 위치버전은 3이 된다.For example, when the object pointed to by the object reference A in line ⑤ in Table 1 is collected, the value 154 of the integer member of the object in the heap is collected and erased, but the position version in the object information area (assuming 3 here). Will remain the same. The object version pointed to by object reference B already refers to the object pointed to by object reference A before collection of the object pointed to by object reference A, so the position version of object reference B is 3.

한편, 추후에 C가 가리키는 객체가 생성될 때 가상머신의 속성상 기존의 A에 의해 가리켜지는 객체가 저장되어 있던 동적 메모리 영역에 그대로 생성되므로, 기존 위치버전 3에 1을 더한 값인 4를 객체 정보 영역의 위치버전에 수정 저장하고, 또한 C가 가리키는 객체에 있는 객체 정보 영역에 위치버전 값 4를 저장한다. 따라서, 향후 어플리케이션이 객체참조 C를 이용하는 경우 객체 변수에 있는 위치버전과 힙에 있는 객체 정보 영역내의 위치버전이 4로 동일하므로 가상머신은 C가 가리키는 객체에 대한 접근을 허용한다. 반면에, 어플리케이션이 B가 가리키는 객체의 정수형 멤버 값을 출력(라인 ⑧)하려는 시도가 있는 경우, 객체참조 B의 위치버전 값 3과 이 것이 가리키는 힙의 객체 위치버전 값 4는 동일하지 않으므로, 가상머신은 어플리케이션이 객체참조 B를 이용한 객체 접근을 막고 예외객체를 어플리케이션에 돌려줌으로써, 객체 변수의 참조를 잘못 사용함으로써 생기는 참조의 일관성이 깨지는 오류를 막을 수 있게 해 준다. 어플리케이션 프로그래머는 이러한 예외객체가 전달되어 오면 이미 객체가 없어진 줄 알게 되어 그에 대한 해결책을 구현할 수 있게 되는 것이다.On the other hand, when the object pointed to by C is created in the future, the object pointed to by the existing A is created as it is in the dynamic memory area where the object pointed by the existing A is stored. Modify and save the location version of the area, and also store the location version value 4 in the object information area in the object pointed to by C. Therefore, when the application uses the object reference C, the virtual machine allows access to the object pointed to by C because the location version in the object variable and the location version in the object information area in the heap are equal to 4. On the other hand, if the application attempts to output the integer member value of the object pointed to by B (line ⑧), the position version value 3 of the object reference B and the object position version value 4 of the heap to which it points are not identical. The machine allows the application to block object accesses using object references B and return exceptions to the application, thereby preventing errors in the consistency of references caused by misuses of object variable references. When an application programmer passes such an exception, it knows that the object is missing and can implement a solution.

도 5는 객체 변수에 위치 버전이 저장된 모습을 나타낸 그림이다.5 is a diagram illustrating a state in which a location version is stored in an object variable.

대부분의 가상머신의 구현물에서는 32비트 환경의 경우 객체의 위치를 8바이트로 정렬한 곳에 생성하게 된다. 따라서, 32비트 중 29비트(510)만 포인터로 이용되고 하위 3비트(520)는 항상 0으로 채워지게 되며 이는 아무런 의미 없는 정보가저장되어 낭비되고 있는 셈이다. 따라서, 하위 3비트를 이용하여 0~7까지의 값을 가지는 위치 버전 정보를 8단계로 구별하여 저장할 수 있다. 64비트 환경에서는 하위 3비트의 크기가 증가될 수 있다.In most virtual machine implementations, the 32-bit environment creates an object with 8 bytes of alignment. Therefore, only 29 bits 510 of the 32 bits are used as pointers, and the lower 3 bits 520 are always filled with zeros, which means that meaningless information is stored and wasted. Therefore, location version information having values from 0 to 7 can be distinguished and stored in eight steps using the lower 3 bits. In 64-bit environments, the lower 3 bits can be increased in size.

한편, 상기에서 설명한 위치버전을 이용한 선택객체 수거 알고리즘을 적용하기 위해서는 도 3에서 도시한 플로우차트에서, 자유화된 객체 판단과 파이널라이즈 메쏘드 존재여부 판단 사이에 위치버전을 확인하는 과정을 거치도록 한다. 즉, 자유화 객체 판단결과 아니라고 판단될 시에는 객체변수에 저장되어 있는 위치버전과 동적 메모리에 있는 해당 위치버전이 동일한가를 판단하여, 동일할 시에는 다음 단계인 파이널라이즈 메쏘드 작업으로 넘어가고 동일하지 않을 시에는 해당 객체에 대한 접근이 불가능하다는 널포인터 예외객체를 발생한 후 해당 객체 수거작업을 종료한다.Meanwhile, in order to apply the selection object collection algorithm using the position version described above, in the flowchart shown in FIG. 3, a process of checking the position version between the liberalized object determination and the finalization method existence determination is performed. In other words, when it is determined that the result of liberalization object is not determined, it is determined whether the location version stored in the object variable and the corresponding location version in the dynamic memory are the same. When the city generates a null pointer exception object indicating that the object is inaccessible, the collection of the object is terminated.

본 발명의 기술사상은 상기 바람직한 실시 예에 따라 구체적으로 기술되었으나 상기한 실시 예는 그 설명을 위한 것으로서, 본 발명의 기술분야의 통상의 전문가라면 본 발명의 기술사상의 범위에서 다양한 실시 예가 가능함을 이해할 수 있을 것이다.Although the technical spirit of the present invention has been described in detail according to the above-described preferred embodiment, the above-described embodiment is for the purpose of description, and various ordinary embodiments of the present invention may be made by those skilled in the art. I can understand.

이상에서 설명한 바와 같이 본 발명은 기존의 쓰레기 수집기를 사용하는 시스템에서 이를 그대로 사용하면서도 프로그래머가 최소한의 프로그래밍 오버헤드만을 부담하며 명시적으로 객체를 수거하게 함으로써, 어플리케이션의 수행의 안정성을 그대로 유지하면서 시스템자원을 절약할 수 있다. 예를 들어 1M의 동적 메모리가 있어 이중 200KB의 크기에 해당하는 객체들을 프로그래머가 본 발명에서 제시한 방법으로 객체들을 자유화하였다고 가정하면, 1MB + 200KB의 가용 메모리가 존재한다고 볼 수 있어 메모리의 이득을 얻는 셈이 된다. 또한, 200KB의 메모리를 어플리케이션의 객체 생성하는데 소비되는 시간만큼의 수집기 시작 시간을 연기할 수 있다. 3번의 수집 작업이 필요했던 어플리케이션이 1번 또는 2번의 수집 작업만으로 수행을 끝마칠 수 있어 시간의 이득을 얻을 수 있는 셈이다.As described above, the present invention allows a programmer to explicitly collect objects with minimal programming overhead while still using the same in a system using a conventional garbage collector, thereby maintaining the stability of the performance of the application. You can save resources. For example, suppose that there is 1M of dynamic memory and the objects corresponding to the size of 200KB are freed up by the programmer in the method proposed in the present invention. You get it. In addition, it is possible to postpone collector start time by the amount of time that is required to create 200KB of memory for an object of an application. An application that required three collections could complete its work with only one or two collections, thus gaining time.

Claims (6)

어플리케이션 프로그램이 실행되는 시스템에서 객체를 생성하는 방법에 있어서,In the method for creating an object in a system running an application program, 생성되는 객체의 위치에 대한 위치버전을 객체에 대한 정보가 들어있는 동적 메모리 상의 객체 정보 영역에 저장하는 단계;Storing a location version of the location of the created object in an object information area on a dynamic memory containing information about the object; 생성되는 객체참조가 특정 객체를 가리키고자할 때 해당 객체참조와 함께 해당 객체의 위치버전을 객체 참조 영역에 저장하는 단계;When the generated object reference is intended to point to a specific object, storing a location version of the object in the object reference area together with the object reference; 를 구비하는 것을 특징으로 하는 자동화된 동적 메모리 기반의 시스템에서 객체를 생성하는 방법.Method for creating an object in an automated dynamic memory-based system comprising a. 제1항에 있어서, 위치버전을 객체 정보 영역에 저장하는 단계는,The method of claim 1, wherein storing the location version in the object information area includes: 해당 객체 정보 영역에 있는 위치버전을 읽어와서 이를 1 증가시킨 후 이를 다시 객체 정보 영역에 저장하는 것을 특징으로 하는 동적 메모리 기반의 시스템에서 객체를 생성하는 방법.A method of creating an object in a dynamic memory based system, comprising: reading a location version in a corresponding object information area, incrementing it by one, and storing it in the object information area again. 제1항에 있어서, 객체 참조 영역에 위치버전을 저장하는 단계는,The method of claim 1, wherein the storing of the location version in the object reference region comprises: 객체 참조 영역 중 어드레스 포인터 저장 시에 낭비되는 영역에 동적 메모리 객체 정보 영역에 있는 해당 객체의 위치버전과 동일한 위치버전을 저장하는 것을 특징으로 하는 자동화된 동적 메모리 기반의 시스템에서 객체를 생성하는 방법.A method for creating an object in an automated dynamic memory based system, comprising storing a location version identical to a location version of a corresponding object in a dynamic memory object information area in an area wasted when storing an address pointer among object reference areas. 어플리케이션이 더 이상 사용하지 않는 객체를 수거하는 메쏘드를 시스템으로 전달하는 단계;Passing a method of collecting an object that is no longer used by the application to the system; 상기의 시스템이 선택객체를 수거하는 기능을 구비하지 않은 경우에 명시적으로 동적 메모리 또는 객체의 수거에 대한 요청 시에, 시스템은 이러한 오류와 관련된 예외객체를 어플리케이션에게 전달 및 수거 요청을 무시하는 시스템 인터페이스 단계; 및When the above system does not have the function of collecting the selection object, upon request for collection of dynamic memory or object explicitly, the system passes the exception object related to this error to the application and ignores the collection request. An interface step; And 상기의 수거메쏘드 실행불가 예외객체가 어플리케이션으로 전달되지 않은 경우에는 해당 선택객체를 동적 메모리에서 명시적으로 수거하는 작업을 수행하는 선택객체 수거 단계If the collection method execution exception is not delivered to the application, the collection process for collecting the selected object in dynamic memory. 를 구비한 어플리케이션이 동적 메모리에 저장된 객체를 직접 수거하는 방법.An application having a method for directly collecting an object stored in a dynamic memory. 제4항에 있어서, 선택객체 수거 단계는,The method of claim 4, wherein the collection of the selected objects, 수거대상이 되는 선택객체가 이미 자유화된 객체인 경우에는, 상기의 시스템은 해당 선택객체가 이미 자유화된 객체라는 것을 나타내는 널포인터 예외객체를 어플리케이션에 전달하고 선택객체 수거 메쏘드 작업을 종료하는 자유화 객체 판단단계;If the selection object to be collected is already a liberalized object, the system determines that the liberalization object passes a null pointer exception to the application indicating that the selection object is already liberalized and terminates the collection of selected objects. step; 상기의 시스템이 객체의 위치를 나타내는 위치버전 알고리즘을 지원하는 경우에는, 객체 정보 영역과 객체참조의 위치버전영역에 각각 저장되어 있는 위치버전을 비교 판단하여 서로 다른 경우에 널포인터 예외객체를 어플리케이션에 전달하고 선택객체 수거 메쏘드 작업을 종료하는 위치버전 판단단계;If the system supports the location version algorithm that indicates the location of the object, the location version stored in the object information area and the location version area of the object reference are compared and judged. A location version determining step of transmitting and ending a selection object collection method operation; 수거 대상이 되는 객체가 사용하고 있는 시스템 자원을 릴리즈(release)시켜주는 파이널라이즈(finalize) 작업이 필요한 경우에는 파이널라이즈 작업을 수행하는 단계;Performing a finalizing operation when a finalizing operation for releasing system resources used by the object to be collected is required; 메모리에 대한 락(lock)을 획득하는 단계;Obtaining a lock on the memory; 수거대상이 되는 객체가 있는 해당 동적 메모리 영역의 내용을 지우는 단계; 및Erasing the contents of the dynamic memory area including the object to be collected; And 동적 메모리에 대한 락을 삭제하는 단계Steps to Delete a Lock on Dynamic Memory 를 포함한 것을 특징으로 하는 어플리케이션이 동적 메모리에 저장된 객체를 직접 수거하는 방법.Method for directly collecting the object stored in the dynamic memory, characterized in that the application. 제5항에 있어서, 파이널라이즈 메쏘드를 수행하는 단계는,The method of claim 5, wherein performing a finalize method comprises: 모든 어플리케이션의 실행을 중단시킨 후 파이널라이즈 작업을 수행하고 다시 어플리케이션의 실행을 재개시키는 것을 특징으로 하는 어플리케이션이 동적 메모리에 저장된 객체를 직접 수거하는 방법.A method in which an application directly collects an object stored in dynamic memory after the execution of all applications is stopped and finalization is performed again.
KR1020020031900A 2002-06-07 2002-06-07 Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program KR20030094658A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020020031900A KR20030094658A (en) 2002-06-07 2002-06-07 Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020020031900A KR20030094658A (en) 2002-06-07 2002-06-07 Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program

Publications (1)

Publication Number Publication Date
KR20030094658A true KR20030094658A (en) 2003-12-18

Family

ID=32386194

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020020031900A KR20030094658A (en) 2002-06-07 2002-06-07 Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program

Country Status (1)

Country Link
KR (1) KR20030094658A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5652883A (en) * 1992-06-15 1997-07-29 Microsoft Corporation Computer method and system for conservative-stack and generational heap garbage collection
JPH10111830A (en) * 1996-10-08 1998-04-28 Fujitsu Ltd Dynamic storage area management device
JPH10320263A (en) * 1997-05-22 1998-12-04 Fujitsu Ltd Gc attachment device and program storage medium
JP2001101070A (en) * 1999-10-04 2001-04-13 Okuma Corp Method and device for managing memory
JP2001265649A (en) * 2000-01-11 2001-09-28 Fujitsu Ltd Memory management method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5652883A (en) * 1992-06-15 1997-07-29 Microsoft Corporation Computer method and system for conservative-stack and generational heap garbage collection
JPH10111830A (en) * 1996-10-08 1998-04-28 Fujitsu Ltd Dynamic storage area management device
JPH10320263A (en) * 1997-05-22 1998-12-04 Fujitsu Ltd Gc attachment device and program storage medium
JP2001101070A (en) * 1999-10-04 2001-04-13 Okuma Corp Method and device for managing memory
JP2001265649A (en) * 2000-01-11 2001-09-28 Fujitsu Ltd Memory management method and device

Similar Documents

Publication Publication Date Title
US6473773B1 (en) Memory management in a partially garbage-collected programming system
US6351794B1 (en) Computer resource management system
US6625808B1 (en) Method and apparatus for facilitating memory management in a program comprised of heterogeneous components
KR100472807B1 (en) System and method for automatically modifying database access methods to insert database object handling instructions
US7263700B1 (en) Serially, reusable virtual machine
US10296388B2 (en) Object optimal allocation device, method and program
US7024436B2 (en) Computer system with two heaps in contiguous storage
US7016923B2 (en) Multi-threaded garbage collector employing cascaded memory arrays of task identifiers to implement work stealing queues for task identification and processing
US7308466B2 (en) Memory reclamation method
US7454447B1 (en) Declarative pinning
US8176142B2 (en) Shared JAVA jar files
US7107426B2 (en) Computer system with heap reset for performing generational garbage collection implemented by card-marking between successive applications
US6996590B2 (en) Method and system for the garbage collection of shared data
US6845437B2 (en) Computer system with heap and card table
US6804765B2 (en) Computer system with multiple heaps
EP1260901A2 (en) Method and apparatus for managing hashed objects
US6094664A (en) Method and apparatus for optimizing the null pointer exception in an object-oriented programming environment with statically typed variables
US20090150465A1 (en) Object Deallocation System and Method
US6735761B1 (en) Compile method frame detection method and device code discarding method and computer
US20090228537A1 (en) Object Allocation System and Method
CN114051610A (en) Arena-based memory management
US6275985B1 (en) Method and apparatus for developing an application that implements garbage collection efficiently by combining proxy objects with compiler support
KR20030094658A (en) Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program
Mahar et al. Puddles: Application-Independent Recovery and Location-Independent Data for Persistent Memory
US11875193B2 (en) Tracking frame states of call stack frames including colorless roots

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E601 Decision to refuse application