CN116107920A - Memory management method, nonvolatile storage medium, processor and terminal equipment - Google Patents

Memory management method, nonvolatile storage medium, processor and terminal equipment Download PDF

Info

Publication number
CN116107920A
CN116107920A CN202310378985.0A CN202310378985A CN116107920A CN 116107920 A CN116107920 A CN 116107920A CN 202310378985 A CN202310378985 A CN 202310378985A CN 116107920 A CN116107920 A CN 116107920A
Authority
CN
China
Prior art keywords
target
region
memory
area
memory management
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.)
Granted
Application number
CN202310378985.0A
Other languages
Chinese (zh)
Other versions
CN116107920B (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.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing 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 Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202310378985.0A priority Critical patent/CN116107920B/en
Publication of CN116107920A publication Critical patent/CN116107920A/en
Application granted granted Critical
Publication of CN116107920B publication Critical patent/CN116107920B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02WCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO WASTEWATER TREATMENT OR WASTE MANAGEMENT
    • Y02W90/00Enabling technologies or technologies with a potential or indirect contribution to greenhouse gas [GHG] emissions mitigation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

The embodiment of the invention discloses a memory management method, a nonvolatile storage medium, a processor and terminal equipment, wherein the memory management method comprises the following steps: under the condition that the memory management condition is met, determining a target recovery area of the heap memory; along the object reference chain, searching for a survival object in the target recovery area, wherein the survival object is an object with other objects for reference; and each time a surviving object is found, moving the surviving object to a target area of the heap memory, and updating the reference address of the surviving object to the address of the moved surviving object. The invention solves the technical problem of lower memory management efficiency of the memory management method in the related technology.

Description

Memory management method, nonvolatile storage medium, processor and terminal equipment
Technical Field
The present invention relates to the field of memory management, and in particular, to a memory management method, a nonvolatile storage medium, a processor, and a terminal device.
Background
When the application program runs, the system can continuously allocate memory for the application program according to the requirement of the application program, and meanwhile, the system also needs to continuously perform memory management, so that memory arrangement, unused memory recovery and the like are performed.
In the related art, in the process of performing memory management, the memory management scheme needs to traverse the whole memory space for multiple times, and consumes a great deal of time, so that the memory management period is long and the efficiency is low. Under the condition of high load, the application program process is in a state of waiting for memory allocation for a long time, so that the operation of the application program is adversely affected, and the response speed of the application program is reduced.
Therefore, the memory management method in the related art has a problem of low memory management efficiency. In view of the above problems, no effective solution has been proposed at present.
The above information disclosed in the background section is only for enhancement of understanding of the background of the technology described herein. Accordingly, the background art may contain some information that is not otherwise known to those of skill in the art.
Disclosure of Invention
The embodiment of the invention provides a memory management method, a nonvolatile storage medium, a processor and terminal equipment, which at least solve the technical problem of lower memory management efficiency of the memory management method in the related art.
According to a first aspect of an embodiment of the present invention, there is provided a memory management method, including: under the condition that the memory management condition is met, determining a target recovery area of the heap memory; along the object reference chain, searching for a survival object in the target recovery area, wherein the survival object is an object with other objects for reference; and each time a surviving object is found, moving the surviving object to a target area of the heap memory, and updating the reference address of the surviving object to the address of the moved surviving object.
Further, along the object reference chain, finding surviving objects in the target reclamation area comprises: starting from the out-of-heap reference, searching for a surviving object along an object reference chain, wherein the out-of-heap reference is a reference from the outside of the heap memory to the object in the heap memory; and/or, the memory management method further comprises the following steps: after the movement operation of all surviving objects in the target reclamation area is completed, the target reclamation area is reclaimed.
Further, the heap memory includes a young generation region and an old generation region, the surviving time of the object stored in the old generation region being greater than the surviving time of the object stored in the young generation region; in the case of memory management for younger generation regions, the target reclaimed region is a younger generation region.
Further, in the case of performing memory management on the older generation area, determining the target reclamation area of the heap memory includes: scanning for surviving subjects in the senior citizen's region; determining a region to be recovered from the aged generation region according to the surviving objects in the aged generation region and the size of the memory space occupied by each surviving object, wherein the region to be recovered is a region in which the occupation condition of the surviving objects in the aged generation region on the memory reaches a preset condition; and determining at least part of the area to be recycled as a target recycling area.
Further, the region to be recycled is divided into a plurality of subarea groups, each subarea group comprises a plurality of subareas, and the target recycling region is one of the subarea groups; in the case that the target reclamation area belongs to the senior citizen region, the memory management method further comprises: each time a surviving object is moved, the address of the cross-region reference associated with the surviving object is updated to the address of the moved surviving object, where the cross-region reference is a reference to an object in the target reclamation area by other areas in the senior citizen agent area than the target reclamation area.
Further, the cross-region reference is extracted based on a memory set of the target reclamation area, the memory set records references of other areas outside the target reclamation area to objects in the target reclamation area, and the memory management method further comprises a memory set construction step, wherein the memory set construction step comprises the following steps: recording the reference information of each surviving object to other objects in the process of scanning the surviving objects in the older generation area; and determining a memory set of the target recycling area according to the reference information of the plurality of surviving objects.
Further, along the object reference chain, finding surviving objects in the target reclamation area comprises: storing a first target object in a stack every time the first target object is found, wherein the first target object is a survival object in an older generation area or a survival object pointing to an older generation area in a younger generation area; and acquiring the first target object stored last time from the stack, and searching for the survival object according to the reference of the first target object to other objects.
Further, the memory management method further comprises the following steps: acquiring target references of the application program to a second target object in the heap memory; determining whether the second target object is moved to the target area under the condition that the memory management condition is met and the address of the target reference is located in the target reclamation area; updating the address of the target reference to the address of the moved second target object under the condition that the second target object is moved to the target area; and under the condition that the second target object is not moved to the target area, moving the second target object to the target area, and updating the address of the target reference to the address of the moved second target object.
According to a second aspect of the embodiment of the present invention, there is further provided a nonvolatile storage medium, where the nonvolatile storage medium includes a stored program, and when the program runs, the device on which the nonvolatile storage medium is controlled to execute the above memory management method.
According to a third aspect of the embodiment of the present invention, there is further provided a processor, where the processor is configured to execute a program, and the memory management method is executed when the program runs.
According to a fourth aspect of the embodiment of the present invention, there is also provided a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the memory management method described above when executing the computer program.
In the memory management method of the embodiment of the invention, when the memory management is performed, the surviving objects in the target recovery area are searched along the object reference chain, and each time a surviving object is searched, the surviving object is moved to the target area of the heap memory. Therefore, the surviving objects in the target recycling area can be intensively arranged to the target area, so that the distribution of the surviving objects is more compact, the utilization effect of the heap memory is improved, and the occurrence of the memory fragmentation condition is prevented. By adopting the memory management method, in the whole memory management process, the memory management operation can be completed by only performing one time of survival object traversal on the target recovery area, so that the memory management step is effectively simplified, the memory management efficiency is improved, and the technical problem of lower efficiency of the memory management method in the related technology can be solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
fig. 1 is a flow chart of a memory management method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram illustrating the generation and use of a memory set in a memory management method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of memory reclamation by using an old area scanning mark stack according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region, and provide corresponding operation entries for the user to select authorization or rejection. The terms first, second and the like in the description and in the claims and drawings are used for distinguishing between different objects and not for limiting the specified sequence.
Fig. 1 is a memory management method according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S102, under the condition that the memory management condition is met, determining a target recovery area of the heap memory;
step S104, searching for a survival object in the target recovery area along the object reference chain, wherein the survival object is an object with other objects for reference;
in step S106, each time a surviving object is found, the surviving object is moved to the target area of the heap memory, and the reference address of the surviving object is updated to the address of the moved surviving object.
By adopting the memory management method of the scheme, when the memory management is carried out, the surviving objects in the target recovery area are searched along the object reference chain, and each time a surviving object is searched, the surviving object is moved to the target area of the heap memory. Therefore, the surviving objects in the target recycling area can be intensively arranged to the target area, so that the distribution of the surviving objects is more compact, the utilization effect of the heap memory is improved, and the occurrence of the memory fragmentation condition is prevented. By adopting the memory management method, in the whole memory management process, the memory management operation can be completed by only performing one time of survival object traversal on the target recovery area, so that the memory management step is effectively simplified, the memory management efficiency is improved, and the technical problem of lower efficiency of the memory management method in the related technology can be solved.
The memory management conditions, that is, the conditions for triggering the above-mentioned memory management operations, may be various in practical implementation, for example: the occupation condition of the host memory reaches a certain threshold, reaches a preset memory management period, receives a memory management instruction or accords with a preset memory management strategy condition.
An object reference chain is a reference dependency relationship between objects, that is, there is a reference relationship between objects in heap memory, for example, object a will reference object B, and object B will reference object C. A lookup along such a chain of references is a surviving object as long as it is an object that can be accessed.
The surviving objects are moved to the target area of the heap memory, the target area can be flexibly defined according to requirements, and the memory arrangement effect can be achieved, so that the distribution of the objects in the heap memory is more compact.
In order to be able to efficiently, orderly and completely find surviving objects in the target reclamation area, in an alternative implementation, along the object reference chain, the finding of surviving objects in the target reclamation area comprises: starting from the out-of-heap reference, searching for a surviving object along an object reference chain, wherein the out-of-heap reference is a reference from the outside of the heap memory to the object in the heap memory; and/or, the memory management method further comprises the following steps: after the movement operation of all surviving objects in the target reclamation area is completed, the target reclamation area is reclaimed.
In this embodiment, the live object is searched along the object reference chain triggered by the off-heap reference, as described above, the off-heap reference is a reference to an object in the heap memory from the outside of the heap memory, for example, a reference to an object in the heap memory in an application process, and then the referenced object further references other objects in the heap memory, and so on, so as to form the object reference chain, along which the live object in the target recovery area can be efficiently and orderly searched.
After traversing all surviving objects in the target reclaimed area and moving them to the target area and updating the reference address, the target reclaimed area can be reclaimed for subsequent memory allocation.
In a preferred embodiment, the heap memory includes a young generation region and an old generation region, the surviving time of the objects stored in the old generation region being greater than the surviving time of the objects stored in the young generation region; in the case of memory management for younger generation regions, the target reclaimed region is a younger generation region.
In this embodiment, the heap memory includes a young generation region and an old generation region, and the two regions are different in that the survival time of the objects stored therein is different, and the survival time of the objects stored in the old generation region is longer than that of the objects stored in the young generation region. For example, in actual implementation, a time threshold or a recycling frequency threshold may be set, a new object is placed in a young generation area, if the survival time of the object reaches the time threshold, or if the memory recycling operation of the object is not recycled after multiple times of passing (the recycling frequency threshold), the object is transferred to an old generation area, and in this manner, different memory management logic may be implemented for objects in different areas according to the survival time of the object, so that the memory management operation is more specifically implemented. On this basis, since the object in the young generation area has a short survival time, the object therein is likely to die or die soon, and thus the memory management requirement is also greater. Wherein the object dies, i.e. the object is no longer referenced. In this embodiment, under the condition of performing memory management on the young generation region, the young generation region is used as the target recovery region, so that in each recovery process, the surviving objects in the young generation region are traversed and sorted once, thereby timely releasing the memory space occupied by the dead objects and improving the memory use efficiency.
For example, in one particular embodiment, objects are scanned during memory management, and the objects are divided into young generations and old generations according to a time threshold for object survival, and the objects just created are assigned to young generation regions. Survive for some time and are not assigned to senior citizen regions by reclaimed objects. That is, all newly generated objects are first placed in young generations, whose goal is to collect those objects that have a short life cycle as quickly as possible. Objects that survive multiple garbage recycles in young ages are placed in the aged. Thus, it can be considered that objects with a longer life cycle are stored in the older ages.
As described above, the subjects in the senior citizen region have survived for a long time, so that the survival stability is high, and most of the subjects remain in a survived state for a long time, so that the memory arrangement requirement for the senior citizen region is also small. In this embodiment, in order to achieve more efficient management of memory, in the case of performing memory management on the older generation area, determining the target reclamation area of the heap memory includes: scanning for surviving subjects in the senior citizen's region; determining a region to be recovered from the aged generation region according to the surviving objects in the aged generation region and the size of the memory space occupied by each surviving object, wherein the region to be recovered is a region in which the occupation condition of the surviving objects in the aged generation region on the memory reaches a preset condition; and determining at least part of the area to be recycled as a target recycling area.
That is, for the old age area, when the memory management is performed, the surviving objects included in the old age area are scanned first, and then the area to be recycled is determined from the old age area according to each surviving object and the memory space occupied by each surviving object, so as to determine the target recycling area. The occupation condition of the survival object in the area to be recycled on the memory reaches a preset condition, and the preset condition can be flexibly defined according to actual requirements, for example, the memory occupation rate is lower than a certain threshold. Therefore, a part of the area can be selected for memory management according to the memory occupation condition of each part of the aged area, and the memory management operation of the whole aged area is not needed, so that the memory management operation of the aged area is more targeted and efficient.
Specifically, the region to be recycled is divided into a plurality of sub-region groups, each sub-region group comprises a plurality of sub-regions, and the target recycling region is one of the plurality of sub-region groups; in the case that the target reclamation area belongs to the senior citizen region, the memory management method further comprises: each time a surviving object is moved, the address of the cross-region reference associated with the surviving object is updated to the address of the moved surviving object, where the cross-region reference is a reference to an object in the target reclamation area by other areas in the senior citizen agent area than the target reclamation area.
The to-be-recycled area of the old-fashioned area often has more survival objects, and if the to-be-recycled area is subjected to one-time arrangement, a great amount of time is consumed, which can seriously affect the normal operation of the application program process, so that a part of the to-be-recycled area is determined as a target recycling area in the embodiment, and the to-be-recycled area is subjected to multiple arrangement for one sub-area group each time. After the incremental memory management processing mode is adopted, the objects among the plurality of sub-region groups can be referred to each other, after the objects of the target recycling region are moved to the target region, if the objects of other sub-regions have references to the objects, the problem that the corresponding objects cannot be found according to the original reference addresses after the objects of the target recycling region are moved can occur. To solve this problem, in this embodiment, each time a surviving object is moved, the addresses of cross-region references related to the surviving object are restored to the moved addresses, so as to ensure that the cross-region references can be successfully referenced to the surviving object in the subsequent process.
In one embodiment, the cross-region reference is extracted based on a memory set of the target reclamation area, the memory set recording references of other areas outside the target reclamation area to objects in the target reclamation area, the memory management method further comprising a memory set construction step, the memory set construction step comprising: recording the reference information of each surviving object to other objects in the process of scanning the surviving objects in the older generation area; and determining a memory set of the target recycling area according to the reference information of the plurality of surviving objects.
In this embodiment, a memory set is constructed for the target reclamation area, where the memory set records references to objects within the target reclamation area by areas other than the target reclamation area, such as a set of pointers to the target reclamation area by other areas. Thus, for each surviving object in the target reclamation area, it is known who points to the surviving object, and after the object is moved, restoration of the references can be achieved. In this embodiment, the multiple sub-areas of the area to be recycled are divided into multiple sub-area groups, so that only a corresponding memory set needs to be built for each sub-area group, and a memory set does not need to be built for each sub-area, so that thousands of memory sets do not need to be built, the occurrence probability of the inter-group reference relationship is greatly reduced, the information quantity to be recorded is reduced, and the memory management operation is convenient.
As described above, in the process of managing the memory of the senior citizen region, the surviving objects in the senior region need to be scanned first, in this embodiment, the reference information of each surviving object to other objects is recorded while the surviving objects are scanned, and then, the memory set of the target recovery region can be obtained by sorting on the basis of integrating the reference information of a plurality of surviving objects. Therefore, the secondary traversal of the old generation region is not needed, the memory management efficiency is improved, and the memory management time is saved.
For example, in one particular embodiment, the construction of a partial memory set may be accomplished while scanning for surviving objects in the senior region, thereby reducing the time consuming construction of the memory set. Specifically, during the scanning process, index numbers of other areas referenced by the area where the scanned surviving object is located are recorded in a data table named cross-area lookup table (cross-region discovertable). That is, information indicated by each area is recorded therein, and a memory set (indicated information) of each area can be established based on the information indicated by the plurality of areas. In this embodiment, the related reference information is stored in a table form, and in most cases, only one index number needs to be recorded, so that the memory set can be built by only reading the cross-region lookup table once. In a few cases, if a certain area points to a plurality of areas, a plurality of index numbers need to be recorded, at this time, the cross-area lookup table cannot realize recording, the value corresponding to the area can be set to be invalid, and in the subsequent memory set construction process, the mutual reference relationship among objects can be determined by scanning the surviving objects in the memory, so that the memory set is built. As shown in fig. 2, the above-described cross-region lookup table (cross-region discover table) is generated based on the scan of the surviving object of the aged region, then the aged region reclamation group memory set (i.e., the memory set of the target reclamation region of the aged region) is generated based on the cross-region lookup table, and then the aged region is subjected to multiple incremental reclamation (i.e., the memory reclamation of each sub-region group) based on the memory set.
Specifically, along the object reference chain, finding surviving objects in the target reclamation area comprises: storing a first target object in a stack every time the first target object is found, wherein the first target object is a survival object in an older generation area or a survival object pointing to an older generation area in a younger generation area; and acquiring the first target object stored last time from the stack, and searching for the survival object according to the reference of the first target object to other objects.
In this embodiment, in the process of performing memory management of the senior generation region, a concurrent stack is designed, where objects scanned in the senior generation region may be stored, and objects pointing to the senior generation region may also be stored in the young generation region, so in the process of performing memory management on the young generation region, marks of the senior generation region, that is, marks of which objects of the young generation region point to the objects of the senior generation region, may be simultaneously implemented, so that the subsequent process may help to perform more comprehensive scanning on surviving objects in the senior generation region. Fig. 3 is a schematic diagram of memory reclamation by using an old area scan tag stack according to an embodiment of the present invention, as shown in fig. 3, during a new area reclamation (young area memory reclamation) and an old area scanning (old area surviving object scanning), a scanned first target object is stored in the old area scan tag stack (i.e. the above stack), and then a subsequent object is moved along an object reference chain based on an object in the stack, so as to realize memory reclamation, and in the whole process, the reclamation of the young area memory, the scanning of the old area surviving object and the running of a Java thread are synchronously performed; the recovery of the old-age regional memory and the running of Java threads are synchronously performed.
In this embodiment, the memory management method further includes: acquiring target references of the application program to a second target object in the heap memory; determining whether the second target object is moved to the target area under the condition that the memory management condition is met and the address of the target reference is located in the target reclamation area; updating the address of the target reference to the address of the moved second target object under the condition that the second target object is moved to the target area; and under the condition that the second target object is not moved to the target area, moving the second target object to the target area, and updating the address of the target reference to the address of the moved second target object.
In the related art, a program is suspended during memory management, memory is not allocated, and memory management can be continued after the memory management is finished, and since heap memory needs to be arranged during memory management, an allocated memory object can move, that is, the memory of an application program can change, so that the operation of the application program needs to be suspended. In this embodiment, a read barrier is applied to the application program's reference to the second target object in heap memory, i.e., logic that is additionally executed before or after a read operation is performed on an object reference. In the memory arrangement process, the application program can normally run, and if the application program refers to the moved object, the reference address can be directly restored to the moved address; if the application program references an object that is not moved, the object is moved and the referenced address is repaired to the address after the object is moved. Thus, the simultaneous operation of the memory management and the application program is realized, and the adverse effect of the memory management on the operation of the application program is avoided.
In order to further improve the memory management efficiency, in a preferred embodiment, the memory management method further includes: and when the thread blocking condition is detected to reach a preset critical condition, suspending the running of the application program, and using the processor resources recovered from the application program for memory management.
In addition, the embodiment of the invention also provides a nonvolatile storage medium, wherein the nonvolatile storage medium comprises a stored program, and the device where the nonvolatile storage medium is controlled to execute the memory management method when the program runs.
The embodiment of the invention also provides a processor, wherein the processor is used for running a program, and the memory management method is executed when the program runs.
Finally, the embodiment of the invention also provides a terminal device, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the memory management method is realized when the processor executes the computer program.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments. Moreover, the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that herein.
In the foregoing embodiments of the present invention, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed technology content may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units, for example, may be a logic function division, and may be implemented in another manner, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.

Claims (11)

1. A memory management method, comprising:
under the condition that the memory management condition is met, determining a target recovery area of the heap memory;
searching for a survival object in the target recycling area along an object reference chain, wherein the survival object is an object with other objects for reference;
and each time one survival object is found, moving the survival object to a target area of the heap memory, and updating the reference address of the survival object to the moved address of the survival object.
2. The memory management method of claim 1, wherein searching for surviving objects in the target reclamation area along an object reference chain comprises: starting from an out-of-heap reference, searching the surviving object along the object reference chain, wherein the out-of-heap reference is a reference of the out-of-heap memory to the object in the heap memory; and/or the number of the groups of groups,
the memory management method further comprises the following steps: and after the moving operation of all the survival objects in the target recycling area is completed, recycling the target recycling area.
3. The memory management method of claim 2, wherein the heap memory includes a young generation region and an old generation region, the surviving time of the objects stored in the old generation region being greater than the surviving time of the objects stored in the young generation region; and under the condition of performing memory management on the young generation region, the target recovery region is the young generation region.
4. The memory management method of claim 3, wherein determining a target reclamation area of heap memory in the case of memory management of the older generation area comprises:
scanning the surviving subjects in the senior citizen's region;
determining a region to be recycled from the senior citizen region according to the surviving objects in the senior citizen region and the size of the memory space occupied by each surviving object, wherein the region to be recycled is a region in the senior citizen region in which the occupation condition of the surviving objects on the memory reaches a preset condition;
and determining at least part of the region to be recycled as the target recycling region.
5. The memory management method according to claim 4, wherein the region to be reclaimed is divided into a plurality of sub-region groups, each sub-region group including a plurality of sub-regions, the target reclamation region being one of the plurality of sub-region groups; in the case that the target reclamation area belongs to the senior citizen generation area, the memory management method further includes:
and updating the address of the cross-region reference related to the surviving object to the address of the surviving object after moving every time the surviving object is moved, wherein the cross-region reference is a reference of other regions except the target recycling region in the senior proxy region to the object in the target recycling region.
6. The memory management method according to claim 5, wherein the cross-region reference is extracted based on a memory set of the target reclamation region, the memory set recording references of other regions than the target reclamation region to objects within the target reclamation region, the memory management method further comprising a memory set construction step including:
recording the reference information of each surviving object to other objects in the process of scanning the surviving objects in the senior citizen generation region;
the memory set of the target reclamation area is determined according to the reference information of a plurality of the surviving objects.
7. The memory management method of claim 3, wherein searching for surviving objects in the target reclamation area along an object reference chain comprises:
storing a first target object in a stack every time the first target object is found, wherein the first target object is the survival object in the older generation area or the first target object is the survival object pointing to the older generation area in the younger generation area;
and acquiring the first target object stored last time from the stack, and searching the survival object according to the reference of the first target object to other objects.
8. The memory management method according to any one of claims 1 to 7, wherein the memory management method further comprises:
acquiring a target reference of an application program to a second target object in the heap memory;
determining whether the second target object is moved to the target area if the memory management condition is satisfied and the address of the target reference is located in the target reclamation area;
updating the address of the target reference to the address of the moved second target object under the condition that the second target object is moved to the target area;
and if the second target object is not moved to the target area, moving the second target object to the target area, and updating the address referenced by the target to the address of the moved second target object.
9. A nonvolatile storage medium, wherein the nonvolatile storage medium includes a stored program, wherein the program, when executed, controls a device in which the nonvolatile storage medium is located to perform the memory management method of any one of claims 1 to 8.
10. A processor, wherein the processor is configured to run a program, wherein the program when run performs the memory management method of any one of claims 1 to 8.
11. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the memory management method of any of claims 1 to 8 when the computer program is executed by the processor.
CN202310378985.0A 2023-04-11 2023-04-11 Memory management method, nonvolatile storage medium, processor and terminal equipment Active CN116107920B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310378985.0A CN116107920B (en) 2023-04-11 2023-04-11 Memory management method, nonvolatile storage medium, processor and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310378985.0A CN116107920B (en) 2023-04-11 2023-04-11 Memory management method, nonvolatile storage medium, processor and terminal equipment

Publications (2)

Publication Number Publication Date
CN116107920A true CN116107920A (en) 2023-05-12
CN116107920B CN116107920B (en) 2023-07-28

Family

ID=86265863

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310378985.0A Active CN116107920B (en) 2023-04-11 2023-04-11 Memory management method, nonvolatile storage medium, processor and terminal equipment

Country Status (1)

Country Link
CN (1) CN116107920B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100223433A1 (en) * 2009-02-27 2010-09-02 Tatu Ylonen Oy Ltd Configurable object graph traversal with redirection for garbage collection
CN108459898A (en) * 2017-02-20 2018-08-28 阿里巴巴集团控股有限公司 A kind of recovery method as resource and device
CN109669759A (en) * 2018-09-25 2019-04-23 深圳壹账通智能科技有限公司 Rubbish recovering method, device, equipment and the storage medium of Java Virtual Machine
CN110928804A (en) * 2018-09-20 2020-03-27 阿里巴巴集团控股有限公司 Optimization method and device for garbage recovery, terminal equipment and machine readable medium
CN112214322A (en) * 2020-10-10 2021-01-12 深圳市欢太科技有限公司 Memory management method and device, storage medium and electronic equipment
CN113553145A (en) * 2020-04-26 2021-10-26 华为技术有限公司 Object access method and device
CN115599707A (en) * 2022-10-26 2023-01-13 北京火山引擎科技有限公司(Cn) Memory management method, device, medium and electronic equipment
CN115756879A (en) * 2021-09-03 2023-03-07 腾讯科技(深圳)有限公司 Memory sharing method and related device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100223433A1 (en) * 2009-02-27 2010-09-02 Tatu Ylonen Oy Ltd Configurable object graph traversal with redirection for garbage collection
CN108459898A (en) * 2017-02-20 2018-08-28 阿里巴巴集团控股有限公司 A kind of recovery method as resource and device
CN110928804A (en) * 2018-09-20 2020-03-27 阿里巴巴集团控股有限公司 Optimization method and device for garbage recovery, terminal equipment and machine readable medium
CN109669759A (en) * 2018-09-25 2019-04-23 深圳壹账通智能科技有限公司 Rubbish recovering method, device, equipment and the storage medium of Java Virtual Machine
CN113553145A (en) * 2020-04-26 2021-10-26 华为技术有限公司 Object access method and device
CN112214322A (en) * 2020-10-10 2021-01-12 深圳市欢太科技有限公司 Memory management method and device, storage medium and electronic equipment
CN115756879A (en) * 2021-09-03 2023-03-07 腾讯科技(深圳)有限公司 Memory sharing method and related device
CN115599707A (en) * 2022-10-26 2023-01-13 北京火山引擎科技有限公司(Cn) Memory management method, device, medium and electronic equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
DAVID DETLEFS: "Garbage-first garbage collection", 《PROCEEDINGS OF THE 4TH INTERNATIONAL SYMPOSIUM ON MEMORY MANAGEMENT》, pages 37 - 48 *
张静;: "论Java堆管理中的垃圾回收技术", 科技信息(学术研究), no. 20 *

Also Published As

Publication number Publication date
CN116107920B (en) 2023-07-28

Similar Documents

Publication Publication Date Title
US6424977B1 (en) Train-algorithm-based garbage collector employing reduced oversized-object threshold
US6434577B1 (en) Scalable-remembered-set garbage collection
US6185581B1 (en) Train-algorithm-based garbage collector employing fixed-size remembered sets
US6434576B1 (en) Popular-object handling in a train-algorithm-based garbage collector
US4660130A (en) Method for managing virtual memory to separate active and stable memory blocks
US6415302B1 (en) Train-algorithm-based garbage collector employing farthest-forward-car indicator
US6449626B1 (en) Reduced-cost remembered-set processing in a train-algorithm-based garbage collector
US7627621B2 (en) Method and system for minor garbage collection
US7650370B2 (en) System and method for regeneration of methods and garbage collection of unused methods
US6999979B2 (en) Efficient encoding of references into a collection set
CN106446044A (en) Storage space reclaiming method and device
US7620943B1 (en) Using class properties to segregate objects in a generation managed by the train algorithm
US7870171B2 (en) Method and system for garbage collection in a multitasking environment
CN114327917A (en) Memory management method, computing device and readable storage medium
US7062518B2 (en) Efficiently supporting the existence of long trains in a generation managed by the train algorithm
US8176286B2 (en) Memory recycling in computer systems
US7155467B1 (en) Adaptive type-partitioned garbage collection
CN116107920B (en) Memory management method, nonvolatile storage medium, processor and terminal equipment
US11416392B2 (en) Arena-based memory management
US5915254A (en) File storing system for managing a relational data base including information of a parental relationship
CN115756838A (en) Memory release method, memory recovery method, memory release device, memory recovery device, computer equipment and storage medium
CN115408342A (en) File processing method and device and electronic equipment
CN109388613B (en) File management method and electronic equipment
US7146390B2 (en) Staging the processing of remembered-set entries as part of collection based on the train algorithm
CN114201415A (en) Garbage recycling method and device applied to solid state disk

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
GR01 Patent grant
GR01 Patent grant