Garbage recovery mobile communication terminal of Java virtual machine and recovery method thereof

A technology of mobile communication terminal and java virtual machine, which is applied in the field of mobile communication terminals for garbage collection, can solve problems such as inability to control the timing of garbage collection, and achieve the effect of ensuring accuracy

Inactive Publication Date: 2008-07-16
ZTE CORP
2 Cites 19 Cited by

AI-Extracted Technical Summary

Problems solved by technology

The disadvantage of this patent is that the virtual object heap and physical object heap are not suitable for the implementation of devices with small memory such as mobile ...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Method used

[0075] Traverse the bitmap, determine the location of the value type object, and collect the value type object into a continuous block to obtain a larger amount of available memory and reduce memory fragmentation.
[0080] Compared with the prior art, the present invention introduces a garbage collection mobile communication terminal of a Java virtual machine and a recycling method. The garbage collection method of the present invention can be passively scheduled and executed by the scheduling module as a system thread according to the priority assigned by the system or actively executed due to insufficient memory. Just because of its schedulability, it can run when the system is idle, instead of pa...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Abstract

The invention discloses a rubbish recovery mobile communication terminal and a rubbish recovery method for a Java virtual machine. The method of the invention comprises the following steps: context environment of a current thread is preserved; all running objects in a memory of the Java virtual machine are traversed, and accessible objects are marked and types of the accessible objects are recorded; memory space of the Java virtual machine which is occupied by unmarked objects is incorporated and released; memory space of the accessible objects is contracted; the convex environment of the current thread is recovered. The invention can rightly distinguish types of objects which are used by a system and predict and record the size of free memories in a memory zone, thereby accuracy of operation of the system is guaranteed. Moreover, the invention divides a system memory into memory blocks with fixed size and the accessible objects are collected into a continuous zone for realization of constrictive memory fragmentation management on allocated memories.

Application Domain

Technology Topic

System usageJava virtual machine +4

Image

  • Garbage recovery mobile communication terminal of Java virtual machine and recovery method thereof
  • Garbage recovery mobile communication terminal of Java virtual machine and recovery method thereof
  • Garbage recovery mobile communication terminal of Java virtual machine and recovery method thereof

Examples

  • Experimental program(1)

Example Embodiment

[0041] The technical features of the present invention will be described in detail below in conjunction with embodiments and drawings.
[0042] Figure 1 is a schematic diagram of the overall structure of the present invention.
[0043] In the mobile communication terminal 100, the operating system 130 runs on the hardware 140, and the Java virtual machine 120 performs related operations based on the operating system 130 to provide a running platform for each application software 110. The mobile communication terminal 100 includes a mobile phone, a PDA, and the like. The Java virtual machine 120 includes various functional modules such as a garbage collection module 200, a runtime environment 201, and a Java virtual machine scheduling module 202. The garbage collection module 200 will perform garbage collection operations for the runtime environment 201. The runtime environment 201 is the method area, the heap, the execution stack of the thread, the register, etc., which are applied during the system runtime. The Java virtual machine scheduling module 202 is used to schedule various functional modules in the Java virtual machine, so that each module sequentially obtains the execution time of the processor. Other functional modules are common modules in the prior art.
[0044] Each functional module in the Java virtual machine, including the garbage collection module 200, has a priority parameter, and the Java virtual machine scheduling module 202 will call according to the priority parameter of each functional module. After the garbage collection module 200 runs as a low-priority thread for a period of time, the Java virtual machine will dynamically increase its priority periodically. This ensures that when all other threads are in the waiting state, the garbage collection thread with low priority can still be executed, thereby dynamically adjusting the available memory of the system, or actively executing when the memory is insufficient.
[0045]Please refer to FIG. 2 which shows a schematic diagram of a specific structure of the garbage collection module 200 of the present invention.
[0046] The garbage collection module 200 includes a memory division module 210, a context preservation module 220, a marking module 230, a memory consolidation module 240, a compaction module 250, and a context restoration module 260.
[0047] The memory dividing module 210 is used to divide the system memory into fixed-size blocks when the garbage collection module 200 is run for the first time, so as to reduce the complexity of moving objects and avoid memory fragmentation. For example, each block can be divided into 32 bytes. A Java object usually occupies one or more blocks in the memory space, and the blocks may not be physically continuous.
[0048] The context saving module 220 is used to save the context of the current thread. The context environment mainly includes the current thread's execution stack pointer, related structures in the current execution stack, and the current program counter pointer. These pointers are used to restore the system context after the garbage collection process.
[0049] The marking module 230 is used to mark all reachable objects in the Java virtual machine. The reachable objects are objects that are still used by the program. The reachable objects include global objects and temporary objects in the Java virtual machine, as well as global variables and symbol tables in the Java virtual machine, and class tables used to record all currently loaded classes. The marking module 230 also includes a bitmap recording module 231. The bitmap recording module is used to define a bitmap. The bits in the bitmap correspond to the memory space of the Java virtual machine; The type of the reachable object is recorded, and the memory space of the Java virtual machine occupied by the object of the reference type or the value type is in the corresponding position in the bitmap.
[0050] The memory merging module 240 is used to merge and release the memory space of the Java virtual machine occupied by the unmarked objects; it can also be used to calculate the maximum available memory in the current system.
[0051] The compaction module 250 is used to compact the memory space of the value type or reference type object when the current amount of memory is insufficient to reduce memory fragmentation.
[0052] The context restoration module 260 is used to restore the context of the current thread according to the saved context of the current thread.
[0053] Please refer to FIG. 3 which shows a flowchart of specific processing steps of the present invention.
[0054] In step 301, the Java virtual machine scheduling module 202 calls the garbage collection module 200 according to the priority parameter, and the garbage collection module 200 starts to run.
[0055] Step 302: When the garbage collection module 200 is run for the first time, the memory division module 210 is used to divide the Java virtual machine memory into fixed-size blocks.
[0056] Step 303: Use the context saving module 220 to save the context of the current thread.
[0057] If the current thread is not empty, save the context of the current thread, especially the execution stack pointer of the current thread, the relevant structure in the current execution stack, and the current program counter pointer. These pointers are used to restore the system context after the garbage collection process.
[0058] Step 304: Traverse all runtime objects in the memory of the Java virtual machine, use the marking module 230 to mark all reachable objects in the Java virtual machine, and record the types of reachable objects.
[0059] Since the global variables in the JVM and the class table used to record all currently loaded classes are accessible during the entire JVM runtime, they should also be marked.
[0060] Please refer to FIG. 4 for a detailed implementation flowchart of step 304 of the present invention.
[0061] Step 401: Traverse all runtime objects in the memory of the Java virtual machine, and for reachable objects, set the flag in front of the object.
[0062] The flag bit is a flag bit set in the data structure representing each object.
[0063] Step 402: Perform recursive marking processing on the child objects of the marked reachable objects in the memory, that is, the indirect reachable objects.
[0064] Step 403: Define a bitmap for correspondingly recording the memory space of the java virtual machine of the mobile communication terminal 100.
[0065] One bit in the bitmap corresponds to, for example, a byte in the memory of the java virtual machine.
[0066] Step 404: For the reachable objects, the space occupied by the value type object is marked as "0" in the bitmap, and the space occupied by the reference type object is set in the bitmap, that is, the corresponding mark is "1", the corresponding bit containing the quoted word is also marked as "1".
[0067] Of course, the space occupied by the value type object can also be set in the bitmap, that is, the corresponding mark is "1", and the space occupied by the reference type object is correspondingly marked as "0" in the bitmap.
[0068] This marking method can quickly distinguish between value type and reference type objects, and know exactly where the references of all objects are distributed. The garbage collection algorithm of the present invention correctly distinguishes the value and reference type of the object used by the system, and the size of the memory occupied by the reachable object in the memory area can be predicted and recorded through the bitmap, thereby obtaining the size of the free memory at the same time. This ensures the accuracy of system operation and minimizes memory overhead.
[0069] Please continue to refer to Figure 3.
[0070] Step 305: Use the memory merging module 240 to merge and release the memory space of the Java virtual machine occupied by the unmarked objects.
[0071] That is, the memory space of the Java virtual machine occupied by the unreachable object is released to make it free memory and re-applied.
[0072] Step 306: Calculate the current maximum available memory in the system, and determine whether the maximum available memory is greater than the amount of memory currently required by the system, if not, proceed to step 307, if yes, proceed to step 310.
[0073] In step 307, the compression module 250 is used to perform compression processing.
[0074] Traverse the bitmap, determine the position of the object of the reference type, and reclaim its space according to the flag bit of the object of the reference type; and/or
[0075] Traverse the bitmap, determine the position of the value type object, and collect the value type object into a continuous block to obtain a larger amount of available memory and reduce memory fragmentation.
[0076] In step 308, it is determined whether the current available memory is greater than the amount of memory currently required by the system, if not, step 309 is executed, and if so, step 310 is executed.
[0077] In step 309, an exception is thrown, the current thread is terminated, the context environment is restored, and step 311 is executed.
[0078] Step 310: Restore the context environment and allocate appropriate memory space for the thread.
[0079] In step 311, the garbage collection module 200 gives up the processor to wait for the next scheduling.
[0080] Compared with the prior art, the present invention introduces a garbage collection mobile communication terminal and a recycling method of a Java virtual machine. The garbage collection method of the present invention can be passively executed by the scheduling module as a system thread according to the priority given by the system or actively executed due to insufficient memory. It is precisely because of its schedulability that it can run when the system is idle instead of passively executing when the memory is insufficient, thereby effectively using system resources. Therefore, the present invention is a progressively running garbage collection method. The garbage collection algorithm of the present invention can also correctly distinguish the types of objects used by the system, and predict and record the size of the free memory in the memory area. This ensures the accuracy of system operation. In addition, the garbage collection algorithm of the present invention divides the system memory into fixed-size memory blocks, and then collects the reachable objects in a continuous area, so as to realize the memory fragment management that compresses the allocated memory.
[0081] The protection scope of the present invention is not limited to the above description, and those skilled in the art can make modifications or changes according to the concept of the present invention, and they should fall within the scope of the concept of the present invention.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Similar technology patents

Intelligent metering management system and method for construction engineering

InactiveCN101504741AGuaranteed accuracyGuaranteed science and accuracyResourcesManagement systemEngineering humans
Owner:ROAD AND BRIDGE CONSTRUCTION

Method for extracting center line of coronary artery blood vessel

ActiveCN108133478AGuaranteed accuracyImprove efficiencyImage enhancementImage analysisThree vesselsDelaunay triangulation
Owner:SUZHOU RAINMED MEDICAL TECH CO LTD

Classification and recommendation of technical efficacy words

Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products