CN110543357B - Method, related device and system for managing application program object - Google Patents

Method, related device and system for managing application program object Download PDF

Info

Publication number
CN110543357B
CN110543357B CN201810519626.1A CN201810519626A CN110543357B CN 110543357 B CN110543357 B CN 110543357B CN 201810519626 A CN201810519626 A CN 201810519626A CN 110543357 B CN110543357 B CN 110543357B
Authority
CN
China
Prior art keywords
storage area
area
storage
new generation
turn
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810519626.1A
Other languages
Chinese (zh)
Other versions
CN110543357A (en
Inventor
单卫华
李旭良
宋安印
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Cloud Computing Technologies Co Ltd
Original Assignee
Huawei Cloud Computing Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Cloud Computing Technologies Co Ltd filed Critical Huawei Cloud Computing Technologies Co Ltd
Priority to CN201810519626.1A priority Critical patent/CN110543357B/en
Publication of CN110543357A publication Critical patent/CN110543357A/en
Application granted granted Critical
Publication of CN110543357B publication Critical patent/CN110543357B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method for managing application program objects, a related device and a system, wherein the method can be applied to a virtual machine, a memory space of the virtual machine comprises a first storage area, the first storage area is used for storing objects with survival turns smaller than preset turns, and the method comprises the following steps: creating a first object of an application in a first storage area; constructing a second object from the first object in the first storage area as a "substitute" for the first object, the second object occupying less storage space than the first object, i.e. the second object is simpler than the first object; the first object in the first storage area is stored to a storage area outside the first storage area. The method can reduce the problems of object stacking and Full GC in the old generation area and improve the performance of the application program.

Description

Method, related device and system for managing application program object
Technical Field
The present invention relates to the field of computer information storage technologies, and in particular, to a method, a related apparatus, and a system for managing application objects.
Background
The problem of memory occupation and release is always a problem of major concern in large-scale application development, and currently, an internal Garbage Collection (GC) method is usually adopted to optimize memory occupation and improve the running performance of a system/application. GC is an automatic memory management mechanism, and the main purpose is to find useless objects in the memory and to recycle the memory space occupied by them.
Taking a Java Virtual Machine (JVM) as an example, a memory space called "heap" is planned in the memory to store objects (Java objects) of Java applications. The heap is divided into a new generation area for storing objects with a shorter life cycle and an old generation area for storing objects with a longer life cycle. Among them, garbage collection in the new generation area is called Minor garbage collection (Minor GC), and garbage collection in the old generation area is called complete garbage collection (Full GC).
Minor GC adopts a copy algorithm to realize garbage collection in a new generation area. The new generation region is almost where all objects were created, i.e., the memory space where the objects apply for storage is present in the new generation region, and most objects generally do not need to survive for a long time. After the memory space occupied by the new generation region reaches a certain space threshold value, the virtual machine carries out Minor GC on the new generation region, and the space occupied by the inactive object is recycled. For some long-term active (long-life cycle) subjects, each time a Minor GC is decocted in a new generation area, the age of the subject is added by 1, and when the age of the subject reaches a preset threshold, the subjects are moved to an old generation area.
The Full GC typically employs a mark-and-clear algorithm to achieve garbage collection in the aged generation area. The old age area generally allocates more memory space than the new age area, and because of its relatively large memory space, the number of times of Full GC in the old age area is not as frequent as that of the new age area Minor GC, and the time for performing Full GC once in the old age area is longer (even more than 10 times) than that of performing Full GC once in the new age area. If the objects in the old generation area are quoted for a long time, stacking occurs in the old generation area, when the available space of the old generation area is insufficient due to excessive stacking, full GC on the whole virtual machine heap memory is triggered, all threads in the virtual machine process are stopped at the moment, namely, all work activities of the virtual machine application program are suspended at the moment, and the application program is greatly degraded in performance due to the Full GC process.
Disclosure of Invention
The embodiment of the invention provides a method for managing application program objects, a related device and a system, which can greatly reduce and even avoid the problems of object stacking and Full GC in an old generation area and improve the performance of the application program.
In a first aspect, embodiments of the present invention provide a method for managing application objects, which is applied to a virtual machine (e.g., JVM), which refers to a special software entity that can create an environment between a computer platform and an end user, and the end user can run an application based on the environment created by the virtual machine. The application constructs objects that are stored in the new generation area during the application process. The virtual machine is not limited to the Java environment, but may be applied to other hosted languages such as Scala, groovy, and the like. The memory space of the virtual machine includes a first storage area, where the first storage area is used to store an object whose survival turn is smaller than a preset turn, where the survival turn refers to an age of the object in the first storage area, and the age of the object still living in the first storage area increases by 1 every time the first storage area performs a Garbage Collection (GC) operation, and it can be understood that, under an existing memory management mechanism, if the survival turn of the object reaches the preset turn (for example, the preset turn is 15), the object will be moved out of the first storage area. The method comprises the following steps: the first object of the application is created in the first storage area, for example, after the application receives the data of the client, a complex object (such as EventData) inside the system is created, and the complex object is the first object. In the embodiment of the present invention, if the object cannot be released quickly during the service processing, and the residence time in the first storage area is long, so that the age of the object can reach the preset threshold, such an object may be regarded as a complex object; in the first storage area, constructing a second object for replacing the first object according to the first object, wherein the storage space occupied by the second object is smaller than that occupied by the first object; storing the first object in the first storage area to a storage area other than the first storage area.
It can be seen that in the embodiment of the present invention, before the first object (complex object) is not moved out of the first storage area, a new simple object (second object) is used to replace the complex object in the first storage area, and then when the first object needs to be used again, the associated first object can be restored by using the second object. Because the memory occupied by the second object is smaller than or even far smaller than the memory occupied by the first object, on one hand, the speed of the memory occupied in the first storage area reaching the space threshold is greatly delayed, namely, the frequency of GC generation in the first storage area is greatly reduced; on the other hand, since the age of the second object hardly reaches the preset threshold value, the second object may be in the first storage area for a longer time than the first object. Even more, the second object may be cleared from the GC by the time its age reaches a preset threshold, and its life cycle is completed (i.e., the second object becomes an inactive object). Therefore, the embodiment of the invention is beneficial to avoiding the problem that the first object is moved out of the first storage area (for example, moved to other areas similar to the old generation area) due to the memory management mechanism, does not influence the normal use object of the application program, and improves the performance of the application program.
Based on the first aspect, in a specific implementation manner, the method is specifically applied to a JVM virtual machine, where a memory space of the virtual machine includes a heap space, and the heap space includes a new generation region and an old generation region, the new generation region is used to store objects whose survival turns are smaller than the preset turns, and the old generation region is used to store objects whose survival turns are greater than or equal to the preset turns. It is understood that the age of a subject still living in the new generation region increases by 1 for each round of Minor GC in the new generation region, and it is understood that the subject is moved from the new generation region to the old generation region if the survival round of the subject reaches a preset round. For example, if the preset round is 15, then subjects whose survival round cannot reach 15 will remain in the new generation area until cleared; for an object whose survival turn can reach (exceed) 15, it is stated that the object can stay for the Minor GC of 15 turns, i.e. its life cycle (i.e. total life duration) is longer than the total time of the Minor GC of 15 turns in the new generation area, and it can be understood that such an object would be stored in the old generation area after all if it is under the prior art. The method specifically comprises the following steps: in the new generation region, creating a first object of the application; determining whether to construct the second object for the first object; if the determination result is that the second object is constructed for the first object, constructing a second object used for replacing the first object according to the first object in the new generation area, wherein the memory space occupied by the second object is smaller than the memory space occupied by the first object; and storing the first object (specifically, the serialized first object for example) in a storage area outside the new generation area and the old generation area.
That is, in this embodiment, in order to avoid that a complex object (i.e., a first object) is referenced for a long time and stacked in an old generation area to cause Full GC during the running of an application, an ID object (i.e., a second object) is used to replace the complex object in a new generation area before the complex object is not moved to the old generation area, and then the associated complex object can be restored by using the ID object when the complex object needs to be used again. Because the memory occupied by the ID object is smaller than or even far smaller than the memory occupied by the complex object, on one hand, the speed of the memory occupation in the new generation region reaching the space threshold is greatly delayed, namely, the frequency of Minor GC generation in the new generation region is greatly reduced, and the use efficiency of the memory is improved; on the other hand, ID objects are in new generation areas for a longer time than complex objects. Even more, most ID objects may end their life cycle before their age reaches a preset threshold, and are cleared in the Minor GC. Therefore, the embodiment of the invention is beneficial to preventing the complex object from entering the old generation area and improving the performance of the application program.
Based on the foregoing embodiment of the first aspect, in a possible embodiment, since the object created in the new generation may be an object with a shorter life cycle (i.e. the survival turn is less than the preset turn), or may be an object with a longer life cycle (i.e. the survival turn can reach the preset turn), the object with a shorter life cycle will certainly die in the area of the new generation and will not enter the area of the old generation; therefore, the embodiment of the present invention focuses on the object whose life cycle is long and which may enter the area of the elderly generation, and such an object may be a complex object. Therefore, after an object is created, it is determined whether the object is the complex object.
In a possible embodiment, it is determined whether the estimated rotation of survival of the first object is greater than or equal to the preset rotation, and if the rotation of survival of the first object can reach the preset rotation, the determination result is to construct the second object for the first object. Wherein the estimated survival turns are pre-estimated survival turns that can reach and exceed a preset turn. For example, the preset turn is 15, and it can be determined in advance according to historical experience that a certain object is a complex object, for example, it is estimated that the survival turn of the object in the new generation region can reach 15, and the life cycle of the object can be longer than the total time of the Minor GC of 15 turns, so that such a first object is the estimated complex object.
In a possible embodiment, it is determined whether the survival turn of a class of a particular object type is greater than or equal to the preset turn; if the survival turn of the class of the specific object type can reach the preset turn and the object type of the first object belongs to the specific object type, the determination result is to construct the second object for the first object, wherein a class is a set of specific object types having the same attribute and common behavior, it can be understood that if a certain class (e.g. a certain array) is a set of complex objects, then if the first object belongs to the class, the first object is a complex object. For such a first object, the determination results in construction of the second object for the first object.
Based on the foregoing implementation manner of the first aspect, in a possible embodiment, before storing the first object in the new generation region into a storage region outside the new generation region and the old generation region, the method includes: and carrying out serialization processing on the first object to obtain a serialized first object. The serialization is a process of converting state information of a complex object into a byte sequence which can be stored or transmitted, and the serialized object is the byte sequence;
correspondingly, the storing the first object in the new generation region to a storage region outside the new generation region and the old generation region includes: storing the serialized first object in a storage area outside the new generation area and the old generation area. The serialization processing can be beneficial to transmission and storage of the first object, and when the first object is needed to be used subsequently, the serialized object is deserialized correspondingly, so that the original first object can be recovered. Among them, the deserialization is a process of restoring a byte sequence to an object.
Based on the above-described implementation of the first aspect, in a specific embodiment, the constructed second object (simple object) contains an identification (e.g. a unique identification UID) of the first object (complex object), so this simple object may in turn be referred to as an ID object. Specifically, the identifier may be transmitted as a parameter together with the complex object when the ID object construction module is called, or the identifier may be carried in the complex object and extracted by the ID object construction module, or the identifier may be generated by the ID object construction module according to the complex object.
In a possible embodiment, the ID object further includes location information indicating a storage location of the serialized complex object in a storage area outside the new generation area and the old generation area, so that the corresponding complex object is restored by the ID object later.
In an application scenario, the second object contains both the identifier and the location information of the first object, and then, when the application needs to call the first object, the procedure for calling the first object is described as follows: receiving a calling request of an application program to a first object, wherein the request comprises an identifier of the first object; and finding the second object in the new generation area according to the identifier of the first object. Obtaining position information through the second object, and searching the serialized first object in a storage region outside the new generation region and the old generation region according to the storage position; storing the serialized first objects in the new generation region and the storage regions outside the old generation region into the new generation region; and performing deserialization processing on the serialized first object to obtain the first object required by calling.
In another application scenario, if the storage location of the serialized first object in the storage area outside the new generation area and the old generation area has a mapping relationship with the first object, the location information may also be used as the identifier of the first object. In this case, the second object only needs to contain at least the position information. Then, when the application needs to call the first object, the procedure for implementing the call to the first object is described as follows: receiving a calling request of an application program to a first object, wherein the request comprises an identifier of the first object; obtaining position information (namely identification of a first object) through the second object, wherein the position information indicates the storage positions of the serialized first object in the storage areas outside the new generation area and the old generation area, and searching the serialized first object in the storage areas outside the new generation area and the old generation area according to the storage positions; storing the serialized first objects in the new generation region and the storage region outside the old generation region into the new generation region; and performing deserialization processing on the serialized first object to obtain the first object required by calling.
It can be seen that, on the premise of avoiding the complex object from entering the old generation region, thereby avoiding the problem of Full GC caused by stacking the complex object in the old generation region due to long-time reference, the embodiment of the present invention can also keep the continuity and stability of the service in the service processing without affecting the normal use of the object by the application, and improve the performance of the application.
Based on the foregoing implementation manner of the first aspect, in a possible embodiment, if there are multiple optional serialization algorithms for the serialization process (it is understood that an deserialization algorithm corresponds to a serialization algorithm), it is further necessary to record the serialization algorithm corresponding to the complex object, for example, a mapping relationship between an ID object and the serialization algorithm used by the corresponding complex object may be recorded in the ID object, or a mapping relationship between the ID object and the serialization algorithm used by the corresponding complex object may be separately stored.
Based on the foregoing implementation manner of the first aspect, in a possible embodiment, if the data relay module has multiple optional storage manners (for example, including storage in a local memory and storage in a cloud server), the storage manner of the serialized object also needs to be recorded, for example, a mapping relationship between an ID object and the storage manner of the corresponding serialized object may be recorded in the ID object, or a mapping relationship between an ID object and the storage manner of the corresponding serialized object is separately stored.
In a second aspect, an embodiment of the present invention provides an apparatus for managing application objects, where the apparatus includes a storage module (or called storage, such as a memory), a service module (or called service system), and a management module; wherein: the storage module comprises a heap space, wherein the heap space comprises a first storage area, and the first storage area is used for storing objects with survival turns smaller than a preset turn; the business module is used for creating a first object of an application program in the first storage area; the management module is used for constructing a second object for replacing the first object according to the first object, wherein the second object is stored in the first storage area, and the storage space occupied by the second object is smaller than that occupied by the first object; storing the first object in the first storage area to a storage area outside the first storage area. Each functional module of the apparatus is specifically configured to implement the method described in the first aspect.
In one possible application scenario, the management module may be deployed in the heap space targeted. For example, for a heap space in a memory space of a virtual machine, the heap space includes a new generation region and an old generation region, and the management module is initially created and stored in the new generation region.
In one possible application scenario, the management module may be deployed in a memory area outside the first storage area, and the management module and the heap space are located in the same memory space. For example, for a heap space in a memory space of a virtual machine, where the heap space includes a new generation region and an old generation region, the management module may be deployed outside the new generation region and the old generation region of the heap space, and the management module and the heap space are located in the same memory space.
In one possible application scenario, the management module may deploy a memory space different from a memory space of the heap space to which the management module is corresponding (for example, the management module and the heap space are respectively deployed in memory spaces of different nodes of the cluster).
In a third aspect, an embodiment of the present invention provides a system for managing application objects, where the system includes one or more computing devices, each computing device includes a processor and a memory, and the processor and the memory may be connected by a bus. The memory comprises a first storage area, and the first storage area is used for storing objects with survival turns smaller than preset turns; the processor is configured to create a first object of an application in the first storage area; constructing a second object in the first storage area according to the first object, wherein the second object occupies a smaller storage space than the first object; storing the first object in the first storage area to a storage area other than the first storage area. The system is particularly adapted to implement the method described in the first aspect.
In a fourth aspect, embodiments of the present invention provide a non-volatile computer-readable storage medium; the computer readable storage medium is used for storing code for implementing the method of the first aspect. The program code is operable, when executed by a computing device, to perform the method of the first aspect.
In a fifth aspect, an embodiment of the present invention provides a computer program product; the computer program product comprises program instructions operable, when executed by a computing device, to perform the method of the first aspect. The computer program product may be a software installation package, which, in case it is required to use the method provided by any of the possible designs of the first aspect described above, may be downloaded and executed on a controller to implement the method of the first aspect.
It can be seen that in the embodiment of the present invention, in order to avoid that a complex object (i.e. a first object) is referenced for a long time and stacked in an old generation area to cause Full GC during the running process of an application, an ID object (i.e. a second object) is used to replace the complex object in a new generation area before the complex object is not moved to the old generation area, and then the associated complex object can be restored by using the ID object when the complex object needs to be used again. Because the memory occupied by the ID object is smaller than or even far smaller than the memory occupied by the complex object, on one hand, the speed of the memory occupation in the new generation region reaching the space threshold is greatly delayed, namely, the frequency of Minor GC generation in the new generation region is greatly reduced, and the use efficiency of the memory is improved; on the other hand, ID objects are in new generation areas for a longer time than complex objects. Even more, most ID objects may end their life cycle before their age reaches a preset threshold, and are cleared in the Minor GC. Therefore, the implementation of the embodiment of the invention is beneficial to avoiding the complex object from entering the old generation area, thereby greatly slowing down the increase of the data volume of the object in the old generation area, avoiding the problem of Full GC caused by the stacking of the complex object in the old generation area due to the long-time reference, not influencing the normal use of the object by the application program, keeping the service continuity in the service processing and improving the performance of the application program.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or the background art of the present invention, the drawings required to be used in the embodiments or the background art of the present invention will be described below.
FIG. 1 is a diagram of a scene for managing complex objects in the prior art;
FIG. 2 is a schematic diagram of a deployment management node according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a further deployment management node provided by an embodiment of the present invention;
FIG. 4 is a schematic diagram of a further deployment management node provided by an embodiment of the present invention;
FIG. 5 is a schematic view of a scenario for managing a complex object according to an embodiment of the present invention;
FIG. 6 is a schematic view of a scenario for invoking a complex object according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating a method for managing application objects according to an embodiment of the present invention;
FIG. 8 is a flowchart illustrating a further method for managing application objects according to an embodiment of the present invention;
FIG. 9 is a flowchart illustrating a further method for managing application objects according to an embodiment of the present invention;
FIG. 10 is a schematic structural diagram of an apparatus for managing application objects according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a system according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described below with reference to the drawings. The terminology used in the description of the embodiments of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
In the computer-based architecture, a virtual machine (e.g., JVM) refers to a special software entity that creates an environment between a computer platform and an end user, who can run applications based on the environment created by the virtual machine. Generally, the heap space managed by the JVM is used primarily to host java objects of classes of various java applications, where the classes are collections of a set of objects having the same properties and common behaviors, and the java objects can be understood as specific instance objects in the classes. Referring to FIG. 1, the heap space includes a new generation region and an older generation region, and the java application constructs objects stored in the new generation region during the application process. If the java object cannot be released quickly during the business process and has a long residence time in the new generation area and the age of the object reaches a preset threshold, such an object may be called a complex object. According to the conventional memory management mechanism of JVM, the complex object is moved from the new generation region to the old generation region.
In the existing big data application in the industry, a large amount of data processing is usually carried out, and the data processing time often exceeds the GC time of a new generation area, so that a large amount of complex objects related to the data processing are transferred to an old generation, objects in the old generation area are gradually accumulated, once the old generation area triggers Full GC, all threads in the virtual machine process are stopped, and the application performance of the virtual machine is greatly influenced.
Based on this, in order to avoid the problem of Full GC in the old age area and improve the application performance, the embodiment of the present invention provides a management module, and the management module may include three sub-modules according to functional division: the ID object constructing module, the serialization module and the data transfer module have respective functions described as follows:
(1) An ID object construction module: the ID object construction module may be configured to construct a simple object from the complex object introduced into the new generation region, the simple object occupying less memory space than the complex object, the simple object being used to replace the complex object.
In particular embodiments, the constructed simple object contains an identification of the complex object (e.g., a unique identification UID), so this simple object may be referred to as an ID object in turn. Specifically, the identifier may be transmitted as a parameter together with the complex object when the ID object construction module is called, or the identifier may be carried in the complex object and extracted by the ID object construction module, or the identifier may be generated by the ID object construction module according to the complex object.
In a possible embodiment, the ID object further includes location information indicating a storage location of the serialized complex object in a storage area outside the new generation area and the old generation area, so that the corresponding complex object is restored by the ID object later.
(2) A serialization module: the serialization module can be used for serializing the complex object to obtain a serialized object. The serialization is a process of converting state information of a complex object into a byte sequence which can be stored or transmitted, and the serialized object is the byte sequence. The serialization module may also be used to receive complex object references that are deserialized from build memory requested by other Application Programming Interfaces (APIs).
The serialization module can also be used for deserializing the serialized object, so that the original object is restored. Deserialization is a process of restoring a byte sequence to an object.
It should be noted that, if the serialization module has a plurality of selectable serialization algorithms (it is understood that an deserialization algorithm corresponds to a serialization algorithm), then it is also necessary to record the serialization algorithm corresponding to the complex object, for example, the mapping relationship between the ID object and the serialization algorithm used by the corresponding complex object may be recorded in the ID object, or the mapping relationship between the ID object and the serialization algorithm used by the corresponding complex object may be separately stored.
(3) A data transfer module: the data transfer module may be configured to perform data transfer on the serialized objects, so as to store the serialized complex objects in storage locations of the new generation region and the old generation region, for example, the serialized objects may be stored in other local storage, or the serialized objects may be stored in a space in the memory other than the heap space, or the serialized objects may be transmitted to other devices through a network, and so on.
It should be noted that, if the data relay module has multiple optional storage manners (for example, including storage in a local memory and storage in a cloud server), the storage manner of the serialized object also needs to be recorded, for example, a mapping relationship between the ID object and the storage manner of the corresponding serialized object may be recorded in the ID object, or a mapping relationship between the ID object and the storage manner of the corresponding serialized object may be separately stored.
It should be noted that, the three sub-modules of the management module are the result of division according to functions, and the management module may have various implementation forms in practical application. For example, the functions of two of the three sub-modules may be integrated together (e.g., the ID object construction module and the serialization module are integrated together); for another example, the three sub-modules may be called independently, and their coordination relationship is determined by the caller himself, and so on.
In one possible application scenario, the management module may be deployed in the heap space targeted. Referring to fig. 2, for a heap space in a memory space of a virtual machine, the heap space includes a new generation region and an old generation region, and a management module is initially created and stored in the new generation region, and as time goes on, the management module is moved from the new generation region to the old generation region as time goes on because the management module needs to work continuously, so that the management module is deployed in the old generation region continuously and stably from a long-term perspective.
In one possible application scenario, the management module may be deployed outside the new generation region and the old generation region of the heap space for which it is located, and the management module is located in the same memory space as the heap space. Referring to fig. 3, for a heap space in a memory space of a virtual machine, the heap space includes a new generation region and an old generation region, a management module is deployed at a position different from the new generation region and the old generation region in the memory space after being created, and the position may be located outside the heap space; this location may also be located in the heap space, e.g. in the heap space, in addition to the new generation area and the old generation area, also including the permanent generation area (the permanent generation area is used for storing objects that are always working), and the management module may be deployed in this permanent generation area.
In one possible application scenario, the management module may deploy a memory space different from a memory space of the heap space to which the management module is corresponding (for example, the management module and the heap space are respectively deployed in memory spaces of different nodes of the cluster). Referring to fig. 4, a management node is deployed in a memory space 2, and a heap space to which the management node is directed is deployed in a memory space 1, where the memory space 1 and the memory space 2 may belong to different virtual machines respectively, and the different virtual machines have communication connections therebetween.
Based on the management module, a process of managing a complex object in a new generation region according to an embodiment of the present invention is described below. Referring to fig. 5, after the application creates the complex object in the new generation region, the ID object constructing module constructs an ID object according to the complex object, the ID object is stored in the new generation region as a "substitute" for the complex object, and a memory space occupied by the "substitute" is smaller than a memory space occupied by the complex object; then, the serialization module carries out serialization processing on the complex object to obtain a serialized object; and the data transfer module transfers the serialized complex object to data, so that the complex object is transferred from the new generation region to a storage region outside the new generation region and the old generation region for storage.
Based on the management module, the following describes a procedure of calling an object by an application according to an embodiment of the present invention. Referring to fig. 6, when the application requests to use the complex object, the ID object construction module obtains the request for the complex object, where the request carries the identifier of the complex object. Since the ID object also contains the identifier of the complex object, the ID object construction module can quickly find the ID object based on the identifier, and then further search for the serialized object corresponding to the ID object according to the storage location indicated by the ID object.
The searching for the corresponding serialized object according to the storage location indicated by the ID object may include two specific implementation manners, one implementation manner is that the ID object includes both an identifier and location information, and the location information indicates the storage location of the serialized complex object in the storage areas other than the new generation area and the old generation area, so that the serialized object corresponding to the ID object can be searched according to the location information; another implementation is to establish a mapping relationship between the storage locations of the serialized complex object in the storage areas outside the new generation area and the old generation area and the complex object, so that the location information can be used as the identifier of the complex object. Then the serialized object corresponding to the ID object can be found from such identification.
And then, transferring the serialized objects from the storage region back to a new generation region through a data transfer module, and then performing deserialization processing on the serialized objects through a serialization module so as to restore the original complex objects. In this way, the application can use the complex object normally.
It can be seen that in the embodiment of the present invention, in order to avoid that a complex object is referenced for a long time and stacked in an old generation area to cause Full GC during the running process of an application, a new simple object (ID object) is used to replace the complex object in a new generation area before the complex object is not moved to the old generation area, and the associated complex object can be restored by using the simple object (ID object) when the complex object needs to be reused. Because the memory occupied by the ID object is smaller than or even far smaller than the memory occupied by the complex object, on one hand, the speed of the memory occupation in the new generation region reaching the space threshold is greatly delayed, namely, the frequency of Minor GC generation in the new generation region is greatly reduced; on the other hand, in the memory management mechanism, the age of the object is increased by 1 after the object is decocted for one round of Minor GC, and the object is moved to the old age area on the premise that the age of the object reaches the preset threshold. Therefore, the ID object is in the new generation area for a longer time than the complex object. Even more, most ID objects may have their life cycle over (i.e., the ID object becomes inactive) before their age reaches a preset threshold, and thus are purged in the Minor GC. Therefore, the implementation of the embodiment of the invention is beneficial to avoiding the complex object from entering the old generation area, thereby avoiding the problem of Full GC caused by the stacking of the complex object in the old generation area due to the long-time reference of the complex object, not influencing the normal use of the object by the application program, and improving the performance of the application program.
Referring to fig. 7, based on the content described above, the following describes a method for managing application objects according to an embodiment of the present invention, where the method is applied to a virtual machine, and the virtual machine is not limited to a Java environment, and may also be applied to other hosted languages, such as Scala, groovy, and the like. The memory space of the virtual machine includes a first storage area, where the first storage area is used to store an object whose survival turn is smaller than a preset turn, where the survival turn refers to an age of the object in the first storage area, and the age of the object still living in the first storage area increases by 1 every time the first storage area performs a Garbage Collection (GC) operation, and it can be understood that, if the survival turn of the object reaches the preset turn (for example, the preset turn is 15), the object will be moved out of the first storage area. The method includes, but is not limited to, the steps of:
step S101: in the first storage area, a first object of an application program is created.
For example, in a specific application scenario, after receiving data of a client, an application program may create a complex object (e.g., eventData) inside the system, where the complex object is the first object.
Step S102: in the first storage area, a second object used for replacing the first object is constructed according to the first object, and the storage space occupied by the second object is smaller than that occupied by the first object.
In a specific embodiment, the second object comprises an identifier of the first object, so that the second object can be stored in the first storage area as a "substitute" for the first object. In a specific embodiment, the second object includes location information, where the location information indicates a storage location of the first object in a storage area outside the first storage area, so that the corresponding first object is restored by the second object subsequently. It can be seen that the second object is a simpler object than the first object (complex object), e.g. the first object occupies 1MB of memory space, while the second object occupies only 50KB of memory space.
It should be noted that the second object may be implemented by referring to the "ID object" described above, and is not described herein again.
Step S103: storing the first object in the first storage area to a storage area other than the first storage area. And subsequently, when the application program needs to call the first object, storing the first object of the storage area into the first storage area for the application program to call.
In a specific embodiment, the first object in the first storage area may be serialized to obtain a serialized first object, and then the serialized first object is stored in a storage area outside the first storage area. And subsequently, when the application program needs to call the first object, storing the serialized first object in the storage area into the first storage area, performing deserialization processing on the serialized object, and restoring the first object for the application program to call.
It should be noted that, the specific implementation process of this step may refer to the related description above, and is not described herein again.
It can be seen that in the embodiment of the present invention, before the first object (complex object) is not moved out of the first storage area, a new simple object (second object) is used to replace the complex object in the first storage area, and then when the first object needs to be used again, the associated first object can be restored by using the second object. Because the memory occupied by the second object is smaller than or even far smaller than the memory occupied by the first object, on one hand, the speed of the memory occupied in the first storage area reaching the space threshold is greatly delayed, namely, the frequency of GC generation in the first storage area is greatly reduced; on the other hand, since the age of the second object hardly reaches the preset threshold value, the second object may be in the first storage area for a longer time than the first object. Even more, the second object may be cleared from the GC by the time its age reaches a preset threshold, and its life cycle is completed (i.e., the second object becomes an inactive object). Therefore, the embodiment of the invention is beneficial to avoiding the problem that the first object is moved out of the first storage area (for example, moved to other areas similar to the old generation area) due to the memory management mechanism, does not influence the normal use object of the application program, and improves the performance of the application program.
Referring to fig. 8, based on the foregoing management module, a further method for managing application program objects according to an embodiment of the present invention is described below, where the method is applied to a JVM virtual machine, a memory space of the virtual machine includes a heap space, the heap space includes a new generation region and an old generation region, the new generation region is used for storing objects with a survival turn smaller than the preset turn, and the old generation region is used for storing objects with a survival turn greater than or equal to the preset turn. It is understood that the age of a subject still living in the new generation region increases by 1 for each round of Minor GC in the new generation region, and it is understood that the subject is moved from the new generation region to the old generation region if the survival round of the subject reaches a preset round. For example, if the preset round is 15, then subjects whose survival round cannot reach 15 will remain in the new generation area until cleared; for an object whose survival turns can reach (exceed) 15 times, it is indicated that the object can stay in the Minor GC of 15 turns, that is, the life cycle (i.e., the total life duration) of the object is longer than the total time of the Minor GC of 15 turns in the new generation area. The method includes, but is not limited to, the steps of:
step S201: in the new generation region, a first object of an application is created.
For example, in a specific application scenario, after a service request enters an application program, the application program constructs a related first object, and the complex object is located in a new generation region.
Step S202: determining whether to construct the second object for the first object;
because the objects created in the new generation may be objects with a shorter life cycle (i.e. the survival turn is less than the preset turn) or objects with a longer life cycle (i.e. the survival turn can reach the preset turn), the objects with a shorter life cycle will certainly die in the new generation area and will not enter the old generation area; embodiments of the present invention are directed to objects having a longer life cycle that may enter into the elderly generation area, and such objects may be referred to as complex objects. Therefore, after an object is created, it is determined whether the object is the complex object, and if the object is the complex object, the following step S203 is executed to construct the second object for the first object; it will be appreciated that if not a complex object, the object will eventually die in the new generation area, so the solution of embodiments of the present invention need not be implemented.
In a possible embodiment, it is determined whether the predicted survival turn of the first object is greater than or equal to the preset turn, and if the survival turn of the first object can reach the preset turn, the determination result is to construct the second object for the first object. Wherein the estimated survival turns are pre-estimated survival turns that can reach and exceed a preset turn. For example, the preset turn is 15, and it can be determined in advance according to historical experience that a certain object is a complex object, for example, it is estimated that the survival turn of the object in the new generation region can reach 15, and the life cycle of the object can be longer than the total time of the Minor GC of 15 turns, so that such a first object is the estimated complex object. Then, for such a first object, the result of the determination is to construct the second object for the first object.
In a possible embodiment, it is determined whether the survival turn of a class of a particular object type is greater than or equal to the preset turn; if the survival turn of the class of the specific object type can reach the preset turn and the object type of the first object belongs to the specific object type, the determination result is to construct the second object for the first object, wherein a class is a set of specific object types having the same attribute and common behavior, it can be understood that if a certain class (e.g. a certain array) is a set of complex objects, then if the first object belongs to the class, the first object is a complex object. For such a first object, the determination results in construction of the second object for the first object.
Step S203: and if the determination result is that the second object is constructed for the first object, constructing a second object used for replacing the first object according to the first object in the new generation area, wherein the memory space occupied by the second object is smaller than that occupied by the first object.
In a specific embodiment, the second object is the aforementioned "ID object", and the second object includes the identifier of the first object, so that the second object can be stored in the first storage area as a "substitute" for the first object (i.e. a complex object). In the process of constructing the second object, the input parameters mainly include the complex object and the identifier of the specified complex object or an algorithm for calculating the identifier, and the identifier may be generated according to the actual situation, and the identifier is, for example, a UID of the complex object, a service-related identifier of the complex object, and the like;
in a specific embodiment, the second object includes location information indicating a storage location of the serialized complex object in a storage region outside the new generation region and the old generation region, so that the corresponding complex object is restored by the second object subsequently. It can be seen that the second object is a simpler object than the first object (complex object), e.g. the first object occupies 1MB of memory space, while the second object occupies only 50KB of memory space.
If the storage position of the serialized complex object in the storage area outside the new generation area and the old generation area has a mapping relation with the complex object, the position information can also be used as the identifier of the complex object.
It should be noted that, this step may also be implemented by referring to the ID object constructing module of the management module, which is not described herein again.
Step S204: and carrying out serialization processing on the first object to obtain a serialized first object.
In a specific embodiment, in the process of performing serialization processing on a complex object, the input parameters are mainly the complex object, and other parameters depend on specific implementation. Such as multiple optional serialization algorithms, the parameters may also include, or be clues to, the mapping between the serialization algorithms used for the first object and the corresponding complex object. The mapping is recorded in the ID object or the mapping is independently maintained in a fixed location.
It should be noted that, this step may also be implemented by referring to the foregoing serialization module of the management module, which is not described herein again.
Step S205: storing the serialized first object in a storage area outside the new generation area and the old generation area. For example, the serialized first object may be saved to other local storage, or the serialized object may be saved to a memory space in memory other than heap space, or the serialized object may be transmitted to other devices over a network, and so on.
In a specific embodiment, in the process of storing the serialized first object in the storage area, the input parameter is mainly a complex object, and other parameters depend on a specific implementation, for example, there are multiple optional storage manners, and then the parameter further includes a mapping relationship between the ID object and the storage manner of the corresponding serialized object, or a clue of the mapping relationship. The mapping is recorded in the ID object or the mapping is independently maintained in a fixed location.
It should be noted that, this step may also be implemented by referring to the data transfer module of the management module, which is not described herein again.
Referring to fig. 9, based on the management module, the following is still another method for managing application objects, where the method flow is used to describe a process of restoring a first object by using a second object (i.e., an ID object) when the first object (i.e., a complex object) needs to be used in a business process of an application. The method includes, but is not limited to, the steps of:
step S301: when an application program needs to call the first object, receiving a call request of the application program to the first object; the object invocation request includes an identification of the first object.
Step S302: and finding the second object in the new generation area according to the identifier of the first object.
Step S303: obtaining, by the second object, location information indicating a storage location of the serialized first object in a storage area outside the new generation area and the old generation area. Wherein, if the storage location of the serialized first object in the storage area outside the new generation area and the old generation area has a mapping relation with the first object, the location information can also be used as the identifier of the first object.
Step S304: and searching the serialized first object in a storage area outside the new generation area and the old generation area according to the storage position.
Step S305: storing the serialized first objects in the new generation region and the storage region outside the old generation region into the new generation region.
Step S306: and performing deserialization processing on the serialized first object to obtain the original first object so as to realize calling by an application program.
In a specific embodiment, there are a plurality of optional serialization algorithms, and it can be understood that there are also a plurality of deserialization algorithms, and then the deserialization algorithm corresponding to the complex object needs to be finally determined according to the mapping relationship between the serialization algorithms used by the first object and the corresponding second object, and then the deserialization processing is performed on the serialized first object, so as to restore the first object.
It can be seen that in the embodiment of the present invention, in order to avoid that a complex object (i.e. a first object) is referenced for a long time and stacked in an old generation area to cause Full GC during the running process of an application, an ID object (i.e. a second object) is used to replace the complex object in a new generation area before the complex object is not moved to the old generation area, and then the associated complex object can be restored by using the ID object when the complex object needs to be used again. Because the memory occupied by the ID object is smaller than or even far smaller than the memory occupied by the complex object, on one hand, the speed of the memory occupation in the new generation region reaching the space threshold is greatly delayed, namely, the frequency of Minor GC generation in the new generation region is greatly reduced, and the use efficiency of the memory is improved; on the other hand, ID objects are in new generation areas for a longer time than complex objects. Even more, most ID objects may end their life cycle before their age reaches a preset threshold, and are cleared in the Minor GC. Therefore, the implementation of the embodiment of the invention is beneficial to avoiding the complex object from entering the old generation area, thereby greatly slowing down the increase of the data volume of the object in the old generation area, avoiding the problem of Full GC caused by the stacking of the complex object in the old generation area due to the long-time reference, not influencing the normal use of the object by the application program, keeping the service continuity in the service processing and improving the performance of the application program.
Based on the same inventive concept, the following further provides a related device related to the embodiment of the invention.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an apparatus 40 according to an embodiment of the present invention, where the apparatus 40 may be used to implement the method for managing application objects according to the embodiment of the present invention, and the apparatus 40 may include a storage module 401, a business module 402, and a management module 403. The respective modules may be software modules. Wherein, the description of each functional module is as follows:
the storage module 401 includes a first storage area, and the first storage area is used for storing objects with survival turns smaller than preset turns;
the business module 402 is configured to create a first object of an application program in the first storage area;
the management module 403 is configured to construct, according to the first object, a second object to replace the first object, where the second object is stored in the first storage area, and a storage space occupied by the second object is smaller than a storage space occupied by the first object; storing the first object in the first storage area to a storage area outside the first storage area.
In a specific embodiment, the storage module 401 specifically includes a new generation region and an old generation region, the new generation region is used for storing objects with a survival turn smaller than a preset turn, the old generation region is used for storing objects with a survival turn greater than or equal to the preset turn, and the new generation region is the first storage region;
the business module 402 is further configured to determine whether to construct the second object for the first object;
the management module 403 is specifically configured to, if the determination result is that the second object is constructed for the first object, construct the second object according to the first object; storing the first object to a storage area outside the new generation area and the old generation area.
The implementation process of the different modules of the apparatus 40 can refer to the foregoing description, and is not described here again.
Referring to fig. 11, fig. 11 is a schematic structural diagram of a system according to an embodiment of the present invention. The system includes one or more computing devices 50, each computing device 50 including a processor 501, a memory 502, and a communication interface 503, the processor 501, the memory 502, and the communication interface 503 being connected by a bus 504. Wherein:
the number of the Memory 602 is one or more, and may include a Volatile Memory (Volatile Memory), such as a Random Access Memory (RAM); the Memory 502 may also include a Non-Volatile Memory (Non-Volatile Memory), such as a Read-Only Memory (ROM), a Flash Memory (Flash Memory), a Hard Disk Drive (HDD), or a Solid-State Drive (SSD); the memory 502 may also comprise a combination of memories of the kind described above. Memory 502 may be used to store a set of program codes for facilitating processor 501 in invoking the program codes stored in memory 502 to implement the method of managing application objects of an embodiment of the present invention. Specifically, the storage 502 is further configured with one or more memory spaces, where the one or more memory spaces correspond to one or more virtual machines, and the memory spaces include a heap space, where the heap space includes the first storage area described above, or the heap space includes the new generation area and the old generation area described above. Specifically, the memory 502 is further configured to store the management module described above, where the management module may be specifically a software module, and the management module may be stored in the memory space or stored outside the memory space; in addition, the management module may store the heap space in the memory space, or may store the region outside the heap space in the memory; in addition, the management module and the targeted heap space may be stored in memories of different computing devices 50, the same memory of the same computing device, or different memories of the same computing device, and the specific implementation manner may also refer to the description of the embodiments in fig. 2 to 4.
Processor 501 may be comprised of one or more general-purpose processors, such as a Central Processing Unit (CPU). Processor 501 may be used to run program code associated with a management module. That is, the processor 501 executes the program code to implement the specific functions of the management module, and implement the method for managing the application object according to the embodiment of the present invention.
The communication interface 503 may be a wired interface (e.g., an ethernet interface) or a wireless interface (e.g., a cellular network interface or using a wireless local area network interface) for communicating with other terminals or websites. In this embodiment of the present invention, the communication interface 503 may be specifically configured to receive a request for calling an object by an application program. Wherein:
the memory comprises a first storage area, and the first storage area is used for storing objects with survival turns smaller than preset turns; the processor is configured to create a first object of an application in the first storage area; constructing a second object in the first storage area according to the first object, wherein the second object occupies a smaller storage space than the first object; storing the first object in the first storage area to a storage area outside the first storage area.
In a specific embodiment, the memory specifically includes a new generation region and an old generation region, the new generation region is used for storing objects whose survival turns are smaller than a preset turn, the old generation region is used for storing objects whose survival turns are greater than or equal to the preset turn, and the new generation region is the first storage region; the processor is specifically configured to determine whether to construct the second object for the first object; if the determination result is that the second object is constructed for the first object, constructing the second object according to the first object; storing the first object to a storage area outside the new generation area and the old generation area.
In practice, the system may include more or less components, and is not limited thereto. The specific functions and implementation procedures of the different devices of the system can refer to the foregoing descriptions, and are not described in detail here.
In the above embodiments, all or part may be implemented by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer program instructions which, when loaded and executed on a computer, cause a process or function according to an embodiment of the invention to be performed, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one network site, computer, server, or data center to another network site, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, digital subscriber line) or wirelessly (e.g., infrared, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer and can be a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The available media may be magnetic media (e.g., floppy disks, hard disks, tapes, etc.), optical media (e.g., DVDs, etc.), or semiconductor media (e.g., solid state drives), among others.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.

Claims (16)

1. A method for managing application program objects is applied to a virtual machine, the memory space of the virtual machine includes a first storage area, the first storage area is used for storing objects with a survival turn smaller than a preset turn, the memory space of the virtual machine includes a new generation area and an old generation area, the new generation area is used for storing objects with a survival turn smaller than the preset turn, the old generation area is used for storing objects with a survival turn larger than or equal to the preset turn, and the new generation area is the first storage area, the method includes:
creating a first object of an application program in the first storage area;
constructing, in the first storage area, a second object from the first object for replacing the first object, the second object occupying less storage space than the first object and the second object including an identification of the first object;
serializing the first object to obtain a serialized first object, wherein the serialization is a byte sequence which can be stored or transmitted and converts state information of a complex object, and the serialized object is the byte sequence;
storing the first object in the serialized first storage area to the first storage area and a storage area outside the elderly generation area;
and when the age of the second object is increased by 1 after a round of Minor GC for recycling the minority garbage, if the age of the second object reaches a preset threshold value, the second object is moved from the first storage area to the old age area, and when the life cycle of the second object is finished, the second object is removed in the Minor GC.
2. The method of claim 1,
before the constructing a second object for replacing the first object according to the first object, the method further comprises:
determining whether to construct the second object for the first object;
correspondingly, the method further comprises the following steps:
if the determination result is that the second object is constructed for the first object, constructing the second object according to the first object;
storing the first object to a storage area outside the new generation area and the old generation area.
3. The method of claim 2, wherein the determining whether to construct the second object for the first object comprises:
determining whether the predicted survival turn of the first object is greater than or equal to the preset turn; if the estimated survival turn of the first object exceeds the preset turn, constructing the second object for the first object according to the determination result; alternatively, the first and second electrodes may be,
determining whether the estimated survival turn of the class of the specific object type is greater than or equal to the preset turn; if the estimated survival turn of the class of the specific object type exceeds the preset turn and the object type of the first object belongs to the specific object type, constructing the second object for the first object as a result of the determination.
4. A method according to claim 2 or 3, characterized in that the method further comprises:
when the first object needs to be called, obtaining position information through the second object, wherein the position information indicates the storage positions of the serialized first object in the storage areas outside the new generation area and the old generation area;
searching the serialized first object in a storage area outside the new generation area and the old generation area according to the storage position;
storing the serialized first objects in the new generation region and the storage region outside the old generation region into the new generation region;
and performing deserialization processing on the serialized first object.
5. The method of claim 4, wherein the second object comprises an identification of the first object;
before obtaining location information by the second object, the method further comprises:
receiving an object invocation request, wherein the object invocation request comprises an identifier of the first object;
and finding the second object in the new generation area according to the identification of the first object.
6. An apparatus for managing application objects, the apparatus comprising a storage module, a business module, and a management module; wherein:
the storage module comprises a first storage area, the first storage area is used for storing objects with survival turns smaller than preset turns, the storage module comprises a new generation area and an old generation area, the new generation area is used for storing the objects with survival turns smaller than the preset turns, the old generation area is used for storing the objects with survival turns larger than or equal to the preset turns, and the new generation area is the first storage area;
the business module is used for creating a first object of an application program in the first storage area;
the management module is used for constructing a second object for replacing the first object according to the first object, wherein the second object is stored in the first storage area, the storage space occupied by the second object is smaller than that occupied by the first object, and the second object comprises the identification of the first object; serializing the first object to obtain a serialized first object, wherein the serialization is a byte sequence which can be stored or transmitted and converts state information of a complex object, and the serialized object is the byte sequence; storing the first object in the serialized first storage area to the first storage area and a storage area outside the elderly generation area; and the second object is further used for increasing the age of the second object by 1 after a round of Minor garbage collection Minor GC, moving the second object from the first storage area to the old generation area if the age of the second object reaches a preset threshold value, and removing the second object in the Minor GC when the life cycle of the second object is finished.
7. The apparatus of claim 6,
the business module is further configured to determine whether to construct the second object for the first object;
the management module is specifically configured to construct the second object according to the first object if the determination result is that the second object is constructed for the first object; storing the first object to a storage area outside the new generation area and the old generation area.
8. The apparatus of claim 7,
the service module is specifically configured to determine whether the estimated survival turn of the first object is greater than or equal to the preset turn; if the estimated survival turn of the first object exceeds the preset turn, constructing the second object for the first object according to the determination result; alternatively, the first and second electrodes may be,
determining whether the predicted turn of survival for the class of the particular object type is greater than or equal to the preset turn; if the predicted turn of survival of the class of the specific object type exceeds the preset turn and the object type of the first object belongs to the specific object type, constructing the second object for the first object as a result of the determination.
9. The apparatus of claim 7 or 8, wherein the management module is further configured to, when the first object needs to be called,
obtaining, by the second object, location information indicating a storage location of the serialized first object in a storage area outside the new generation area and the old generation area;
searching the serialized first object in a storage area outside the new generation area and the old generation area according to the storage position;
storing the serialized first objects in the new generation region and the storage region outside the old generation region into the new generation region;
and performing deserialization processing on the serialized first object.
10. The apparatus of claim 9, wherein the second object comprises an identification of the first object;
the management module is specifically configured to receive an object invocation request before obtaining the location information through the second object, where the object invocation request includes an identifier of the first object; and finding the second object in the new generation area according to the identifier of the first object.
11. A system for managing application objects, the system comprising one or more computing devices, each computing device comprising a processor and a memory, wherein:
the memory comprises a first storage area, the first storage area is used for storing objects with survival turns smaller than preset turns, the memory space of the memory comprises a new generation area and an old generation area, the new generation area is the first storage area, and the old generation area is used for storing objects with survival turns larger than or equal to the preset turns;
the processor is configured to create a first object of an application in the first storage area; constructing a second object in the first storage area from the first object for replacing the first object, the second object occupying less storage space than the first object and the second object including an identification of the first object; serializing the first object to obtain a serialized first object, wherein the serialization is a byte sequence which can be stored or transmitted and converts state information of a complex object, and the serialized object is the byte sequence; storing the first object in the serialized first storage area to a storage area outside the first storage area and the elderly generation area; and the second object is further used for increasing the age of the second object by 1 after a round of Minor GC for recycling the minority garbage, and when the age of the second object reaches a preset threshold value, the second object is moved from the first storage area to the old age area, and when the life cycle of the second object is over, the second object is removed in the Minor GC.
12. The system of claim 11,
the processor is specifically configured to determine whether to construct the second object for the first object; if the determination result is that the second object is constructed for the first object, constructing the second object according to the first object; storing the first object to a storage area outside the new generation area and the old generation area.
13. The system of claim 12, wherein the processor is specific to,
determining whether the predicted survival turn of the first object is greater than or equal to the preset turn; if the estimated survival turn of the first object exceeds the preset turn, constructing the second object for the first object according to the determination result; alternatively, the first and second electrodes may be,
determining whether the estimated survival turn of the class of the specific object type is greater than or equal to the preset turn; if the predicted turn of survival of the class of the specific object type exceeds the preset turn and the object type of the first object belongs to the specific object type, constructing the second object for the first object as a result of the determination.
14. The system of claim 12 or 13, wherein the processor is further configured to, when the first object needs to be invoked,
obtaining, by the second object, location information indicating a storage location of the serialized first object in a storage area outside the new generation area and the old generation area;
searching the serialized first objects in the storage areas outside the new generation area and the old generation area according to the storage positions;
storing the serialized first objects in the new generation region and the storage region outside the old generation region into the new generation region;
and performing deserialization processing on the serialized first object.
15. The system of claim 14, wherein the second object comprises an identification of the first object;
the processor is specifically configured to receive an object invocation request through a communication interface, where the object invocation request includes an identifier of the first object; and finding the second object in the new generation area according to the identifier of the first object.
16. A non-transitory computer-readable storage medium storing program code, wherein the program code is executable by a computing device to perform the method of any of claims 1-5.
CN201810519626.1A 2018-05-28 2018-05-28 Method, related device and system for managing application program object Active CN110543357B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810519626.1A CN110543357B (en) 2018-05-28 2018-05-28 Method, related device and system for managing application program object

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810519626.1A CN110543357B (en) 2018-05-28 2018-05-28 Method, related device and system for managing application program object

Publications (2)

Publication Number Publication Date
CN110543357A CN110543357A (en) 2019-12-06
CN110543357B true CN110543357B (en) 2023-01-13

Family

ID=68700939

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810519626.1A Active CN110543357B (en) 2018-05-28 2018-05-28 Method, related device and system for managing application program object

Country Status (1)

Country Link
CN (1) CN110543357B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112231066B (en) * 2020-10-29 2024-02-13 北京思特奇信息技术股份有限公司 Optimization processing method and system based on JVM memory use
CN112764880B (en) * 2021-01-19 2023-07-07 福建天泉教育科技有限公司 Java garbage recycling monitoring method and terminal

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5900001A (en) * 1997-04-23 1999-05-04 Sun Microsystems, Inc. Method and apparatus for optimizing exact garbage collection using a bifurcated data structure
US6865657B1 (en) * 2000-06-02 2005-03-08 Sun Microsystems, Inc. Garbage collector for a virtual heap
US7321909B1 (en) * 2004-12-23 2008-01-22 Sun Microsystems, Inc. Method and apparatus for forwarding references to objects concurrently with space-incremental garbage collection
WO2011045949A1 (en) * 2009-10-13 2011-04-21 株式会社日立製作所 Memory management method, memory management program, and information processing device
CN106648882A (en) * 2015-11-04 2017-05-10 龙芯中科技术有限公司 Garbage recycling method and device based on virtual machine

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5900001A (en) * 1997-04-23 1999-05-04 Sun Microsystems, Inc. Method and apparatus for optimizing exact garbage collection using a bifurcated data structure
US6865657B1 (en) * 2000-06-02 2005-03-08 Sun Microsystems, Inc. Garbage collector for a virtual heap
US7321909B1 (en) * 2004-12-23 2008-01-22 Sun Microsystems, Inc. Method and apparatus for forwarding references to objects concurrently with space-incremental garbage collection
WO2011045949A1 (en) * 2009-10-13 2011-04-21 株式会社日立製作所 Memory management method, memory management program, and information processing device
CN106648882A (en) * 2015-11-04 2017-05-10 龙芯中科技术有限公司 Garbage recycling method and device based on virtual machine

Also Published As

Publication number Publication date
CN110543357A (en) 2019-12-06

Similar Documents

Publication Publication Date Title
CN110941481A (en) Resource scheduling method, device and system
CN112214293A (en) Method for service deployment under server-free architecture and function management platform
CN105049268A (en) Distributed computing resource allocation system and task processing method
JP2013513174A (en) Method and system for managing virtual machine storage space and physical hosts
CN104461744A (en) Resource allocation method and device
US20180025049A1 (en) Server and Data Processing Method
WO2018171392A1 (en) Method for virtual machine capacity expansion and reduction and virtual management device
WO2021109750A1 (en) Node management method, device and apparatus, storage medium, and system
CN110543357B (en) Method, related device and system for managing application program object
CN112463290A (en) Method, system, apparatus and storage medium for dynamically adjusting the number of computing containers
CN112231108A (en) Task processing method and device, computer readable storage medium and server
CN109582459A (en) The method and device that the trustship process of application is migrated
CN101354720B (en) Distributed memory database data system and sharing method thereof
CN114168490A (en) Method for determining memory recovery threshold and related equipment
CN113918647A (en) Distributed database elastic expansion method, device, equipment and storage medium
US11080909B2 (en) Image layer processing method and computing device
CN106557404B (en) Application control method and mobile terminal
CN103150159A (en) Identifier generation using named objects
CN110580195A (en) Memory allocation method and device based on memory hot plug
CN110019475B (en) Data persistence processing method, device and system
US20230185772A1 (en) Inode number distribution management method for distributed storage system and related component
CN110795202A (en) Resource allocation method and device of virtualized cluster resource management system
CN112346848A (en) Method, device and terminal for managing memory pool
CN113821333A (en) Android application program migration method and device
WO2017070963A1 (en) Method, apparatus, and system for deploying virtual resources

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20220210

Address after: 550025 Huawei cloud data center, jiaoxinggong Road, Qianzhong Avenue, Gui'an New District, Guiyang City, Guizhou Province

Applicant after: Huawei Cloud Computing Technology Co.,Ltd.

Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Applicant before: HUAWEI TECHNOLOGIES Co.,Ltd.

GR01 Patent grant
GR01 Patent grant