Memory garbage recovery method and device, equipment and storage medium

By conducting detailed evaluation of the memory object status in different areas of memory and calculating weight coefficients, and calculating memory garbage values, more efficient and flexible memory recycling is achieved, solving the problems of low memory garbage collection efficiency and insufficient memory space utilization in the existing technology, and optimizing system performance.

CN119597679AActive Publication Date: 2025-03-11深圳市云希谷科技有限公司
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411649508.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-03-11
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

The existing memory garbage collection methods are inefficient, cannot effectively utilize memory space, and have a single recycling strategy, making it difficult to flexibly adjust according to the usage of different memory areas.

Method used

By obtaining the memory object status of different areas in memory, performing data sorting and weight coefficient calculation, calculating memory garbage values ​​in different areas, and sorting and pre-determined threshold filtering, and finally performing recycling operations based on the memory sorting table to be recycled.

Benefits of technology

It improves the utilization rate of memory resources, optimizes system performance, solves the problems of low recycling efficiency and insufficient memory space utilization, and achieves more flexible and efficient memory management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597679A_ABST
    Figure CN119597679A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of memory garbage collection, and discloses a memory garbage collection method, device and equipment and a storage medium, the method comprises the following steps: obtaining memory object conditions of different areas in a memory, performing data arrangement operation according to the memory object conditions to obtain memory garbage assessment data, and storing the memory garbage assessment data in the memory; the method comprises the steps of obtaining memory junk assessment data, performing weight coefficient calculation according to the memory junk assessment data to obtain a memory junk data weight coefficient, performing memory junk value calculation according to the memory junk assessment data and the memory junk data weight coefficient to obtain memory junk values of different areas, and performing sorting operation according to the memory junk values of the different areas. The method comprises the steps of obtaining a memory junk value sorting table, performing preset threshold value screening according to the memory junk value sorting table to obtain a to-be-recycled memory sorting table, and performing recycling operation according to the to-be-recycled memory sorting table to obtain an optimized memory. According to the method, the precision of memory recovery is improved, and the utilization of memory resources is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of memory garbage recovery, and in particular to a memory garbage recovery method, device, equipment and storage medium. Background Art

[0002] In the field of memory management, as the complexity of programs and applications in computer systems continues to increase, memory garbage collection has become an important means to keep the system running efficiently. Memory garbage refers to invalid memory usage caused by frequent allocation and release of memory blocks in the system. These garbages occupy a large amount of memory resources, resulting in system performance degradation and even possible system crashes. Therefore, how to efficiently recycle memory garbage and release more available memory space has become an important part of system performance optimization.

[0003] Existing memory garbage collection methods are mainly completed through mark-and-sweep, copy algorithms, and reference counting. These methods periodically scan the memory to identify invalid memory objects and release them. However, these methods have many problems: First, existing recycling methods usually need to traverse the entire memory space, and the recycling efficiency is low. Especially in systems with intensive memory usage, this traversal operation will bring high system overhead and affect the operating efficiency. Secondly, the mark and clear operations in the recycling process are prone to cause memory fragmentation, and continuous memory space cannot be effectively utilized, further reducing the efficiency of memory use. Finally, the existing memory recycling algorithm is relatively simple, and it is difficult to flexibly adjust the recycling strategy according to the usage of different memory areas, resulting in limited memory recycling effects.

[0004] In summary, existing memory garbage collection methods have deficiencies in efficiency, memory space utilization, and flexibility, and cannot meet the needs of modern complex systems for efficient memory management. Summary of the invention

[0005] The present invention provides a memory garbage recovery method, device, equipment and storage medium to solve the problem of low recovery efficiency caused by lack of accurate evaluation and sorting in the existing memory garbage recovery process.

[0006] In a first aspect, in order to solve the above technical problems, the present invention provides a memory garbage recovery method, comprising:

[0007] Obtaining memory object status in different areas of the memory; wherein the memory object status includes the number of objects, the size of the objects, and the survival time of the objects;

[0008] According to the memory object status, a data sorting operation is performed to obtain memory garbage assessment data; wherein the memory garbage assessment data includes object quantity data, object size data and object survival time data;

[0009] Calculate the weight coefficient according to the memory garbage evaluation data to obtain the memory garbage data weight coefficient; wherein the memory garbage data weight coefficient includes the object quantity data weight, the object size data weight and the object survival time data weight;

[0010] Calculating memory garbage values ​​according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain memory garbage values ​​of different areas;

[0011] Performing a sorting operation according to the memory garbage values ​​of the different areas to obtain a memory garbage value sorting table;

[0012] According to the memory garbage value sorting table, a predetermined threshold value screening is performed to obtain a memory sorting table to be recycled;

[0013] According to the memory sorting table to be reclaimed, a reclaiming operation is performed to obtain optimized memory.

[0014] Preferably, performing data sorting operations according to the memory object status to obtain memory garbage assessment data includes:

[0015] According to the number of objects, a summary statistics is performed to obtain object quantity data;

[0016] Performing cumulative calculation according to the object size to obtain object size data;

[0017] According to the object survival time, a sorting calculation is performed to obtain object survival time data.

[0018] Preferably, the calculating of the weight coefficient according to the memory garbage evaluation data to obtain the memory garbage data weight coefficient includes:

[0019] The memory garbage data weight coefficient is calculated by the following formula:

[0020] W=(α·N)+(β·S)+(γ·T)

[0021] Among them, W represents the weight coefficient of memory garbage data, N represents the number of objects, S represents the size of objects, T represents the survival time of objects, and α, β, and γ are the weight coefficients of the number of objects, object size, and object survival time, respectively.

[0022] Preferably, the memory garbage value calculation is performed according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain the memory garbage values ​​of different regions, including:

[0023] The memory garbage value of different areas is calculated by the following formula:

[0024]

[0025] Among them, G i Represents the memory garbage value of the i-th region, S i represents the object size of the ith region, N i represents the number of objects in the ith region, T i represents the object survival time of the i-th region, W is the memory garbage data weight coefficient, M i Indicates the total memory capacity of the i-th region.

[0026] Preferably, performing data processing according to the memory garbage value to obtain a memory garbage value sorting table includes:

[0027] Perform a sorting operation according to the memory garbage value to obtain a list to be sorted;

[0028] According to the list to be sorted, quick sort and merge sort are performed to obtain a memory garbage value sorting table.

[0029] Preferably, performing a predetermined threshold screening according to the memory garbage value sorting table to obtain a to-be-reclaimed memory sorting table includes:

[0030] According to the memory garbage value sorting table, obtaining the memory garbage value to be filtered;

[0031] According to the memory garbage value to be screened, a predetermined threshold value comparison is performed to obtain a memory garbage value greater than or equal to the predetermined threshold value;

[0032] According to the memory garbage values ​​that are greater than or equal to the predetermined threshold, garbage values ​​are summarized to obtain a memory sorting table to be reclaimed.

[0033] Preferably, performing a recycling operation according to the memory sorting table to be recycled to obtain optimized memory includes:

[0034] According to the memory sorting table to be reclaimed, reclaim locking is performed to obtain the memory area to be reclaimed;

[0035] According to the memory area to be reclaimed, data is cleaned up to obtain optimized memory.

[0036] In a second aspect, the present invention provides a memory garbage recovery device, comprising:

[0037] Data acquisition module, obtains the status of memory objects in different areas of memory;

[0038] A data sorting module, used to perform data sorting operations according to the memory object status to obtain memory garbage assessment data;

[0039] A weight calculation module, used to calculate a weight coefficient according to the memory garbage evaluation data to obtain a memory garbage data weight coefficient;

[0040] A garbage value calculation module, used to calculate the memory garbage value according to the memory garbage evaluation data and the memory garbage data weight coefficient, to obtain the memory garbage values ​​of different areas;

[0041] A sorting module, used for performing a sorting operation according to the memory garbage values ​​of the different areas to obtain a memory garbage value sorting table;

[0042] A recycling screening module is used to perform a predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recycled;

[0043] The recycling module is used to perform recycling operations according to the memory sorting table to be recycled to obtain optimized memory.

[0044] In a third aspect, the present invention further provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any one of the above-mentioned memory garbage recovery methods when executing the computer program.

[0045] In a fourth aspect, the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the memory garbage recovery methods described above.

[0046] Compared with the prior art, the present invention has the following beneficial effects: obtaining memory object status in different areas of the memory, performing data sorting operations according to the memory object status to obtain memory garbage assessment data, performing weight coefficient calculation according to the memory garbage assessment data to obtain memory garbage data weight coefficient, performing memory garbage value calculation according to the memory garbage assessment data and the memory garbage data weight coefficient to obtain memory garbage values ​​in different areas, performing sorting operations according to the memory garbage values ​​in different areas to obtain a memory garbage value sorting table, performing predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recycled, performing a recycling operation according to the memory sorting table to be recycled to obtain optimized memory.

[0047] The present invention discloses a memory garbage recovery method, comprising obtaining memory object status in different areas of a memory, performing a data sorting operation according to the memory object status to obtain memory garbage evaluation data, performing a weight coefficient calculation according to the memory garbage evaluation data to obtain a memory garbage data weight coefficient, performing a memory garbage value calculation according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain memory garbage values ​​in different areas, performing a sorting operation according to the memory garbage values ​​in different areas to obtain a memory garbage value sorting table, performing a predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recovered, performing a recovery operation according to the memory sorting table to be recovered to obtain an optimized memory, thereby improving the utilization rate of memory resources and optimizing system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a schematic diagram of the flow of a memory garbage recovery method provided by the first embodiment of the present invention;

[0049] Figure 2 It is a schematic diagram of the structure of a memory garbage recovery device provided by the second embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] Reference Figure 1 The first embodiment of the present invention provides a memory garbage recovery method, comprising the following steps:

[0052] S11, obtaining the status of memory objects in different areas of the memory;

[0053] S12, performing data sorting operations according to the memory object status to obtain memory garbage assessment data;

[0054] S13, calculating a weight coefficient according to the memory garbage evaluation data to obtain a memory garbage data weight coefficient;

[0055] S14, calculating the memory garbage value according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain the memory garbage values ​​of different areas;

[0056] S15, performing a sorting operation according to the memory garbage values ​​of the different regions to obtain a memory garbage value sorting table;

[0057] S16, performing a predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recycled;

[0058] S17, performing a recycling operation according to the memory to be recycled sorting table to obtain optimized memory.

[0059] In step S11, the status of memory objects in different areas of the memory is obtained.

[0060] It is worth noting that in the process of memory garbage collection, it is crucial to obtain the status of memory objects in different memory areas. This step is the basis for subsequent garbage collection. The main goal of this step is to collect relevant information in each memory area, including the number, size and survival time of objects, by scanning the memory areas in the system at regular intervals. The acquisition of this information can provide accurate basic data for the evaluation, sorting and final collection of memory garbage.

[0061] First, the system scans the memory in different areas and records the number of objects in each memory area. The statistics of the number of objects can reflect the density of memory usage in the area and can also provide support for further weight calculations. Next, the scan will also count the memory size occupied by each object, that is, the size information of the object. By accumulating this data, the system can evaluate the memory usage in each area and determine whether there is memory waste or ineffective use. Finally, the system will also record the survival time of the object in memory. The survival time of the object is a key factor in measuring whether the object is outdated or no longer needed. The system uses a timer to measure the survival time of the object from its creation to the current time. When the time exceeds a certain threshold, the object may be considered no longer necessary and needs to be recycled.

[0062] Obtaining the status of these objects is not just a simple statistics of memory space, but also requires a series of algorithms to process these data to lay the foundation for the subsequent garbage value calculation. By comprehensively analyzing the number, size and survival time of objects, the system can more accurately determine the efficiency of memory use, thereby providing a scientific basis for garbage collection.

[0063] In step S12, the data sorting operation is performed according to the memory object status to obtain memory garbage assessment data, including:

[0064] According to the number of objects, a summary statistics is performed to obtain object quantity data;

[0065] Performing cumulative calculation according to the object size to obtain object size data;

[0066] According to the object survival time, a sorting calculation is performed to obtain object survival time data.

[0067] It is worth noting that in the memory garbage collection process, the step of sorting data according to the status of memory objects is crucial, which determines how the system evaluates the degree of garbage in each memory area. The core goal of this process is to classify, count and process the acquired memory object information in detail, so as to generate evaluation data for subsequent garbage value calculation.

[0068] First, the system will summarize and count the number of memory objects obtained. The statistics of the number of objects is a basic step in evaluating the density of memory usage. By regularly scanning the memory area, the system will record the total number of objects in each area and store them in a digital form. The number of objects directly reflects the activity level of the memory in the area. A large number of memory areas usually means high resource usage. By summarizing these object quantity data, the system can quickly identify those areas with dense objects and provide guidance for subsequent recycling operations. This step is not just a simple statistics, but also needs to consider the allocation of different memory areas to accurately determine the number of objects in each area.

[0069] Next, the system will accumulate the size of the objects. The object size reflects the actual space occupied by each object in memory. This indicator is crucial because it can directly measure the memory usage. By accumulating the sizes of objects, the system can derive the total memory usage of each memory area. The accumulation operation requires accurate measurement of the actual size of each memory object and summing them according to certain calculation rules. Usually, the system will also distinguish between different memory types such as heap memory or stack memory to ensure the accuracy of the accumulation calculation. The accumulated object size data can help the system evaluate which areas have memory waste and which areas have exceeded the reasonable range of memory usage, providing the necessary basis for subsequent garbage value calculations.

[0070] In addition, the system performs sorting calculations based on the survival time of the objects. The survival time is one of the key factors in determining whether an object needs to be recycled. The system determines whether the object is still in use by recording the survival time of the object from allocation to the current time. If an object has a long survival time and is not frequently accessed during this period, it may have lost its function. The sorting operation arranges these objects according to their survival time, and the objects with the longest survival time are given priority for recycling. The goal of this sorting calculation is to ensure that the system can give priority to recycling objects that are no longer used or have survived too long to free up more memory space. In order to ensure the accuracy of the sorting, the system will combine factors such as the object's historical access records and the last modification time to comprehensively measure the object's survival time.

[0071] In general, data sorting operations are not only a simple statistical and calculation process, but also involve the classification, screening and sorting of data. By comprehensively analyzing the three key indicators of object quantity, size and survival time, the system can generate detailed memory garbage assessment data. These data will be used for subsequent garbage value calculations to help the system decide which areas of memory need to be reclaimed and which areas of memory can continue to be used. This process lays a solid foundation for the efficient execution of memory garbage collection, ensuring that the system can maximize the release of memory resources and optimize overall performance without affecting performance.

[0072] In step S13, the weight coefficient is calculated according to the memory garbage evaluation data to obtain the memory garbage data weight coefficient, including:

[0073] The memory garbage data weight coefficient is calculated by the following formula:

[0074] W=(α·N)+(β·S)+(γ·T)

[0075] Among them, W represents the weight coefficient of memory garbage data, N represents the number of objects, S represents the size of objects, T represents the survival time of objects, and α, β, and γ are the weight coefficients of the number of objects, object size, and object survival time, respectively.

[0076] It is worth noting that in the process of memory garbage collection, weight coefficient calculation is one of the key steps. Its core purpose is to comprehensively consider the number, size and survival time of memory objects, evaluate the impact of these factors on the memory garbage value in a weighted manner, and finally obtain the weight coefficient of memory garbage data. First, the system has obtained the evaluation data of the number of objects, object size and object survival time in each memory area. These data are key indicators for measuring the usage of memory areas, but because the memory usage in different areas is different, the contribution of each factor to memory garbage is also different. Therefore, it is necessary to reasonably allocate the influence weight of each factor through weight coefficient calculation to ensure accurate garbage collection in the subsequent memory garbage value calculation process.

[0077] The system analyzes the number of memory objects and uses the object number data as an important basis for measuring the density of memory usage. A large number of memory areas usually means that the memory in this area is frequently used, and there may be more invalid objects or outdated data, so the number of objects will be given a certain weight. This weight is adjusted by the coefficient α in the system to ensure that the object number data can accurately reflect the memory usage in the area in the calculation of the memory garbage value. Next, the system evaluates each memory area according to the object size and determines the size of the space occupied by each object in the memory. The object size is directly related to the degree of memory occupancy. For objects that occupy a large amount of memory space, the system may assign them a higher weight β because these objects will significantly affect the allocation and use efficiency of memory resources. In this way, the system can accurately evaluate the memory occupancy and give priority to reclaiming those objects that occupy a large amount of space.

[0078] In addition, the system will adjust the weight according to the object's survival time. The object survival time is an important indicator to measure whether the object is still valid or needs to be recycled. If an object survives in memory for a long time and is not frequently accessed, it is likely to have lost its function and become a candidate for memory garbage. In order to ensure that the system can give priority to recycling these objects that have not been used for a long time, the system will assign a weight γ to the object survival time data so that it occupies a larger proportion in the garbage value calculation. Through this weight distribution, the system can more effectively screen out invalid objects in memory and ensure the accuracy and timeliness of garbage collection.

[0079] The entire weight coefficient calculation process is implemented through the formula:

[0080] W=(α·N)+(β·S)+(γ·T)

[0081] Where W is the final memory garbage data weight coefficient, which reflects the combined impact of the number of objects, object size, and object survival time on the memory garbage value. This formula ensures that the impact of various factors is fully considered during the memory garbage collection process by assigning appropriate weights to different data. Ultimately, the weight coefficient W will be used in subsequent memory garbage value calculations to help the system determine which memory areas need to be recycled first, thereby optimizing the allocation and use of memory resources and improving the performance of the overall system.

[0082] In step S14, a memory garbage value is calculated according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain memory garbage values ​​of different regions, including:

[0083] The memory garbage value of different areas is calculated by the following formula:

[0084]

[0085] Among them, G i Represents the memory garbage value of the i-th region, S i represents the object size of the ith region, N i represents the number of objects in the ith region, T i represents the object survival time of the i-th region, W is the memory garbage data weight coefficient, M i Indicates the total memory capacity of the i-th region.

[0086] It is worth noting that M i Indicates the total capacity of the memory region, which refers to the total amount of all memory resources occupied by the i-th memory region. During the memory garbage assessment process, the total capacity of the memory region is used to normalize the memory garbage value to ensure that the garbage assessment results between different regions are comparable. Due to the difference in the number and size of objects in each memory region, the amount of memory occupied by each memory region is also different, so it is necessary to measure it according to its total capacity during garbage collection.

[0087] M i The function of the formula is to divide the memory garbage value by the total capacity of the memory area so that the evaluation result can reflect the actual memory usage ratio of each area. This can not only accurately measure the memory garbage level of each area, but also avoid calculation errors caused by differences in the size of memory areas, thereby ensuring the rationality and accuracy of the garbage collection strategy.

[0088] It is worth noting that in the process of memory garbage collection, calculating the memory garbage value based on the memory garbage assessment data and the memory garbage data weight coefficient is a complex and precise step. Its core goal is to calculate the garbage value of each area by analyzing the usage of each memory area and provide a basis for subsequent garbage collection. This step combines multiple key factors, such as object size, number of objects, and object survival time, and finally obtains the memory garbage value through weighted calculation. This calculation result is crucial to determine which memory areas need to be recycled first.

[0089] First, the system extracts three core indicators for each memory area from the memory garbage assessment data: object size, number of objects, and object survival time. Object size refers to the sum of the memory space occupied by all objects in a memory area. It directly reflects the degree of memory usage in the area. Larger objects occupy more memory resources, so object size is an important basis for measuring memory waste. The number of objects indicates the total number of objects stored in the area. The larger the number, the more intensive the memory usage in the area, which may mean that the memory utilization efficiency is low, especially when the number of objects in the area increases but the object size is small, memory fragmentation often occurs. Object survival time is another key factor, which refers to the length of time that a memory object persists in memory. If an object exists for a long time but is not frequently accessed, it may mean that the object has lost its original function and becomes invalid data in memory, so it can be recycled.

[0090] After extracting this data, the system needs to weight it. The purpose of weighting is to balance the impact of different factors on memory garbage assessment. The system uses weight coefficients to assign different weights to each indicator based on the system's judgment of the relative importance of these indicators. For example, if the system believes that large objects in memory put more pressure on memory, it will assign a higher weight to the object size, so that the object size data accounts for a larger proportion in the garbage value calculation. On the contrary, if the system detects that the number of objects in a certain area has a greater impact on memory resources, it will assign a higher weight to the number of objects. Similarly, the weight of the object survival time is also adjusted by the system based on the usage of the memory area. This weighted processing ensures that the system can flexibly adjust the garbage collection strategy according to the specific situation.

[0091] After completing the weighted processing of the data, the system combines these results to calculate the memory garbage value of each memory area. This garbage value not only reflects the degree of memory waste in the area, but also quantifies the importance of each memory area in the entire memory management. The system uses the garbage value to determine which areas should be recycled first. At this time, the total capacity of the memory area is also included in the calculation. The total memory capacity is used to standardize the garbage value of each area to ensure that memory areas of different sizes can be reasonably compared during evaluation. Larger areas may contain more objects and data, but by introducing the total capacity as a criterion, the system can fairly measure the memory utilization efficiency of each area. In this way, even if the memory size of some areas is different, the system can adjust according to the total memory capacity to obtain an accurate garbage value.

[0092] Finally, by completing the calculation of the garbage value, the system obtains the specific memory garbage evaluation results for each memory area. These evaluation results will serve as the basis for the system to decide which memory areas need to be recycled first. The system will sort according to the garbage value of each memory area. The area with a larger garbage value means that the waste of memory resources is more serious and will be given priority for recycling. Through this scientific and systematic garbage value calculation, the system can achieve more efficient memory resource management, ensuring that when memory resources are tight, those memory areas that have the greatest impact on system performance can be processed first, maximizing memory utilization.

[0093] In step S15, data processing is performed according to the memory garbage values ​​of the different regions to obtain a memory garbage value sorting table, including:

[0094] Perform a sorting operation according to the memory garbage value to obtain a list to be sorted;

[0095] According to the list to be sorted, quick sort and merge sort are performed to obtain a memory garbage value sorting table.

[0096] It is worth noting that in the memory garbage collection process, data processing based on the memory garbage values ​​of different areas and generating a memory garbage value sorting table is one of the core steps for the system to efficiently perform garbage collection. The main purpose of this step is to sort the garbage values ​​of each memory area in order to ensure that the memory areas with higher garbage values ​​can be processed first in the subsequent recycling process, thereby maximizing the release of memory resources and improving system performance.

[0097] First, the system will calculate the memory garbage value of each memory area through the previous steps. These garbage values ​​reflect the memory usage and garbage level of each area, and represent the degree of memory resource waste in the area. The system will generate a list to be sorted based on these garbage values. This list records the garbage values ​​of all memory areas and the corresponding memory area information. After generating the list, the system will sort it according to the size of the garbage value to ensure that the high garbage value area can appear at the front of the list first. Since the number of memory areas may be large, in order to improve the sorting efficiency, the system chooses to use two classic sorting algorithms: quick sort and merge sort.

[0098] In the process of data processing, quick sort is an efficient comparison sorting algorithm, which recursively divides the data into small intervals, sorts these small intervals independently, and finally merges them into a complete ordered list. The time complexity of the quick sort algorithm is low, which is suitable for processing large data sets, so it is used to process a large amount of memory garbage value data. Quick sort can quickly locate those areas with large garbage values, thereby speeding up data processing. Merge sort is a sorting algorithm with higher stability. It divides the data into smaller ordered segments and gradually merges them into a complete ordered list. The advantage of merge sort is its stability, which ensures that the relative order between memory areas will not be disrupted during the sorting process. This sorting method is particularly suitable for scenarios that require precise sorting, ensuring that the garbage values ​​in each memory area can be accurately arranged.

[0099] With the combined effect of quick sort and merge sort, the system can quickly and accurately sort the garbage values ​​of all memory areas and generate a complete memory garbage value sorting table. This sorting table not only records the garbage values ​​of each memory area, but also provides a clear priority basis for subsequent recycling operations. Through this sorting table, the system can give priority to processing memory areas with larger garbage values, thereby ensuring that the memory space is released to the maximum extent within a limited recycling time. The sorting table can also be used for further predetermined threshold screening, that is, according to the threshold range set by the system, filter out those areas where the garbage value exceeds the threshold, and perform more accurate garbage collection operations.

[0100] The execution of the entire sorting and data processing steps lays a solid foundation for memory garbage collection. Through this efficient sorting method, the system can make reasonable garbage collection decisions between different memory areas, ensuring that while ensuring performance, the use of memory resources is optimized and the overall efficiency of the system is improved.

[0101] In step S16, a predetermined threshold screening is performed according to the memory garbage value sorting table to obtain a memory sorting table to be recycled, including:

[0102] According to the memory garbage value sorting table, obtaining the memory garbage value to be filtered;

[0103] According to the memory garbage value to be screened, a predetermined threshold value comparison is performed to obtain a memory garbage value greater than or equal to the predetermined threshold value;

[0104] According to the memory garbage values ​​that are greater than or equal to the predetermined threshold, garbage values ​​are summarized to obtain a memory sorting table to be reclaimed.

[0105] It is worth noting that in the memory garbage collection process, the step of screening based on the memory garbage value sorting table with a predetermined threshold is a key step to ensure that the system can accurately and efficiently screen out the memory areas that need to be recycled first. This step involves the analysis, comparison and aggregation of a large number of memory garbage values, and finally generates a sorting table of memory to be recycled, thereby providing clear guidance for the system recycling operation. The accuracy of this step determines the efficiency of releasing memory resources during the recycling process and the optimization of overall system performance.

[0106] First, the system obtains the garbage value of each memory area one by one according to the memory garbage value sorting table that has been generated. The memory garbage value is a comprehensive evaluation result obtained through previous calculations, which indicates the degree of waste of memory resources in each memory area. The system uses these garbage values ​​as the basic data to be screened, and gradually builds a list of garbage values ​​to be screened. Since the memory garbage value is an important indicator for evaluating the memory usage status, it represents the memory usage efficiency and recycling urgency of each memory area, so accurately obtaining the garbage value of each area is crucial for subsequent screening operations.

[0107] Next, the system will compare the obtained garbage values ​​one by one according to the set predetermined threshold. The predetermined threshold is a pre-set standard used to determine whether a certain memory area needs to enter the recycling process. The system will compare the garbage value of each memory area with the threshold. If the garbage value is greater than or equal to the threshold, the memory area is considered to be a recycling object. During this comparison process, the system will make real-time adjustments based on the specific situation of each memory area to ensure the accuracy of the screening. For example, in some cases, the system may dynamically adjust the threshold, especially when memory resources are tight, and may lower the threshold standard to allow more memory areas to enter the state to be recycled. Through this process, the system ensures that the screened memory areas not only need to be recycled, but can also be prioritized and managed through reasonable standards.

[0108] After completing the threshold comparison, the system aggregates the garbage values ​​of all memory areas that meet the recycling conditions. The purpose of the aggregation operation is to sort all memory areas that are greater than or equal to the threshold and generate a new sorting table of memory to be recycled. This sorting table is sorted by the high and low memory garbage values ​​to ensure that in the subsequent recycling process, memory areas with higher garbage values ​​can be processed first. This step is crucial because by aggregating and sorting the filtered garbage values, the system can process the memory areas that need to be recycled most in a limited time to avoid wasting too many system resources.

[0109] The entire threshold screening and aggregation process provides an accurate and efficient decision-making basis for memory garbage collection. By screening out memory areas whose garbage values ​​exceed the predetermined threshold, the system can ensure the accuracy and timeliness of the recycling operation, thereby maximizing the release of system resources and optimizing memory management efficiency.

[0110] In step S17, a recycling operation is performed according to the memory sorting table to be recycled to obtain optimized memory, including:

[0111] According to the memory sorting table to be reclaimed, reclaim locking is performed to obtain the memory area to be reclaimed;

[0112] According to the memory area to be reclaimed, data is cleaned up to obtain optimized memory.

[0113] It is worth noting that in the entire process of memory garbage collection, recycling operations based on the memory sorting table to be recycled is a crucial step, which aims to effectively clean up the memory area to be recycled through systematic memory management, and finally obtain optimized memory. This process involves multiple steps, including locking the area to be recycled and in-depth data cleaning operations, to ensure that the system's memory resources can be released to the maximum extent without affecting the normal operation of the system.

[0114] First, the system will process each memory area step by step according to the memory sorting table to be recycled. The memory sorting table to be recycled is generated by the previous threshold screening and garbage value sorting. The table contains all the memory areas that need to be garbage collected and is sorted by garbage value. Therefore, the system will process these memory areas to be recycled according to the priority order in the table. This priority order can ensure that the areas that waste the most memory resources are recycled first, thereby effectively releasing the memory pressure of the system.

[0115] Next, the system will perform a recycling lock operation on each area to be recycled. The purpose of recycling lock is to prevent new data from being written to these areas to be recycled during recycling. In order to ensure data integrity and system stability, the system will lock each memory area to be recycled before recycling so that these areas will not allocate new memory resources or write new data during the recycling process. This step is crucial because if new data is written during the recycling process, it may cause data inconsistency and may even cause system crashes or data loss. The locking operation ensures the security of the recycling process and provides a stable working environment for subsequent data cleanup operations.

[0116] After the memory area is locked, the system will perform data cleanup operations on these locked areas. Data cleanup is the core of the recycling operation, and its main task is to release invalid memory objects that are no longer used. First, the system will perform a full scan of the locked memory area to identify which objects have lost their function or are considered invalid because they have not been accessed for a long time. These objects are usually memory data marked as garbage objects, including unreferenced objects, outdated data caches, temporary files, etc. The system will delete these invalid data to release this part of the occupied memory space.

[0117] In addition, the data cleaning operation also includes memory defragmentation, which is to ensure that the memory area after cleaning can obtain continuous memory space. Due to the frequent allocation and recovery of memory, memory fragmentation may occur, that is, the free memory block is divided into multiple discontinuous small blocks. Although fragmented memory is available, it may not meet the needs of large-scale data in actual use. To solve this problem, after cleaning invalid data, the system will compress and merge the recycled memory, and integrate these fragmented memory blocks into a continuous, large-scale usable memory area. This step not only improves the availability of memory, but also reduces the impact of memory fragmentation on system performance.

[0118] In addition, after the data cleanup operation is completed, the system will generate an optimized memory status report to record the results of this recovery operation in detail. The report usually includes the size of the recovered memory space, the amount of invalid data cleaned, the memory defragmentation status, and the changes in the overall memory utilization of the system. Through this report, the system can fully understand the actual effect of this memory recovery and provide data support for the next step of memory management operations. After the recovery operation is completed, the system's memory resources are greatly optimized, the free memory space is increased, the memory fragmentation is reduced, and the system performance is significantly improved.

[0119] Finally, the steps of recycling operations based on the memory sorting table to be recycled are very detailed and critical. By locking the area to be recycled, cleaning data and defragmenting memory, the system is ensured to release memory resources safely and effectively. This process ultimately achieves optimized memory management, allowing the system to maximize memory utilization without affecting operation, and ensuring long-term stable operation of the system.

[0120] Reference Figure 2 The second embodiment of the present invention provides a memory garbage recovery device, comprising:

[0121] Data acquisition module, obtains the status of memory objects in different areas of memory;

[0122] A data sorting module, used to perform data sorting operations according to the memory object status to obtain memory garbage assessment data;

[0123] A weight calculation module, used to calculate a weight coefficient according to the memory garbage evaluation data to obtain a memory garbage data weight coefficient;

[0124] A garbage value calculation module, used to calculate the memory garbage value according to the memory garbage evaluation data and the memory garbage data weight coefficient, to obtain the memory garbage values ​​of different areas;

[0125] A sorting module, used for performing a sorting operation according to the memory garbage values ​​of the different areas to obtain a memory garbage value sorting table;

[0126] A recycling screening module is used to perform a predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recycled;

[0127] The recycling module is used to perform recycling operations according to the memory sorting table to be recycled to obtain optimized memory.

[0128] It should be noted that a memory garbage recovery device provided in an embodiment of the present invention is used to execute all process steps of a memory garbage recovery method in the above embodiment, and the working principles and beneficial effects of the two correspond one to one, so they will not be repeated.

[0129] The embodiment of the present invention further provides an electronic device. The electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a memory garbage collection program. When the processor executes the computer program, the steps in the above-mentioned memory garbage collection method embodiments are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are realized, such as the garbage value calculation module.

[0130] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the electronic device.

[0131] The electronic device may be a computing device such as a desktop computer, a notebook, a PDA, and a smart tablet. The electronic device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. The electronic device may include more or fewer components than the above components, or may combine certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0132] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device.

[0133] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the electronic device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0134] Wherein, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0135] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.

[0136] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A memory garbage recovery method, characterized in that: include: Obtaining memory object status in different areas of the memory; wherein the memory object status includes the number of objects, the size of the objects, and the survival time of the objects; According to the memory object status, a data sorting operation is performed to obtain memory garbage assessment data; wherein the memory garbage assessment data includes object quantity data, object size data and object survival time data; Calculate the weight coefficient according to the memory garbage evaluation data to obtain the memory garbage data weight coefficient; wherein the memory garbage data weight coefficient includes the object quantity data weight, the object size data weight and the object survival time data weight; Calculating memory garbage values ​​according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain memory garbage values ​​of different areas; Performing a sorting operation according to the memory garbage values ​​of the different areas to obtain a memory garbage value sorting table; According to the memory garbage value sorting table, a predetermined threshold value screening is performed to obtain a memory sorting table to be recycled; According to the memory sorting table to be reclaimed, a reclaiming operation is performed to obtain optimized memory.

2. The memory garbage recovery method according to claim 1, characterized in that: The step of performing data sorting operations according to the memory object status to obtain memory garbage assessment data includes: According to the number of objects, a summary statistics is performed to obtain object quantity data; Performing cumulative calculation according to the object size to obtain object size data; According to the object survival time, a sorting calculation is performed to obtain object survival time data.

3. The memory garbage recovery method according to claim 1, characterized in that: The step of calculating a weight coefficient according to the memory garbage evaluation data to obtain a memory garbage data weight coefficient includes: The memory garbage data weight coefficient is calculated by the following formula: W=(α·N)+(β·S)+(γ·T) Among them, W represents the weight coefficient of memory garbage data, N represents the number of objects, S represents the size of objects, T represents the survival time of objects, and α, β, and γ are the weight coefficients of the number of objects, object size, and object survival time, respectively.

4. The memory garbage recovery method according to claim 1, characterized in that: The memory garbage value calculation is performed according to the memory garbage evaluation data and the memory garbage data weight coefficient to obtain the memory garbage values ​​of different areas, including: The memory garbage value of different areas is calculated by the following formula: Among them, G i Represents the memory garbage value of the i-th region, S i represents the object size of the ith region, N i represents the number of objects in the ith region, T i represents the object survival time of the i-th region, W is the memory garbage data weight coefficient, M i Indicates the total memory capacity of the i-th region.

5. The memory garbage recovery method according to claim 1, characterized in that: The step of performing data processing according to the memory garbage values ​​of the different regions to obtain a memory garbage value sorting table includes: Perform a sorting operation according to the memory garbage value to obtain a list to be sorted; According to the list to be sorted, quick sort and merge sort are performed to obtain a memory garbage value sorting table.

6. The memory garbage recovery method according to claim 1, characterized in that: The method of performing a predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recycled includes: According to the memory garbage value sorting table, obtaining the memory garbage value to be filtered; According to the memory garbage value to be screened, a predetermined threshold value comparison is performed to obtain a memory garbage value greater than or equal to the predetermined threshold value; According to the memory garbage values ​​that are greater than or equal to the predetermined threshold, garbage values ​​are summarized to obtain a memory sorting table to be reclaimed.

7. The memory garbage recovery method according to claim 1, characterized in that: The step of performing a recycling operation according to the memory sorting table to be recycled to obtain optimized memory includes: According to the memory sorting table to be reclaimed, reclaim locking is performed to obtain the memory area to be reclaimed; According to the memory area to be reclaimed, data is cleaned up to obtain optimized memory.

8. A memory garbage recovery method and device, characterized in that: include: Data acquisition module, obtains the status of memory objects in different areas of memory; A data sorting module, used to perform data sorting operations according to the memory object status to obtain memory garbage assessment data; A weight calculation module, used to calculate a weight coefficient according to the memory garbage evaluation data to obtain a memory garbage data weight coefficient; A garbage value calculation module, used to calculate the memory garbage value according to the memory garbage evaluation data and the memory garbage data weight coefficient, to obtain the memory garbage values ​​of different areas; A sorting module, used for performing a sorting operation according to the memory garbage values ​​of the different areas to obtain a memory garbage value sorting table; A recycling screening module is used to perform a predetermined threshold screening according to the memory garbage value sorting table to obtain a memory sorting table to be recycled; The recycling module is used to perform recycling operations according to the memory sorting table to be recycled to obtain optimized memory.

9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the memory garbage recovery method as claimed in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the memory garbage recovery method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Memory garbage recycling system and method

    CN103577335A

  • Memory allocation and garbage collection method based on life-period prediction

    CN104035879A

  • Memory recovery method and device

    CN114995993A

  • Memory garbage recycling method and device, computer equipment and storage medium

    CN116932418A

  • Garbage collection method and equipment for partition storage equipment and storage medium

    CN118733482A