Data processing method and device, electronic equipment and readable storage medium

CN119311372APending Publication Date: 2025-01-14LOONGSON TECH CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411356779.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-14

Smart Images

  • Figure CN119311372A_ABST
    Figure CN119311372A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method and device, electronic equipment and a readable storage medium. The method comprises the steps that a survival object corresponding to a target application program is traversed; analyzing a current target survival object in the survival objects, and respectively determining a current active state and a current compression level of the target survival object; the active state comprises an active state or an inactive state; the compression level comprises one of non-compression, lightweight compression, heavy compression and mixed compression; determining a target compression level of the target survival object according to the current active state and the current compression level; according to the target compression level, compressing the basic area of the target survival object; the base region contains a base data type field. The method can improve the memory utilization rate, reduce the garbage collection frequency, reduce the garbage collection overhead and improve the system performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device, electronic device and readable storage medium. Background Art

[0002] Garbage Collection (GC), also known as automatic memory management, is an important module of the virtual machine. It can free programmers from manually releasing memory, avoid memory leaks and dangling references, and thus ensure availability and memory safety.

[0003] During the execution of an application, when the remaining memory space cannot meet the space required to continue allocating new objects, the virtual machine will trigger garbage collection to recycle memory that is no longer used by the application to meet subsequent object allocations.

[0004] However, garbage collection usually requires more system resources. If garbage collection operations are triggered frequently, it will not only affect the execution of the application but also the performance of the entire system. Summary of the invention

[0005] In view of the above problems, an embodiment of the present invention is proposed to provide a data processing method that overcomes the above problems or at least partially solves the above problems, which can improve memory utilization, reduce garbage collection times, reduce garbage collection overhead, and improve system performance.

[0006] Correspondingly, an embodiment of the present invention further provides a data processing device, an electronic device, and a computer program product to ensure the implementation and application of the above method.

[0007] In a first aspect, an embodiment of the present invention discloses a data processing method, the method comprising:

[0008] Traverse the surviving objects corresponding to the target application;

[0009] Analyze the current target surviving object among the surviving objects, and determine the current active state and the current compression level of the target surviving object respectively; the active state includes active or inactive; the compression level includes one of no compression, lightweight compression, heavyweight compression and mixed compression;

[0010] Determining a target compression level of the target surviving object according to the current activity state and the current compression level;

[0011] According to the target compression level, the basic area of ​​the target surviving object is compressed to save the memory space occupied by the target application; the basic area includes a basic data type field.

[0012] In a second aspect, an embodiment of the present invention discloses a data processing device, the device comprising:

[0013] The object traversal module is used to traverse the surviving objects corresponding to the target application;

[0014] a state determination module, configured to analyze a current target surviving object among the surviving objects, and respectively determine a current active state and a current compression level of the target surviving object; the active state includes active or inactive; the compression level includes one of no compression, lightweight compression, heavyweight compression, and mixed compression;

[0015] A target determination module, configured to determine a target compression level of the target surviving object according to the current active state and the current compression level;

[0016] The object compression module is used to compress the basic area of ​​the target surviving object according to the target compression level to save the memory space occupied by the target application; the basic area includes a basic data type field.

[0017] In the third aspect, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the steps of any of the data processing methods described above.

[0018] In a fourth aspect, an embodiment of the present invention discloses a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the data processing method as described in any of the above can be implemented.

[0019] In a fifth aspect, an embodiment of the present invention discloses a computer program product, including a computer program, which, when executed by a processor, performs the steps of any of the data processing methods described above.

[0020] The embodiments of the present invention include the following advantages:

[0021] The data processing method of the present invention can be applied to the garbage collection process in a virtual machine, and the garbage collection process is based on objects. During the garbage collection process, the surviving objects corresponding to the application are traversed, and the target compression level suitable for the target surviving object is determined according to the real-time active state and compression level of the target surviving object. By compressing the basic area of ​​the target surviving object using the target compression level, the memory space occupied during the execution of the application can be effectively saved, the memory space utilization rate can be improved, the number of garbage collection times can be reduced, thereby reducing the system resources required for garbage collection and improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a flow chart of steps of an embodiment of a data processing method of the present invention;

[0023] Figure 2 It is a schematic diagram of the field structure of the object used in the present invention;

[0024] Figure 3 is a schematic diagram of the structure of object A before and after compression in an example of the present invention;

[0025] Figure 4 It is a schematic diagram of the process of compressing target surviving objects during garbage collection in the present invention;

[0026] Figure 5 is a schematic diagram of the structure of object B before and after decompression in an example of the present invention;

[0027] Figure 6 Yes Figure 5 Schematic diagram of the structure after object B is marked in the example;

[0028] Figure 7 It is a schematic diagram of the process of decompressing the target surviving object during the garbage collection process of the present invention;

[0029] Figure 8 is a structural block diagram of an embodiment of a data processing device of the present invention;

[0030] Fig. 9 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0032] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0033] In order to facilitate understanding of the technical solutions of the present invention, the following first explains the technical terms that may be involved in the embodiments of the present invention:

[0034] Garbage collection is the core concept of memory management in Java programming. The memory management mechanism of the Java Virtual Machine (JVM) is called the garbage collection mechanism, which is used to track objects in use and discover and recycle objects that are no longer in use.

[0035] Heap is an area in memory used to store objects (object instances). The heap is an area in memory managed by the Java virtual machine, which is shared by all threads. The heap is created when the Java virtual machine starts. When the Java virtual machine executes a Java program, it creates an object and allocates a piece of memory for the object in the heap, and the object is stored in the heap. Since the Java virtual machine will continue to create objects and allocate memory, if an object is no longer referenced, it will become a garbage object and need to be garbage collected, otherwise the memory will be consumed and affect the program operation.

[0036] Garbage collection thread (GC thread): A thread started by the Java virtual machine for garbage collection. The GC thread is used to manage objects in the heap. It can traverse, mark, and delete dead objects in the heap.

[0037] Surviving objects: objects in the heap that have a reference relationship with other objects. In this reference relationship, a first object pointing to a second object indicates that the first object references the second object, which can also be described as the second object being referenced by the first object.

[0038] Dead objects (also called orphan objects or garbage objects) are objects in the heap that have no reference to other objects.

[0039] Reference Figure 1, shows a flow chart of steps of an embodiment of a data processing method of the present invention, the method may include the following steps:

[0040] Step 101, traverse the surviving objects corresponding to the target application;

[0041] Step 102: Analyze the current target surviving object among the surviving objects, and determine the current active state and the current compression level of the target surviving object respectively; the active state includes active or inactive; the compression level includes one of no compression, lightweight compression, heavyweight compression and mixed compression;

[0042] Step 103: Determine a target compression level of the target surviving object according to the current active state and the current compression level;

[0043] Step 104: compress the basic area of ​​the target surviving object according to the target compression level to save the memory space occupied by the target application; the basic area includes a basic data type field.

[0044] The present invention provides a data processing method, which can be applied to electronic devices. The data processing method provided by the present invention uses objects in a Java virtual machine as units of garbage collection, compresses the basic data type fields (i.e., basic areas) in surviving objects, and determines a more appropriate target compression level according to the real-time active state and compression level of the surviving objects, so as to effectively save the memory space occupied during program execution, improve memory utilization, thereby reducing the number of garbage collections and reducing garbage collection overhead, thereby reducing the impact of garbage collection on application programs and improving system performance.

[0045] The electronic device may run multiple applications (such as Java programs), and each application corresponds to a respective virtual machine (such as a Java virtual machine). For example, the electronic device runs applications APP1 and APP2, the virtual machine running APP1 is recorded as JVM1, and the virtual machine running APP2 is recorded as JVM2. Each virtual machine starts a GC thread, such as JVM1 starts GC thread 1, and JVM2 starts GC thread 2. The GC thread is responsible for monitoring the memory usage in the heap and determining whether to execute the garbage collection (GC) process.

[0046] For example, during the execution of an application (such as APP1), when JVM1 cannot continue to allocate new objects for APP1 in the heap, APP1 can start GC thread 1 to execute the GC process, and APP1 is called the target application.

[0047] In an example, the GC process can be as follows: traverse all surviving objects in the heap of the target application, and each time a surviving object is traversed, copy the surviving object from the current memory area (called the from area) to a new area (called the to area). After all surviving objects in the from area are copied to the to area, the from area can be directly cleared, thereby completing a GC process.

[0048] In a specific implementation, there are many ways to implement the GC process, and the embodiment of the present invention does not limit the specific implementation method of the GC process.

[0049] In the case of relatively tight memory, after executing a GC process, the memory may soon be insufficient and the GC process may be triggered again, resulting in a high frequency of garbage collection, thereby affecting system performance. To solve this problem, in the process of executing GC, in the process of traversing the surviving objects corresponding to the target application, the embodiment of the present invention compresses the basic area of ​​each surviving object (the surviving object currently traversed is called the target surviving object) to save the memory space occupied by the target application, improve memory utilization, and thus reduce the number of garbage collections. Furthermore, the embodiment of the present invention does not use the same compression algorithm for all surviving objects, but each time a surviving object is traversed, according to the current active state and current compression level of the surviving object, a target compression level that is more suitable for the surviving object is determined, and the compression algorithm corresponding to the target compression level is used to compress the basic area of ​​the surviving object, so as to maximize the memory utilization of inactive objects and effectively reduce the decompression overhead when accessing active objects.

[0050] It should be noted that the above steps 101 to 104 can be a synchronous process called and executed when the virtual machine triggers garbage collection, or can be an asynchronous execution process called by the virtual machine when the target application runs for a period of time. That is, the embodiment of the present invention can synchronously execute steps 101 to 104 during the garbage collection process, and compress the traversed surviving objects using a suitable compression algorithm during the stage of traversing the surviving objects corresponding to the target application during the garbage collection process to improve memory utilization; or, during the operation of the target application, the embodiment of the present invention can actively and asynchronously execute steps 101 to 104 periodically or when it is detected that the allocatable memory is lower than a preset threshold, so as to improve memory utilization, further reduce the frequency of triggering garbage collection, and thus reduce the system resources required for garbage collection.

[0051] In the specific implementation, the field of the object consists of an object header and instance data. Among them, the object header is used to store the runtime data and type pointer of the object itself. The runtime data includes hash code, GC generation age, lock status flag, etc. The type pointer is used to indicate which class the object is an instance of. Instance data is the data actually stored by the object, and the contents of various types of fields defined in the application are stored in the instance data part. The types of fields are mainly divided into reference data types (oop types) and basic data types (char, short, int, long, etc.). The basic data type field stores the data of the object itself, and the reference data type field stores the address of the sub-object referenced by the object.

[0052] The field structures of objects used by different virtual machines are different. Figure 2 , shows a schematic diagram of the field structure of the object used in the present invention. Figure 2 As shown, the instance data part is divided into a reference area and a basic area, the reference area contains all reference data type fields of the object; the basic area contains all basic data type fields of the object; wherein the basic area is placed at the end of the object field. In a specific implementation, in order to facilitate the traversal and search of the object, the fields in the reference area may not be compressed, but only the fields in the basic area may be compressed. Of course, in a specific implementation, in order to further improve the compression rate, on the basis of compressing the basic data type fields (basic area) using the method of the present invention, the reference data type fields (reference area) may also be compressed, and the embodiment of the present invention does not limit this.

[0053] In the process of performing garbage collection on a target application, an embodiment of the present invention traverses the surviving objects corresponding to the target application. The currently traversed target surviving object is analyzed to determine the current active state and the current compression level of the target surviving object; the active state includes active or inactive. If the current active state of the target surviving object is active, the target surviving object is called an active object; if the current active state of the target surviving object is inactive, the target surviving object is called an inactive object.

[0054] In the embodiment of the present invention, the execution process of garbage collection is a process of traversing and determining whether an object is alive, and reclaiming the memory space occupied by the dead object.

[0055] A dead object is an object that is no longer referenced in the heap. A live object is an object that is still referenced by other objects in the heap. The embodiment of the present invention does not limit the method of determining whether an object is a dead object or a live object. Exemplarily, each object in the heap may correspond to a reference count, and whenever a reference points to an object, the reference count of the object is increased by 1; when a reference to the object is invalid, the reference count of the object is decreased by 1; if the reference count of an object in the heap is 0, the object is a dead object; if the reference count of the object is greater than 0, the object is a live object.

[0056] For another example, the Java virtual machine can use an object reference graph for memory management, which includes the reference relationships between objects in the heap. Starting from the root object, traverse the object reference graph to determine whether the object is reachable. A reachable object is a live object; an unreachable object means that the object has no reference connection to the root object, and the object is a dead object. Among them, the root object refers to an object that can only reference other objects but cannot be referenced by other objects.

[0057] The active state is used to indicate whether a live object is an active object or an inactive object. An object that has been recently accessed (read / written) is an active object, whereas an object that has not been accessed for a continuous period of time is an inactive object. The embodiment of the present invention determines a target compression level that is more suitable for the target live object based on the current active state and the current compression level of the target live object, so as to effectively reduce the overhead of compression and decompression while improving memory utilization.

[0058] In an optional embodiment of the present invention, respectively determining the current active state and the current compression level of the target surviving object may include:

[0059] Read a first flag bit and a second flag bit in the object header of the target surviving object; determine the current active state corresponding to the target surviving object according to the first flag bit; and determine the current compression level corresponding to the target surviving object according to the second flag bit.

[0060] The present invention can set a first flag bit in the object header, and the first flag bit can be 1 bit in the object header. The first flag bit is used to indicate the active state of the object. Exemplarily, the first flag bit is 0 for active, and the first flag bit is 1 for inactive.

[0061] In a Java program, the keyword new is used to create an object. When the JVM (Java Virtual Machine) executes the new instruction, it will allocate memory space for the newly created object in the heap and perform necessary initialization operations, such as setting the object header. Furthermore, when a new object is initialized, the first flag bit in the object header of the object can be initialized to 0, indicating that it is an active object. When the object is garbage collected, the first flag bit in the object header of the object can be changed from 0 to 1, indicating that it is an inactive object. When the inactive object is accessed again, the first flag bit in the object header of the object can be changed from 1 to 0, that is, the object becomes an active object.

[0062] The compression level of an object can indicate the degree of compression. When a compressed object is accessed, it needs to be decompressed to obtain the original data. Different compression levels require different decompression methods. Exemplarily, the compression level of an object can include the following four levels: no compression, lightweight compression, heavyweight compression, and mixed compression.

[0063] No compression means that the basic area of ​​the object remains in the current state without compression, and the basic area stores the original data. Lightweight compression means that the basic area of ​​the object is compressed using a lightweight compression algorithm, and the basic area stores data compressed using a low-compression algorithm that consumes less resources. Heavyweight compression means that the basic area of ​​the object is compressed using a heavyweight compression algorithm, and the basic area stores data compressed using a high-compression algorithm that consumes more resources. Hybrid compression means that the basic area of ​​the object is first compressed using a lightweight compression algorithm, and then the lightweight compressed data is further compressed using a heavyweight compression algorithm, and the basic area stores data compressed using a low-compression algorithm and a high-compression algorithm.

[0064] Among them, lightweight compression algorithm refers to a low compression rate algorithm that consumes less resources, such as bitmap compression algorithm. Bitmap compression algorithm uses bits to store data. For example, 1 bit is used to represent 1 byte of data. If 1 byte of data is all 0, it is represented by 1 bit of 0, and the 1 byte of data is deleted; if 1 byte of data is not all 0, it is represented by 1 bit of 1, and the 1 byte of data remains unchanged. The bitmap compression algorithm has a better compression effect on data containing more 0s. For lightweight compressed data, the original data can be quickly obtained without decompression.

[0065] Heavyweight compression algorithms refer to high-compression algorithms that consume more resources, such as gzip, zlib, lz4, etc. For heavyweight compressed data, the original data can be obtained by decompressing it using the corresponding compression algorithm.

[0066] Lightweight compression is suitable for active objects. It has a fast compression speed and can quickly obtain the original data without decompressing the entire data. Because active objects are frequently accessed, for active objects with lightweight compression, the original data in the object can be quickly obtained, and no additional space is required to store the decompressed objects, which can effectively reduce the decompression overhead when accessing active objects.

[0067] Heavyweight compression and mixed compression are suitable for inactive objects, with a high compression rate, but the compression and decompression speed is slow, and partial decompression is not possible. When decompressing, additional space is required to decompress all data to obtain the original data. Therefore, heavyweight compression is not suitable for active objects, but for inactive objects that are rarely accessed, due to the low number of compression and decompression, once compressed, it is likely that they will not be decompressed. Therefore, using heavyweight compression or mixed compression levels for inactive objects can achieve higher memory space utilization.

[0068] Hybrid compression is to use lightweight compression first and then heavyweight compression. It is mainly used when inactive objects have been compressed using lightweight compression levels, and heavyweight compression is further used to obtain higher memory space utilization.

[0069] Optionally, the present invention can set a second flag bit in the object header, and the second flag bit can be n bits in the object header. The second flag bit is used to indicate the current compression level of the object. The larger the value of n is, the more types of compression levels can be indicated.

[0070] In a specific implementation, the embodiment of the present invention traverses the surviving objects corresponding to the target application during the process of garbage collection of the memory space occupied by the target application; analyzes the current target surviving object among the surviving objects, and determines the current active state and the current compression level of the target surviving object. For example, the current active state and the current compression level of the target surviving object are determined by reading the first flag bit and the second flag bit in the object header of the target surviving object. Based on the current active state and the current compression level, a target compression level that is more suitable for the target surviving object is determined; based on the target compression level, the basic area of ​​the target surviving object is compressed to further save the memory space occupied by the target application.

[0071] To facilitate description of the technical solution of the present invention, the embodiment of the present invention is described by taking the value of n as 2. For example, 00 indicates no compression, 01 indicates lightweight compression, 10 indicates heavyweight compression, and 11 indicates mixed compression.

[0072] When a new object is created, the second flag bit in the object header of the object can be initialized to 00, that is, not compressed, and the object is original data. During the garbage collection process, the present invention determines whether the target surviving object needs to be compressed and the target compression level to be adopted according to the current active state and current compression level of the target surviving object. In this process, if the current compression level of the target surviving object is consistent with the current state of the target surviving object, it can be determined that the target compression level maintains the current compression level unchanged; if the current compression level of the target surviving object does not meet the current state of the target surviving object, a more appropriate target compression level is determined, and the target compression level may be different from the current compression level.

[0073] In the garbage collection process, in the stage of traversing live objects, the embodiment of the present invention determines the current active state and the current compression level of the traversed live objects while traversing the live objects, thereby determining a suitable compression method. Specifically, for the target live object currently traversed, the embodiment of the present invention determines the target compression level of the target live object according to the current active state and the current compression level of the target live object; and compresses the basic area of ​​the target live object according to the target compression level.

[0074] For example, if the target surviving object is an active object, and the current compression level is lightweight compression, it means that the compression level currently used by the target surviving object is already the most suitable compression level, so the current compression level can be maintained unchanged. For another example, if the target surviving object is an active object, and the current compression level is uncompressed. That is, the data of the target surviving object is uncompressed original data, then it can be determined that the target compression level of the target surviving object is lightweight compression. That is, a lightweight compression algorithm can be used to compress the basic area of ​​the target surviving object to improve memory utilization.

[0075] For another example, if the target surviving object is an inactive object, a more suitable target compression level is further determined according to the current compression level of the target surviving object.

[0076] The embodiment of the present invention adopts a more suitable target compression level for different target surviving objects according to the current activity state and current compression level of the target surviving objects. On the basis of improving memory utilization, the efficiency of compressing and decompressing objects can be improved, thereby improving the efficiency of accessing objects.

[0077] In an optional embodiment of the present invention, determining the target compression level of the target surviving object according to the current activity state and the current compression level may include:

[0078] Step S11, determining the current active state, and if the current active state is active, determining the current compression level;

[0079] Step S12: If the current compression level is lightweight compression, determine the target compression level of the target surviving object to maintain the current compression level unchanged;

[0080] Step S13: If the current compression level is no compression, determine the target compression level of the target surviving object as lightweight compression.

[0081] For the target live object currently traversed, first read the first flag and the second flag in the object header of the target live object. Determine the current active state of the target live object through the first flag. If the target live object is an active object, further determine the current compression level of the target live object through the second flag.

[0082] If the current compression level of the target surviving object is lightweight compression, since lightweight compression is suitable for active objects, the current compression level of the target surviving object is a suitable compression level, so the target compression level can be determined to maintain the current compression level unchanged.

[0083] If the current compression level of the target surviving object is no compression, it means that the target surviving object has not been compressed yet, then the target compression level can be determined to be lightweight compression, that is, a lightweight compression algorithm can be used to compress the basic area of ​​the target surviving object.

[0084] It is understandable that, in a specific implementation, since active objects are frequently accessed, in order to improve the access efficiency of active objects on the basis of improving memory utilization, a compression level applicable to active objects may be set to include lightweight compression or no compression.

[0085] In an optional embodiment of the present invention, the method may further include:

[0086] After compressing the basic area of ​​the target surviving object, the compression level of the target surviving object is updated, and the data in the basic area is replaced with compressed data corresponding to the target compression level.

[0087] The compressed data corresponding to the target compression level refers to the data after the basic area is compressed using the compression algorithm corresponding to the target compression level. For example, for the target surviving object currently traversed, the first flag bit and the second flag bit in the object header of the target surviving object are read. Assume that the first flag bit is 0 and the second flag bit is 00. That is, the target surviving object is currently an active object, and the current compression level of the target surviving object is uncompressed, then the target compression level is determined to be lightweight compression, and the compression algorithm corresponding to the lightweight compression level (i.e., lightweight compression algorithm) can be used to compress the basic area of ​​the target surviving object, and after compression, the second flag bit in the object header of the target surviving object is modified to 01, indicating that the current compression level of the target surviving object is lightweight compression. For example, when compressing the basic area of ​​the target surviving object, the compression algorithm corresponding to the lightweight compression level can be called in the allocated cache space to compress the basic area of ​​the target surviving object to obtain compressed data, and the data in the basic area of ​​the target surviving object is replaced with the compressed data.

[0088] Reference Figure 3 , shows a schematic diagram of the structure of an object A before and after compression in an example, Figure 3 (a) is a schematic diagram of the structure of object A before compression. Before compression, the first flag bit in the object header of object A is 0, the second flag bit is 00, and the basic area of ​​object A contains the original data before compression. Figure 3 (b) is a schematic diagram of the structure of object A after compression. After compression, in the object header of object A, the first flag bit is 0, the second flag bit is 01, and the basic area of ​​object A contains data compressed using a lightweight compression algorithm.

[0089] In an optional embodiment of the present invention, determining that the target compression level of the target surviving object is lightweight compression may include:

[0090] Determine whether the compression rate of lightweight compression performed on the basic area of ​​the target surviving object meets a preset value. If so, determine that the target compression level of the target surviving object is lightweight compression; if not, determine that the target compression level maintains the current compression level unchanged.

[0091] In order to further improve the compression ratio and avoid invalid compression, the present invention determines whether the compression ratio of lightweight compression performed on the basic area of ​​the target surviving object meets the preset value (i.e. exceeds the preset value) before determining that the target compression level is lightweight compression. The compression ratio refers to the percentage by which the size of the data is reduced compared to the original data after compression. For example: 100m of data is compressed to 90m, and the compression ratio is (100-90) / 100*100%=10%. For the same data, the higher the compression ratio, the smaller the compressed data. The compression ratio meets the preset value, indicating that the size of the compressed data is reduced to the expected extent relative to the size of the data before compression. The preset value can be set as needed.

[0092] Exemplarily, assuming that the preset value is 3%, it means that the size of the compressed data is at least 3% smaller than the size of the basic area before compression.

[0093] For example, assuming that the preset value is 3%, and the compression rate of the basic area of ​​the target surviving object subjected to lightweight compression is 3% or greater than 3%, it is determined that the compression rate of the basic area of ​​the target surviving object subjected to lightweight compression meets the preset value, and the target compression level can be determined to be the lightweight compression level. For another example, if the compression rate of the basic area of ​​the target surviving object subjected to lightweight compression is less than 3%, such as 1% or 2%, it does not meet the preset value of 3%, indicating that the use of lightweight compression is not meaningful, and even after lightweight compression, no larger space can be obtained, and it can be determined that the target compression level maintains the current compression level (i.e., no compression) unchanged.

[0094] In an optional embodiment of the present invention, after determining the current active state, the method may further include:

[0095] Step S21: If the current active state is inactive, determine the current compression level;

[0096] Step S22: If the current compression level is lightweight compression, determine that the target compression level of the target surviving object is mixed compression;

[0097] Step S23: If the current compression level is heavyweight compression or mixed compression, determine the target compression level to maintain the current compression level unchanged;

[0098] Step S24: If the current compression level is no compression, then compare the compression rates of lightweight compression and heavyweight compression performed on the basic area of ​​the target surviving object, and determine the one that meets the preset value and has a higher compression rate as the target compression level; if both do not meet the preset value, then determine the target compression level to maintain the current compression level unchanged.

[0099] For the currently traversed target surviving object, first determine the current active state of the target surviving object through the first flag bit in the object header of the target surviving object. If the target surviving object is an inactive object, further determine the current compression level of the target surviving object.

[0100] If the target surviving object is an inactive object and the current compression level is lightweight compression, since inactive objects are not frequently accessed, using heavyweight compression with a higher compression rate is beneficial to saving more space. Therefore, heavyweight compression can be further performed on the target surviving object based on lightweight compression, and the target compression level can be determined to be mixed compression.

[0101] If the target surviving object is an inactive object and the current compression level is heavyweight compression or mixed compression, it means that the current compression level of the target surviving object is already a suitable compression level. Therefore, it can be determined that the target compression level maintains the current compression level (ie, heavyweight compression or mixed compression) unchanged.

[0102] If the target surviving object is an inactive object and the current compression level is no compression, the two compression levels of heavyweight compression and lightweight compression can be compared to evaluate which compression level can save more space, and the one with a higher compression rate and meeting the preset value is selected as the target compression level to further improve the memory space utilization. If the compression rates of both compression levels do not meet the preset value, that is, both compression levels cannot obtain a larger memory space after compression, then the target compression level is determined to maintain the current compression level (i.e., no compression) unchanged.

[0103] Exemplarily, if the target surviving object is an inactive object, and the current compression level of the target surviving object is not compressed, lightweight compression and heavyweight compression are simultaneously performed on the basic area of ​​the target surviving object, and the compression ratios of the two are determined. If the compression ratio of lightweight compression is higher, and the compression ratio of lightweight compression meets the preset value, the target compression level is determined to be lightweight compression. After lightweight compression is performed on the basic area of ​​the target surviving object, the second flag bit in the object header of the target surviving object is modified to 01, and the data in the basic area of ​​the target surviving object is replaced with the lightweight compressed data.

[0104] If the compression rate of performing heavyweight compression is higher and the compression rate of performing heavyweight compression meets the preset value, the target compression level is determined to be heavyweight compression. After performing heavyweight compression on the basic area of ​​the target surviving object, the second flag bit in the object header of the target surviving object is modified to 10, and the data in the basic area of ​​the target surviving object is replaced with the heavyweight compressed data.

[0105] If the compression ratio of performing lightweight compression and the compression ratio of performing heavyweight compression do not meet the preset value, the target compression level is determined to maintain the current compression level (ie, no compression) unchanged.

[0106] In an optional embodiment of the present invention, determining that the target compression level of the target surviving object is mixed compression may include:

[0107] Determine whether the compression rate of the re-executed heavyweight compression is greater than the compression rate corresponding to the current lightweight compression; if so, determine that the target compression level of the target surviving object is mixed compression; otherwise, determine that the target compression level maintains the current compression level unchanged.

[0108] For the target surviving object currently traversed, if the target surviving object is an inactive object, and the current compression level of the target surviving object is lightweight compression, heavyweight compression can usually be further performed on the basis of lightweight compression to further reduce the data size and improve memory space utilization. However, there may be a situation where the data size does not decrease significantly or even becomes larger after further performing heavyweight compression. At this time, it is not meaningful to further perform heavyweight compression. Therefore, on the basis that lightweight compression has been performed on the inactive object, it can be determined whether the compression rate of performing heavyweight compression is greater than the current compression rate; if so, the target compression level is determined to be mixed compression, so that heavyweight compression can be further performed on the basis of lightweight compression to obtain more available memory space after heavyweight compression; otherwise, it is estimated that no larger space can be obtained after compression, then the target compression level can be determined to maintain the current compression level (i.e., lightweight compression) unchanged.

[0109] Optionally, the determination of whether the compression ratio of re-executing heavyweight compression is greater than the compression ratio corresponding to the current lightweight compression includes: allocating cache space, further performing heavyweight compression on the basic area of ​​the target surviving object in the cache space on the basis of lightweight compression, and determining whether the compression ratio after performing heavyweight compression is greater than the compression ratio corresponding to the current lightweight compression.

[0110] Furthermore, if the compression ratio after heavyweight compression is greater than the compression ratio corresponding to the current lightweight compression, the target compression level of the target surviving object is determined to be mixed compression; the compression of the basic area of ​​the target surviving object includes: replacing the data in the basic area of ​​the target surviving object with the data after heavyweight compression in the cache space, and reclaiming the cache space.

[0111] Furthermore, if the compression ratio after heavyweight compression is less than or equal to the compression ratio corresponding to the current lightweight compression, the current basic area of ​​the target surviving object is kept unchanged (lightweight compressed data), and the cache space is reclaimed.

[0112] Reference Figure 4 , showing a schematic diagram of a process of compressing target surviving objects during garbage collection in the present invention, including the following steps:

[0113] Step A1, traverse to the target surviving object;

[0114] Step A2: determine the current active state of the target surviving object; if the target surviving object is an active object, execute step A3; if it is an inactive object, execute step A7;

[0115] Step A3, determine the current compression level of the active object; if the current compression level is 01, i.e., lightweight compression, there is no need to modify the current compression level of the target surviving object, determine the target compression level to maintain the current compression level unchanged, and execute step A14; if the current compression level is 00, i.e., no compression, determine the target compression level to be lightweight compression, and execute step A4; (active objects only have two compression levels: no compression and lightweight compression)

[0116] A4. Perform lightweight compression on the basic area of ​​the target surviving object;

[0117] A5, determining whether the compression rate of the basic area of ​​the target surviving object performing lightweight compression meets the preset value; if so, executing step A6; if not, there is no need to modify the current compression level of the target surviving object (i.e., keep it uncompressed), and executing step A14;

[0118] A6. Modify the second flag bit in the object header of the target surviving object to 01, i.e., the lightweight compression level, and replace the data in the basic area of ​​the target surviving object with the lightweight compression result, i.e., the data obtained after performing lightweight compression on the basic area of ​​the target surviving object, and then execute step A14;

[0119] A7, determine the current compression level of the inactive object; if the current compression level is 01, i.e., lightweight compression, determine the target compression level to be mixed compression, and execute step A11; if the current compression level is 10, i.e., heavyweight compression, or the current compression level is 11, i.e., mixed compression, there is no need to modify the current compression level of the target live object, determine the target compression level to maintain the current compression level unchanged, and execute A14; if the current compression level is 00, i.e., no compression, execute step A8;

[0120] A8. Perform light compression and heavy compression on the basic area of ​​the target surviving object respectively;

[0121] A9. Determine which compression ratio is higher between lightweight compression and heavyweight compression; if the compression ratio of lightweight compression is higher and the compression ratio meets the preset value, determine the target compression level to be lightweight compression, and execute step A6; if the compression ratio of heavyweight compression is higher and the compression ratio meets the preset value, determine the target compression level to be heavyweight compression, and execute step A10; if both compression ratios do not meet the preset value, there is no need to modify the current compression level of the target surviving object, that is, keep it uncompressed, and execute step A14;

[0122] A10, modifying the second flag bit in the object header of the target surviving object to 10, and replacing the data in the basic area of ​​the target surviving object with the heavyweight compression result, that is, the data obtained after performing heavyweight compression on the basic area of ​​the target surviving object, and then executing step A14;

[0123] A11. Further perform heavyweight compression on the lightly compressed data, that is, perform hybrid compression;

[0124] A12, determining whether the compression rate after further performing heavyweight compression on the light-weight compressed data is higher than that before performing heavyweight compression; if so, executing step A13; otherwise, keeping the light-weight compressed data unchanged, not performing heavyweight compression, and executing step A14;

[0125] A13, modifying the second flag bit in the object header of the target surviving object to 11, and replacing the data in the basic area of ​​the target surviving object with the mixed compression result, that is, the data obtained by further performing heavyweight compression on the lightly compressed data;

[0126] A14. Continue to execute the subsequent steps of garbage collection.

[0127] The above steps A1 to A14 are the process of processing (whether to compress and how to compress) the target surviving object currently traversed during the garbage collection process and in the process of traversing the surviving objects. After traversing and processing all the surviving objects, the dead objects can be recycled to release the memory space occupied by the dead objects. The present invention traverses the surviving objects of the application during the garbage collection process, and compresses the traversed target surviving objects according to the target compression level, which can improve the utilization of memory space, reduce the number of garbage collection times, and reduce the garbage collection overhead.

[0128] It should be noted that the embodiment of the present invention mainly describes the process of how to compress the target surviving object, and does not describe in detail the specific process of garbage collection. After compressing the target surviving object, step A14 is executed to perform other operations of the garbage collection process.

[0129] In an optional embodiment of the present invention, the method may further include:

[0130] When the target application accesses the target surviving object, the compressed basic area of ​​the target surviving object is decompressed according to the current active state and the current compression level of the target surviving object to obtain the decompressed target surviving object.

[0131] After the target surviving object is compressed, the basic area of ​​the target surviving object needs to be decompressed when accessing the target surviving object to obtain the decompressed original data. For target surviving objects of different compression levels, different decompression algorithms need to be used to decompress them to obtain the decompressed target surviving object, so that the target surviving object can be accessed.

[0132] Furthermore, the embodiment of the present invention adopts different compression levels for active objects and inactive objects. For active objects that are frequently accessed, lightweight compression is adopted, and the compression speed is fast, and the original data can be quickly obtained without decompressing the entire data. For inactive objects that are rarely accessed, heavyweight compression or mixed compression is adopted, which can save a lot of memory space. Since inactive objects are rarely accessed, it is rarely necessary to decompress inactive objects, and the probability of reducing memory space due to decompression of inactive objects is low.

[0133] Furthermore, in order to avoid the situation where the memory space is reduced due to the decompression of inactive objects, thereby affecting the normal operation of the application, a baseline value for triggering garbage collection can be set. When the available memory space in the heap is less than the baseline value, the garbage collection process can be automatically triggered to release the memory space occupied by dead objects.

[0134] Specifically, when an application accesses a target live object, the current active state and the current compression level of the target live object can be obtained by reading the first flag bit and the second flag bit in the object header of the target live object. First, the current active state of the target live object is determined. If the target live object is an active object, the current compression level of the target live object is further determined.

[0135] If the current compression level of the target live object is uncompressed, it can be accessed directly. If the current compression level of the target live object is lightweight compression, since lightweight compression can obtain the original data without decompression, it is only necessary to obtain the required original data according to the corresponding parsing method of lightweight compression. For example, for lightweight compressed data, the bit with a value of 0 is parsed as 1 byte of 0 data, and the bit with a value of 1 directly obtains the original 1 byte of data.

[0136] If the target surviving object is an inactive object, the current compression level of the target surviving object is further determined, so as to determine a specific decompression algorithm for decompression and access.

[0137] Furthermore, the method may also include:

[0138] After the application accesses the target live object, the active state of the target live object is modified to active. Exemplarily, the first flag bit in the object header of the target live object is modified to 0.

[0139] In an optional embodiment of the present invention, decompressing the compressed basic area of ​​the target surviving object according to the current active state and the current compression level of the target surviving object to obtain the decompressed target surviving object may include:

[0140] Step S31: If the current active state of the target surviving object is inactive, and the current compression level is heavyweight compression or mixed compression, a first memory space is allocated;

[0141] Step S32: decompressing the compressed basic area of ​​the target surviving object in the second memory space, and storing the decompressed target surviving object in the first memory space;

[0142] Step S33: updating the compression level and active state of the decompressed target surviving object in the first memory space;

[0143] Step S34: modify the reference address pointed to by the object header of the compressed target surviving object to the address corresponding to the first memory space.

[0144] When the target application wants to access the compressed target surviving object, the current active state of the target surviving object is first determined. If the target surviving object is currently an inactive object, the current compression level of the target surviving object is further determined.

[0145] If the current compression level of the target surviving object is heavyweight compression or mixed compression, a memory space (called the first memory space) needs to be allocated during decompression to store the decompressed target surviving object. The size of the first memory space is equal to the memory size occupied by the target surviving object before compression. For ease of explanation, in an embodiment of the present invention, the original storage space of the compressed target surviving object is referred to as the second memory space. The first memory space and the second memory space can be two memory spaces in the heap. That is, when the target application wants to access the compressed target surviving object, the compressed target surviving object is stored in the second memory space in the heap. If the current compression level of the target surviving object is heavyweight compression or mixed compression, the compressed target surviving object needs to be decompressed to the first memory space, so that the decompressed target surviving object can be accessed by accessing the first memory space. Since the compressed target surviving object in the second memory space is no longer used, the second memory space can be reclaimed.

[0146] To facilitate distinction, the embodiment of the present invention refers to the decompressed target surviving object (that is, the target surviving object stored in the first memory space) as a new object, and the target surviving object before decompression (that is, the compressed target surviving object stored in the second memory space) as an old object. Next, the compression level of the new object is modified to the current compression level of the new object, and the reference address pointed to by the object header of the old object is modified to the address of the first memory space. Thus, the decompressed target surviving object can be accessed by accessing the address of the first memory space. In addition, since the new object is accessed by the application, the active state of the new object needs to be modified, such as changing it to active.

[0147] Reference Figure 5 , shows a schematic diagram of the structure of an object B before and after decompression in an example, assuming that the compression level of object B is heavyweight compression. Figure 5 As shown in (a), it is a schematic diagram of the structure of object B before decompression. Before decompression, it is called an old object (denoted as object B). In the object header of object B, the first flag bit is 1, indicating an inactive object; the second flag bit is 10, indicating that the compression level is heavyweight compression; the basic area contains data compressed using the heavyweight compression algorithm. Figure 5 As shown in (b), it is a schematic diagram of the structure of object B after decompression. After decompression, it is called a new object (denoted as object B'). Object B' is in the first memory space. In the object header of object B', the first flag bit is 0, indicating an active object; the second flag bit is 00, indicating that the compression level is uncompressed; the basic area is the original data obtained after decompression.

[0148] In this example, object B' is stored in the first memory space, and the address of object B' is recorded as addr(B'); object B is stored in the second memory space, and the address of object B is recorded as addr(B). Object B is the compressed data, and object B' is the decompressed data. The embodiment of the present invention modifies the reference address pointed to by the object header of object B to addr(B'). The reference address pointed to by the object header is used to indicate the actual access address. When an application or other object wants to access object B, according to the reference address addr(B') pointed to by the object header of object B, it can be known that the address should be accessed, so that the pointer originally pointing to object B can be modified to point to the new object.

[0149] Furthermore, the difference between the decompression process of heavyweight compression and hybrid compression is that hybrid compression needs to go through a two-step decompression process to obtain the final original data.

[0150] Optionally, if the current active state of the target surviving object is inactive, for heavyweight compression, the decompression process is as follows:

[0151] Step S41: If the current active state of the target surviving object is inactive, and the current compression level of the target surviving object is heavyweight compression, a first memory space is allocated;

[0152] Step S42: decompress the basic area of ​​the target surviving object according to the decompression algorithm corresponding to the heavyweight compression algorithm, and store the decompressed target surviving object (new object) into the first memory space;

[0153] Step S43: modifying the compression level of the new object to uncompressed, and modifying the active state of the new object to active;

[0154] Step S44: modify the reference address pointed to by the object header of the old object to the address of the first memory space.

[0155] Optionally, if the current active state of the target surviving object is inactive, for hybrid compression, the decompression process is as follows:

[0156] Step S51: If the current active state of the target surviving object is inactive, and the current compression level of the target surviving object is mixed compression, a first memory space is allocated;

[0157] Step S52: decompress the basic area of ​​the target surviving object according to the decompression algorithm corresponding to the heavyweight compression algorithm, and store the decompressed target surviving object (new object) into the first memory space;

[0158] Step S53: modifying the compression level of the new object to lightweight compression, and modifying the active state of the new object to active;

[0159] Step S54: modify the reference address pointed to by the object header of the old object to the address of the first memory space.

[0160] At this time, the target surviving object of the mixed compression has undergone the first step of decompression (decompression corresponding to heavyweight compression), and the decompressed target surviving object obtained by the first step of decompression is still compressed data. That is, at this time, the compression level of the new object stored in the first memory space is lightweight compression, and the second step of decompression (parsing method corresponding to lightweight compression) is required. The second step of decompression does not require the execution of a real decompression process, and the original data can be quickly obtained through parsing. Further, after step S54, it can also include:

[0161] Step S55: parse the basic area of ​​the new object in the first memory space according to the lightweight compression algorithm to obtain the original data. Since the lightweight compressed data can directly and quickly obtain the original data, the lightweight compressed data does not need to be restored to the original data.

[0162] In an optional embodiment of the present invention, after storing the decompressed target surviving object (new object) in the first memory space, the method may further include:

[0163] Step S61: Mark the compressed target surviving object (old object) in the second memory space;

[0164] Step S62: performing garbage collection on the memory space occupied by the marked target surviving objects.

[0165] For an inactive target surviving object, if the compression level is heavyweight compression or mixed compression, when the application needs to access the target surviving object, the target surviving object will be decompressed to the newly allocated first memory space, thereby accessing the decompressed target surviving object in the first memory space, such as Figure 5 The object B' in (b) is the old object (the target surviving object compressed in the second memory space, such as Figure 5 The object B) in (a) is no longer accessed, so the old object can be marked. When garbage collection is performed next time, the memory space occupied by the marked target surviving object can be reclaimed to release the memory space occupied by the old object and improve the memory space utilization.

[0166] Reference Figure 6 , showing the Figure 5 The structural diagram of object B after marking in the example. Figure 5It can be seen that object B' is a new object obtained after decompression and is stored in the first memory space. Object B is an old object that has not been decompressed and is stored in the second memory space. After decompressing the new object (such as object B') in the first memory space, the embodiment of the present invention marks the old object (such as object B) in the second memory space. The mark is used to indicate that the object has been decompressed to the new memory space, and if you want to access the object, you need to access it in the new memory space.

[0167] Optionally, marking the compressed target surviving object (old object) in the second memory space may include: setting a preset mark in the object header of the old object (such as object B) in the second memory space. It should be noted that the preset mark is different from the aforementioned first flag bit and second flag bit, for example, the positions of the marks are different for distinction. The present invention does not limit the preset mark, for example, the preset mark is 11.

[0168] Furthermore, since the old object (such as object B) in the second memory space is no longer needed, the object header of the old object can be directly replaced with the preset mark (such as 11) and the address of the new object (such as addr(B')), such as Figure 6 shown.

[0169] Among them, the memory space occupied by the marked target surviving object is recycled, which can specifically include: if the preset mark is traversed during the next garbage collection process, all pointers to the target surviving objects (old objects) that need to access the preset mark are modified to point to the corresponding new objects, such as pointing to the address addr(B'), so that the new object (object B') can be accessed. In this way, the old object (object B) will become a dead object relative to the surviving object because it is not referenced by any other object. During the garbage collection process, the corresponding garbage collection process will automatically recycle the space occupied by the old object.

[0170] Reference Figure 7 , showing a schematic diagram of a process of decompressing a target surviving object during garbage collection in the present invention, comprising the following steps:

[0171] B1, the target surviving object to be accessed by the application;

[0172] B2. Determine the current active state of the target surviving object; if the target surviving object is currently an active object, execute step B12; if the target surviving object is currently an inactive object, execute step B3;

[0173] B3, determining the current compression level of the inactive object; if the current compression level of the inactive object is 00 (no compression) or 01 (lightweight compression), executing step B11; otherwise, executing step B4;

[0174] B4, allocating a first memory space according to the size of the original object; if the current compression level of the inactive object is 10 (heavyweight compression) or 11 (mixed compression), allocate a new memory space (first memory space) on the heap according to the original size of the target surviving object before compression; and determine the current compression level of the inactive object; if the current compression level of the inactive object is 10, execute step B8; if the current compression level of the inactive object is 11, execute step B5;

[0175] B5. If the current compression level of the inactive object is 11, i.e., mixed compression, the target surviving object is decompressed to the first memory space according to the decompression algorithm corresponding to the heavyweight compression algorithm; specifically, the basic area of ​​the target surviving object is decompressed according to the decompression algorithm corresponding to the heavyweight compression algorithm, and the decompressed target surviving object (new object) is stored in the newly allocated memory space (first memory space);

[0176] B6. Change the second flag bit in the object header of the new object to 01, that is, the lightweight compression level, and change the first flag bit in the object header of the new object to 0, that is, the active state;

[0177] B7, point the object header of the old object to the address of the new object, and mark the old object; that is, modify the address pointed to by the object header of the old object to point to the address of the first memory space, and execute step B13;

[0178] B8. Decompress the target surviving object to the first memory space according to the decompression algorithm corresponding to the heavyweight compression algorithm; that is, decompress the basic area of ​​the target surviving object according to the decompression algorithm corresponding to the heavyweight compression algorithm, and store the decompressed target surviving object (new object) to the newly allocated memory space (first memory space);

[0179] B9. Change the second flag bit in the object header of the new object to 00, that is, no compression level, and change the first flag bit in the object header of the new object to 0, that is, active state;

[0180] B10, point the object header of the old object to the address of the new object and mark the old object; then execute step B14;

[0181] B11. Change the first flag bit in the object header of the target surviving object to 0, that is, active state;

[0182] B12, determine the current compression level of the active object, if it is 00, that is, no compression, execute step B14; otherwise, execute step B13;

[0183] B13, parsing the basic area of ​​the target surviving object according to the parsing method corresponding to the lightweight compression algorithm to obtain the original data;

[0184] B14. The application continues to execute.

[0185] In summary, the data processing method of the present invention can be applied to the garbage collection process in a virtual machine, and the garbage collection process is based on objects. During the garbage collection process, the surviving objects corresponding to the application are traversed, and the target compression level suitable for the target surviving object is determined according to the real-time active state and compression level of the target surviving object. By compressing the basic area of ​​the target surviving object using the target compression level, the memory space occupied during the execution of the application can be effectively saved, the memory space utilization rate can be improved, the number of garbage collection times can be reduced, thereby reducing the system resources required for garbage collection and improving system performance.

[0186] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0187] Reference Figure 8 , shows a structural block diagram of an embodiment of a data processing device of the present invention, the device may include:

[0188] The object traversal module 501 is used to traverse the surviving objects corresponding to the target application in the process of garbage collection of the memory space occupied by the target application;

[0189] A state determination module 502 is used to analyze the current target surviving object among the surviving objects, and determine the current active state and the current compression level of the target surviving object respectively; the active state includes active or inactive; the compression level includes one of no compression, lightweight compression, heavyweight compression and mixed compression;

[0190] A mode determination module 503, configured to determine a target compression level of the target surviving object according to the current active state and the current compression level;

[0191] The object compression module 504 is used to compress the basic area of ​​the target surviving object according to the target compression level to save the memory space occupied by the target application; the basic area includes a basic data type field.

[0192] Optionally, the mode determination module includes:

[0193] A first judgment submodule is used to judge the current active state, and if the current active state is active, then judge the current compression level;

[0194] A first determination submodule is used to determine the target compression level of the target surviving object to maintain the current compression level unchanged if the current compression level is lightweight compression;

[0195] The second determination submodule is used to determine the target compression level of the target surviving object as lightweight compression if the current compression level is no compression.

[0196] Optionally, the second determining submodule is specifically configured to:

[0197] Determine whether the compression rate of lightweight compression performed on the basic area of ​​the target surviving object meets a preset value. If so, determine that the target compression level of the target surviving object is lightweight compression; if not, determine that the target compression level maintains the current compression level unchanged.

[0198] Optionally, the device further comprises:

[0199] A second judgment submodule, configured to judge the current compression level if the current active state is inactive;

[0200] A third determination submodule, configured to determine, if the current compression level is lightweight compression, that the target compression level of the target surviving object is mixed compression;

[0201] A fourth determination submodule, configured to determine the target compression level to maintain the current compression level unchanged if the current compression level is heavyweight compression or mixed compression;

[0202] The fifth determination submodule is used to compare the compression rates corresponding to lightweight compression and heavyweight compression performed on the basic area of ​​the target surviving object if the current compression level is no compression, and determine the one that meets the preset value and has a higher compression rate as the target compression level; if both do not meet the preset value, determine the target compression level to maintain the current compression level unchanged.

[0203] Optionally, the third determining submodule is specifically configured to:

[0204] Determine whether the compression rate of the re-executed heavyweight compression is greater than the compression rate corresponding to the current lightweight compression; if so, determine that the target compression level of the target surviving object is mixed compression; otherwise, determine that the target compression level maintains the current compression level unchanged.

[0205] Optionally, the device further comprises:

[0206] The modification and replacement module is used to update the compression level of the target surviving object after compressing the basic area of ​​the target surviving object, and replace the data in the basic area with the compressed data corresponding to the target compression level.

[0207] Optionally, the state determination module is specifically configured to:

[0208] Read a first flag bit and a second flag bit in the object header of the target surviving object; determine the current active state corresponding to the target surviving object according to the first flag bit; and determine the current compression level corresponding to the target surviving object according to the second flag bit.

[0209] Optionally, the device further comprises:

[0210] The object decompression module is used to decompress the compressed basic area of ​​the target surviving object according to the active state and compression level of the target surviving object when the target application accesses the target surviving object, so as to obtain the decompressed target surviving object.

[0211] Optionally, the object decompression module includes:

[0212] A space allocation submodule, configured to allocate a first memory space if the current active state of the target surviving object is inactive and the current compression level is heavyweight compression or mixed compression;

[0213] a decompression storage submodule, configured to decompress the compressed basic area of ​​the target surviving object located in the second memory space, and store the decompressed target surviving object in the first memory space;

[0214] A state updating submodule, used for updating the compression level and active state of the decompressed target surviving object in the first memory space;

[0215] The address modification submodule is used to modify the reference address pointed to by the object header of the compressed target surviving object to the address corresponding to the first memory space.

[0216] Optionally, the device further comprises:

[0217] An object marking module, used for marking the compressed target surviving object in the second memory space;

[0218] The object recycling module is used to perform garbage collection on the memory space occupied by the marked target surviving objects.

[0219] The data processing device of the present invention can be applied to the garbage collection process in a virtual machine, and the garbage collection process is based on objects. During the garbage collection process, the surviving objects corresponding to the application are traversed, and the target compression level suitable for the target surviving object is determined according to the real-time active state and compression level of the target surviving object. By compressing the basic area of ​​the target surviving object using the target compression level, the memory space occupied during the execution of the application can be effectively saved, the memory space utilization rate can be improved, the number of garbage collection times can be reduced, thereby reducing the system resources required for garbage collection and improving system performance.

[0220] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0221] Reference Fig. 9 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 6 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the steps of the data processing method of the aforementioned embodiment.

[0222] An embodiment of the present invention provides a non-transitory computer-readable storage medium. When instructions in the storage medium are executed by a program or processor of a terminal, the terminal is enabled to execute the steps of the data processing method of the aforementioned embodiment.

[0223] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0224] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0225] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0226] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0227] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0228] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0229] Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A data processing method, characterized in that: The method comprises: Traverse the surviving objects corresponding to the target application; Analyze the current target surviving object among the surviving objects, and determine the current active state and the current compression level of the target surviving object respectively; the active state includes active or inactive; the compression level includes one of no compression, lightweight compression, heavyweight compression and mixed compression; Determining a target compression level of the target surviving object according to the current activity state and the current compression level; According to the target compression level, the basic area of ​​the target surviving object is compressed to save the memory space occupied by the target application; the basic area includes a basic data type field.

2. The method according to claim 1, characterized in that The step of determining a target compression level of the target surviving object according to the current active state and the current compression level comprises: Determine the current active state, and if the current active state is active, determine the current compression level; If the current compression level is lightweight compression, determining the target compression level of the target surviving object to maintain the current compression level unchanged; If the current compression level is no compression, the target compression level of the target surviving object is determined to be lightweight compression.

3. The method according to claim 2, characterized in that The determining that the target compression level of the target surviving object is lightweight compression includes: Determine whether the compression rate of lightweight compression performed on the basic area of ​​the target surviving object meets a preset value. If so, determine that the target compression level of the target surviving object is lightweight compression; if not, determine that the target compression level maintains the current compression level unchanged.

4. The method according to claim 2, characterized in that After determining the current active state, the method further includes: if the current active state is inactive, determining the current compression level; If the current compression level is lightweight compression, determining the target compression level of the target surviving object to be mixed compression; If the current compression level is heavyweight compression or mixed compression, determining the target compression level to maintain the current compression level unchanged; If the current compression level is no compression, the compression rates of lightweight compression and heavyweight compression performed on the basic area of ​​the target surviving object are compared, and the one that meets the preset value and has a higher compression rate is determined to be the target compression level; if both do not meet the preset value, the target compression level is determined to maintain the current compression level unchanged.

5. The method according to claim 4, characterized in that The determining that the target compression level of the target surviving object is mixed compression includes: Determine whether the compression rate of the re-executed heavyweight compression is greater than the compression rate corresponding to the current lightweight compression; if so, determine that the target compression level of the target surviving object is mixed compression; otherwise, determine that the target compression level maintains the current compression level unchanged.

6. The method according to claim 1, characterized in that The method further comprises: After compressing the basic area of ​​the target surviving object, the compression level of the target surviving object is updated, and the data in the basic area is replaced with compressed data corresponding to the target compression level.

7. The method according to claim 1, characterized in that The determining the current active state and the current compression level of the target surviving object respectively includes: Reading a first flag bit and a second flag bit in an object header of the target surviving object; Determine the current active state of the target surviving object according to the first flag bit; The compression level currently corresponding to the target surviving object is determined according to the second flag bit.

8. The method according to claim 1, characterized in that: The method further includes: decompressing the compressed basic area of ​​the target surviving object to obtain the decompressed target surviving object, specifically: If the current active state of the target surviving object is inactive, and the current compression level is heavyweight compression or mixed compression, allocating the first memory space; decompressing the compressed basic area of ​​the target surviving object in the second memory space, and storing the decompressed target surviving object in the first memory space; Updating the compression level and active state of the decompressed target surviving object in the first memory space; The reference address pointed to by the object header of the compressed target surviving object is modified to an address corresponding to the first memory space.

9. The method according to claim 8, characterized in that After storing the decompressed target surviving object in the first memory space, the method further includes: Marking the compressed target surviving object in the second memory space; Perform garbage collection on the memory space occupied by the marked target surviving objects.

10. A data processing device, characterized in that: The device comprises: The object traversal module is used to traverse the surviving objects corresponding to the target application; a state determination module, configured to analyze a current target surviving object among the surviving objects, and respectively determine a current active state and a current compression level of the target surviving object; the active state includes active or inactive; the compression level includes one of no compression, lightweight compression, heavyweight compression, and mixed compression; A target determination module, configured to determine a target compression level of the target surviving object according to the current active state and the current compression level; The object compression module is used to compress the basic area of ​​the target surviving object according to the target compression level to save the memory space occupied by the target application; the basic area includes a basic data type field.

11. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the steps of the data processing method according to any one of claims 1 to 9.

12. A readable storage medium, characterized in that: The readable storage medium stores programs or instructions, and when the programs or instructions are executed by the processor, the steps of the data processing method according to any one of claims 1 to 9 are implemented.

13. A computer program product, comprising a computer program, characterized in that The computer program is executed by a processor according to the steps of the data processing method according to any one of claims 1 to 9.