Memory optimization system and method based on dynamic memory allocation and garbage collection

By introducing dynamic memory allocation, generational garbage collection, memory compression and performance optimization modules into the memory management system, the problems of memory fragmentation, low garbage collection efficiency and unreasonable dynamic memory allocation are solved, and more efficient memory utilization and system performance improvement are achieved.

CN120216166APending Publication Date: 2025-06-27INSPUR FINANCIAL INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510195499.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In the prior art, there are problems such as memory fragmentation, low garbage collection efficiency and unreasonable dynamic memory allocation, resulting in low memory utilization and system performance degradation.

Method used

It provides a memory optimization system based on dynamic memory allocation and garbage collection, including memory monitoring module, dynamic allocation module, garbage collection module, memory compression module and performance optimization module. It monitors memory usage in real time, adjusts memory allocation strategies dynamically, adopts generational garbage collection algorithms, regularly merges free memory blocks, and dynamically adjusts garbage collection frequency and memory allocation strategies according to system load.

Benefits of technology

Through dynamic memory allocation and memory compression, memory fragmentation is reduced and memory utilization is improved; through efficient garbage collection mechanism, the impact of garbage collection on system performance is reduced; through intelligent memory management strategies, memory leakage and insufficient memory problems are avoided, and system performance is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216166A_ABST
    Figure CN120216166A_ABST
Patent Text Reader

Abstract

The invention discloses a memory optimization system and method based on dynamic memory allocation and garbage collection, and the system comprises a memory monitoring module which is used for monitoring the use condition of a memory in real time; the dynamic allocation module is used for dynamically adjusting a memory allocation strategy according to the memory demand of the application program; the garbage recycling module is used for recycling useless memory by adopting a fractional garbage recycling algorithm; the memory compression module is used for regularly merging free memory blocks; the performance optimization module is used for dynamically adjusting the garbage collection frequency and the memory allocation strategy according to the system load; through dynamic allocation and memory compression, memory fragmentation is reduced, and the memory utilization rate is increased; through an efficient garbage recycling mechanism, the influence of garbage recycling on system performance is reduced; through an intelligent memory management strategy, the problems of memory leakage and memory insufficiency are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer memory management, and particularly to a memory optimization system and method based on dynamic memory allocation and garbage collection. Background Art

[0002] In a computer system, memory management is one of the key factors affecting system performance; the existing memory management technologies have the following problems: (1) Memory fragmentation: Frequent memory allocation and release lead to memory fragmentation, reducing memory utilization.

[0003] (2) Low garbage collection efficiency: Traditional garbage collection algorithms (such as mark-sweep, copy algorithm) degrade in performance under high-load scenarios, resulting in increased system latency.

[0004] (3) Unreasonable dynamic memory allocation: Existing memory allocation strategies fail to dynamically adjust according to the actual needs of application programs, resulting in memory waste or shortage.

[0005] Therefore, there is an urgent need for a technical solution that can optimize the memory allocation and recycling mechanism to solve the above problems. Summary of the Invention

[0006] The purpose of the present invention is to provide, in view of the above problems in the prior art, a memory optimization system and method based on dynamic memory allocation and garbage collection, thereby solving all or one of the above problems existing in the prior art.

[0007] To solve the above technical problems, the specific technical solutions of the present invention are as follows: On the one hand, the present invention provides a memory optimization system based on dynamic memory allocation and garbage collection, including: A memory monitoring module for real-time monitoring of memory usage; A dynamic allocation module for dynamically adjusting the memory allocation strategy according to the memory requirements of application programs; A garbage collection module for recycling unused memory using a generational garbage collection algorithm; A memory compression module for periodically merging free memory blocks; A performance optimization module for dynamically adjusting the garbage collection frequency and memory allocation strategy according to system load.

[0008] Furthermore, the memory usage monitored by the memory monitoring module includes: used memory, free memory, and the degree of memory fragmentation.

[0009] Furthermore, the dynamic allocation module is also used to adopt an allocation strategy that combines partition allocation and buddy system.

[0010] Furthermore, the garbage collection module is also used to adopt the generational garbage collection algorithm, combined with the concurrent marking and incremental collection mechanism.

[0011] Furthermore, the memory compression module reduces memory fragmentation by merging free memory blocks.

[0012] Furthermore, the performance optimization module is also used to dynamically adjust the garbage collection frequency according to the system load.

[0013] Furthermore, the garbage collection module is also used to divide the memory into a young generation and an old generation, and adopt the copying algorithm and the mark-sweep algorithm respectively.

[0014] Furthermore, the memory monitoring module collects memory usage data every 5 minutes through a timer.

[0015] Furthermore, the dynamic allocation module is also used to support memory allocation in a multi-threaded environment.

[0016] On the other hand, the present invention also provides a memory optimization method based on dynamic memory allocation and garbage collection, including the following steps: Real-time monitor the memory usage; Dynamically adjust the memory allocation strategy according to the memory requirements of the application program; Adopt the generational garbage collection algorithm to recycle the useless memory; Regularly merge free memory blocks; Dynamically adjust the garbage collection frequency and the memory allocation strategy according to the system load The beneficial effects of the technical solution of the present invention are: 1. The memory optimization system based on dynamic memory allocation and garbage collection according to the present invention can reduce memory fragmentation and improve memory utilization through dynamic allocation and memory compression; reduce the impact of garbage collection on system performance through an efficient garbage collection mechanism; avoid memory leakage and memory shortage problems through an intelligent memory management strategy.

[0017] 2. The memory optimization method based on dynamic memory allocation and garbage collection according to the present invention can orderly call system modules, and then implement the system logic of the memory optimization system based on dynamic memory allocation and garbage collection according to the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0019] Figure 1 It is a schematic diagram of the architecture of the memory optimization system based on dynamic memory allocation and garbage collection described in Embodiment 1 of the present invention; Figure 2 It is a schematic flowchart of the memory optimization method based on dynamic memory allocation and garbage collection described in Embodiment 2 of the present invention. Detailed implementation manners

[0020] The following elaborates on the preferred embodiments of the present invention in conjunction with the accompanying drawings, so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making the protection scope of the present invention more clearly defined.

[0021] In the description of the present invention, it should be noted that the embodiments described in the present invention are part of the embodiments of the present invention, rather than all of the embodiments; all other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without creative work belong to the protection scope of the present invention.

[0022] The terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances, so that the embodiments described in this article can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or equipment that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or equipment. Embodiment 1

[0023] This embodiment provides a memory optimization system based on dynamic memory allocation and garbage collection, as Figure 1 shown, including: (1) Memory monitoring module: used to monitor the memory usage in real time, including the used memory, free memory, and memory fragmentation degree.

[0024] (2) Dynamic allocation module: dynamically adjusts the memory allocation strategy according to the memory requirements of the application program, and adopts a combination of partition allocation and buddy system to reduce memory fragmentation.

[0025] (3) Garbage collection module: adopts a generational garbage collection algorithm, combined with a concurrent marking and incremental recycling mechanism, to improve the garbage collection efficiency.

[0026] (4) Memory compression module: periodically compresses the memory, merges free memory blocks, and reduces fragmentation.

[0027] (5) Performance Optimization Module: Dynamically adjusts the garbage collection frequency and memory allocation strategy according to the system load to balance performance and resource consumption.

[0028] Specifically, in one implementation, the working logic of each of the above modules is as follows: Memory Monitoring: The memory monitoring module collects memory usage data in real time, including used memory, free memory, and memory fragmentation level; for example, when the system detects that the current memory fragmentation level is 30%, it determines that memory optimization is required.

[0029] Dynamic Allocation: The dynamic allocation module dynamically adjusts the allocation strategy according to the memory requirements of the application program; for example, for an application program that frequently requests small memory blocks, the buddy system allocation strategy is adopted; for large memory requirements, the partition allocation strategy is adopted.

[0030] Garbage Collection: The garbage collection module adopts the generational garbage collection algorithm, dividing the memory into the young generation and the old generation; the young generation uses the copying algorithm, and the old generation uses the mark-sweep algorithm; at the same time, combining the concurrent marking and incremental recycling mechanisms to reduce the impact of garbage collection on system performance.

[0031] Memory Compression: The memory compression module periodically compresses the memory and merges free memory blocks; for example, the system performs memory compression once every 10 minutes, merging fragmented free memory blocks into a continuous memory area.

[0032] Performance Optimization: The performance optimization module dynamically adjusts the garbage collection frequency and memory allocation strategy according to the system load; for example, in a high-load scenario, the garbage collection frequency is reduced to avoid system latency; in a low-load scenario, the garbage collection frequency is increased to release more memory.

[0033] Specifically, in one implementation, the system architecture of the present invention includes the following components: Hardware Layer: Includes computer memory (such as DRAM) and a processor.

[0034] Operating System Layer: Provides basic support for memory management, such as virtual memory management.

[0035] Application Layer: Includes a memory monitoring module, a dynamic allocation module, a garbage collection module, a memory compression module, and a performance optimization module.

[0036] Specifically, in one implementation, taking server memory optimization as an example, the application effect of this system is as follows: (1) The server runs multiple applications, and the memory monitoring module detects the memory usage in real time.

[0037] (2) The dynamic allocation module dynamically adjusts the allocation strategy according to the memory requirements of the applications to reduce memory fragmentation.

[0038] (3) The garbage collection module adopts the generational garbage collection algorithm to efficiently recycle the unused memory.

[0039] (4) The memory compression module periodically merges the free memory blocks to improve the memory utilization rate.

[0040] (5) The performance optimization module dynamically adjusts the garbage collection frequency according to the server load to ensure the stable system performance.

[0041] It should be noted that the above examples are only for explaining the present invention and should not limit the protection scope of the present invention. Embodiment 2

[0042] This embodiment is based on the same inventive concept as the memory optimization system based on dynamic memory allocation and garbage collection described in Embodiment 1, and provides a memory optimization method based on dynamic memory allocation and garbage collection. As Figure 2 shown, it includes the following steps: S100. Monitor the memory usage in real time; S200. Dynamically adjust the memory allocation strategy according to the memory requirements of the applications; S300. Adopt the generational garbage collection algorithm to recycle the unused memory; S400. Periodically merge the free memory blocks; S500. Dynamically adjust the garbage collection frequency and the memory allocation strategy according to the system load.

[0043] It should be understood that in various embodiments herein, the magnitudes of the sequence numbers of the above processes do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments herein.

[0044] It should also be understood that in the embodiments herein, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after.

[0045] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this article.

[0046] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific logical processes of the methods described above can refer to the corresponding working processes of the systems, devices, and units in the foregoing method embodiments, and will not be elaborated herein.

[0047] In the several embodiments provided in this article, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed couplings or direct couplings or communication connections to each other can be indirect couplings or communication connections through some interfaces, devices, or units, and can also be in electrical, mechanical, or other forms of connection.

[0048] 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 can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments in this article.

[0049] In addition, the functional units in the various embodiments in this article can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0050] When the integrated unit 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 this understanding, the technical solution herein, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments herein. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0051] The above are only embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. A memory optimization system based on dynamic memory allocation and garbage collection, characterized in that: include: Memory monitoring module, used to monitor memory usage in real time; Dynamic allocation module, used to dynamically adjust memory allocation strategy according to the memory requirements of the application; Garbage collection module, used to recycle unused memory using generational garbage collection algorithm; Memory compression module, used to periodically merge free memory blocks; Performance optimization module, used to dynamically adjust garbage collection frequency and memory allocation strategy according to system load.

2. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The memory usage monitored by the memory monitoring module includes: used memory, free memory and memory fragmentation degree.

3. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The dynamic allocation module is also used to adopt an allocation strategy combining partition allocation with a partner system.

4. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The garbage collection module is also used to adopt a generational garbage collection algorithm combined with concurrent marking and incremental collection mechanisms.

5. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The memory compression module reduces memory fragmentation by merging free memory blocks.

6. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The performance optimization module is also used to dynamically adjust the garbage collection frequency according to the system load.

7. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The garbage collection module is also used to divide the memory into a new generation and an old generation, using a copy algorithm and a mark-and-sweep algorithm respectively.

8. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The memory monitoring module collects memory usage data every five minutes through a timer.

9. The memory optimization system based on dynamic memory allocation and garbage collection according to claim 1, characterized in that: The dynamic allocation module is also used to support memory allocation in a multi-threaded environment.

10. A memory optimization method based on dynamic memory allocation and garbage collection, characterized in that: The following steps are involved: Monitor memory usage in real time; Dynamically adjust memory allocation strategy based on application memory requirements; Use generational garbage collection algorithm to recycle unused memory; Periodically merge free memory blocks; Dynamically adjust garbage collection frequency and memory allocation strategy according to system load.