Memory management method and device for data forwarding, equipment and storage medium

By dividing the memory pool into a frequently used memory area and an extended memory area, and dynamically managing the allocation and return of memory resources, the efficiency problem caused by memory resource sorting and searching algorithms is solved, thus achieving efficient memory management.

CN121357136APending Publication Date: 2026-01-16FIBERHOME TELECOMMUNICATION TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511470251.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-15
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

In the data forwarding process, existing technologies require complex memory resource sorting and search algorithms to ensure the order and continuity of each resource in the memory pool, which leads to a decrease in software forwarding efficiency.

Method used

The memory pool is divided into a fixed-size common memory area and a dynamically sized memory expansion area. Memory resources are dynamically allocated and returned based on the current memory resource usage, avoiding complex sorting and search algorithms.

Benefits of technology

Avoid memory fragmentation under low load, improve data forwarding efficiency, simplify memory management, and avoid unnecessary sorting and lookup operations for memory resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121357136A_ABST
    Figure CN121357136A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of communication, and discloses a memory management method and device for data forwarding, equipment and a storage medium. The method comprises the following steps: dividing a memory pool into a memory common area and a memory expansion area; wherein the memory common area is of a fixed size, and the memory expansion area is of a dynamic size; when a message is forwarded, distributing memory resources of the memory common area or the memory expansion area to the outside according to a current memory resource usage amount pointer so as to map and store the message; wherein each memory resource distributed to the outside by the memory common area and the memory expansion area has a corresponding mark; and when forwarding of the message is finished, returning the memory resource storing the message to a region corresponding to a memory pool based on the mark corresponding to the memory resource. Through the method and the device, the technical problem that in the prior art, in order to ensure that each resource in the memory pool is sequential and continuous, only a complex algorithm can be added is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a memory management method, apparatus, device, and storage medium for data forwarding. Background Technology

[0002] When network devices forward data streams, some service flows need to be sent to the CPU for forwarding via the software's network protocol stack. During data forwarding, the network device receives N packets and needs to request N consecutive resources from the memory pool. However, because the packets take different forwarding paths, the order in which the packets are returned to the memory pool after transmission is different from the order in which the packets were requested from the memory pool. During the initialization phase of the memory pool, each resource is sequential and contiguous. After multiple rounds of resource allocation and release, the resources in the memory pool will inevitably become out-of-order and non-contiguous. This dynamic memory pool needs to expand under high traffic load and shrink under low traffic load.

[0003] In existing technologies, the memory pool additionally maintains the relative position of each memory resource. When a memory resource is returned, it is placed in a designated position in the memory pool, and the continuity of memory is maintained by a memory resource sorting algorithm. When the memory pool shrinks under low load, each memory resource is traversed one by one by a memory resource search algorithm, and the usage status of its associated adjacent memory resources is searched. After finding multiple consecutive memory resources in an idle state, they are returned to the system memory.

[0004] While memory resource sorting and lookup algorithms can guarantee that each resource in the memory pool is ordered and continuous, they also increase overhead when allocating or releasing memory resources. In scenarios with high-frequency memory allocation or release, such as data forwarding, this can lead to reduced software forwarding efficiency. Summary of the Invention

[0005] This invention provides a memory management method, apparatus, device, and storage medium for data forwarding, which can solve the technical problem in the prior art that only complex algorithms can be added in order to ensure the order and continuity of each resource in the memory pool.

[0006] To achieve the above objectives, the present invention provides the following technical solution: A memory management method for data forwarding, the method comprising: The memory pool is divided into a commonly used memory area and a memory expansion area; wherein, the commonly used memory area has a fixed size, and the memory expansion area has a dynamic size; When forwarding a message, memory resources in the commonly used memory area or the extended memory area are allocated externally according to the current memory resource usage pointer for mapping and storing the message; each memory resource allocated externally in the commonly used memory area and the extended memory area has its corresponding tag; When the packet forwarding ends, based on the tag corresponding to the memory resource, the memory resource storing the packet is returned to the area corresponding to the memory pool.

[0007] Optionally, in one embodiment, the step of allocating memory resources of the commonly used memory area or the memory extension area externally according to the current memory resource usage pointer includes: Detect whether the current resource usage of the commonly used memory area is greater than a first preset number; If the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, then memory resources are allocated externally according to the current memory resource usage pointer of the commonly used memory area.

[0008] Optionally, in one embodiment, after detecting whether the current resource usage of the frequently used memory area is greater than a first preset number, the process includes: If the current resource usage of the commonly used memory area is greater than the first preset amount, allocate a second preset amount of memory resources to the memory extension area; When the current resource usage of the commonly used memory area reaches a third preset amount, memory resources are allocated externally according to the current memory resource usage pointer of the memory extension area. The third preset quantity is the total number of memory resources in the commonly used memory area, and the third preset quantity is greater than the first preset quantity.

[0009] Optionally, in one embodiment, after allocating memory resources externally according to the current memory resource usage pointer of the memory extension area, the following steps are included: When the current resource usage of the memory expansion area reaches a second preset amount, the memory expansion area is expanded. When the current resource usage of the memory expansion area is less than the fourth preset number, the memory expansion area is shrunk. The fourth preset quantity is less than the second preset quantity.

[0010] Optionally, in one embodiment, the method further includes: Detect whether the current resource usage of the memory extension area is within a preset value; If it is a preset value, the memory extension area will be returned to the operating system; If it is not the preset value, after a preset interval, return to the step of checking whether the current resource usage of the memory extension area is the preset value.

[0011] Based on the same inventive concept, embodiments of the present invention also provide a memory management device for data forwarding, the device comprising: The memory pool partitioning module is configured to divide the memory pool into a commonly used memory area and a memory extension area; wherein the commonly used memory area has a fixed size and the memory extension area has a dynamic size. The memory resource allocation module is configured to allocate memory resources in the commonly used memory area or the extended memory area according to the current memory resource usage pointer when forwarding packets, so as to map and store the packets; wherein each memory resource allocated externally in the commonly used memory area and the extended memory area has its corresponding tag; The memory resource return module is configured to return the memory resource storing the packet to the area corresponding to the memory pool based on the tag corresponding to the memory resource when the packet forwarding ends.

[0012] Optionally, in one embodiment, the memory resource allocation module is specifically configured to: Detect whether the current resource usage of the commonly used memory area is greater than a first preset number; If the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, then memory resources are allocated externally according to the current memory resource usage pointer of the commonly used memory area; If the current resource usage of the commonly used memory area is greater than the first preset amount, allocate a second preset amount of memory resources to the memory extension area; When the current resource usage of the commonly used memory area reaches a third preset amount, memory resources are allocated externally according to the current memory resource usage pointer of the memory extension area. When the current resource usage of the memory expansion area reaches a second preset amount, the memory expansion area is expanded. When the current resource usage of the memory expansion area is less than the fourth preset number, the memory expansion area is shrunk. The third preset quantity is the total number of memory resources in the commonly used memory area. The third preset quantity is greater than the first preset quantity, and the fourth preset quantity is less than the second preset quantity.

[0013] Optionally, in one embodiment, the memory resource return module is further configured to: Detect whether the current resource usage of the memory extension area is within a preset value; If it is a preset value, the memory extension area will be returned to the operating system; If it is not the preset value, after a preset interval, return to the step of checking whether the current resource usage of the memory extension area is the preset value.

[0014] Based on the same inventive concept, embodiments of the present invention also provide an electronic device, including: a memory and a processor; the processor is configured to read and execute a computer program stored in the memory to implement the steps of the aforementioned memory management method for data forwarding.

[0015] Based on the same inventive concept, embodiments of the present invention also provide a computer storage medium storing computer-executable instructions, which, when executed, implement the steps of the aforementioned memory management method for data forwarding.

[0016] The technical effects and advantages of this invention are as follows: Under low load, packet forwarding still requires repeated requests for and / or release of resources from the memory pool. After multiple rounds of requesting and / or releasing resources, all memory resources in the memory extension (exp) area will be in a state of idle and unused. After returning all memory resources in the memory extension area to the operating system, the size of the memory extension area becomes zero. There is no need to sort the addresses of internal resources in the extension area, and there is no fragmentation. The complete memory extension area is returned to the operating system, avoiding memory fragmentation residue. After the packet forwarding is completed, there is no need to add a complex algorithm to sort the memory for each memory resource allocation and / or release action. The solution is simple and does not affect the processing efficiency of packet forwarding. This invention solves the technical problem in the prior art that, in order to ensure the order and continuity of each resource in the memory pool, one can only add complex algorithms.

[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 A flowchart of the method provided in the embodiments of the present invention; Figure 2 This is a schematic diagram of the first embodiment of the memory pool; Figure 3 This is a schematic diagram of a second embodiment of the memory pool; Figure 4 This is a schematic diagram of the first embodiment of the commonly used area and the extended area of ​​the memory pool of the present invention; Figure 5 This is a schematic diagram of the second embodiment of the commonly used area and the extended area of ​​the memory pool of the present invention; Figure 6 This is a schematic diagram of the third embodiment of the commonly used area and the extended area of ​​the memory pool of the present invention; Figure 7 This is a schematic diagram of the fourth embodiment of the commonly used area and the extended area of ​​the memory pool of the present invention; Figure 8 This is a schematic diagram of the fifth embodiment of the commonly used area and the extended area of ​​the memory pool of the present invention; Figure 9 for Figure 1 A detailed flowchart of step S20; Figure 10 This is a schematic diagram of the functional modules of a memory management device for data forwarding according to an embodiment of the present invention. Figure 11 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] To address the shortcomings of existing technologies, this invention discloses a memory management method for data forwarding, comprising: Step S10: Divide the memory pool into a commonly used memory area and a memory expansion area; wherein the commonly used memory area has a fixed size and the memory expansion area has a dynamic size. In this embodiment, refer to Figure 2 During the dynamic memory pool initialization phase, contiguous memory objects (obj) are requested from the operating system (Slab cache). Each member of the memory stack stores a usable memory address. Figure 2In the stack, `Buf_top_idx` indicates the maximum number of `kmem_cache_alloc`s, which is the total amount of resources in the memory pool, including both used (cur) and available (avail) memory resources. `Buf_cur_idx` indicates the current usage of the memory pool. Initially, when no resources are allocated externally, `Buf_cur_idx` points to the bottom of the stack. The `kmem_cache_alloc()` function is used to allocate an object from a given cache. If the cache is currently empty, this function will call `cache_alloc_refill()` to add memory to the cache.

[0022] Reference Figure 3 During data forwarding, the packet receiving phase requires requesting a memory resource from the memory pool to store the packet. After packet sending is completed, the memory resource is returned to the memory pool once it is no longer needed. When requesting memory, after obtaining a free memory resource according to Buf_cur_idx, the Buf_cur_idx pointer moves upward (unused memory resources correspond to...). Figure 3 The green sections indicate the memory resources that have been used. Figure 3 (The red part is marked in the middle). When returning memory resources, the stack member is found according to Buf_cur_idx and its memory address is stored. The Buf_cur_idx pointer is then moved down. The Buf_cur_idx pointer is a pointer to the current amount of memory resources used.

[0023] The memory pool expands under high traffic load and shrinks under low traffic load. When shrinking, contiguous resources need to be returned to system memory; otherwise, memory fragmentation will occur, indirectly leading to insufficient remaining system memory. Additionally, when shrinking, all free slab pages of the memory object (obj) are deleted; when expanding, new slab pages are allocated. A slab is the smallest unit of the slab allocator, and in implementation, a slab consists of one or more contiguous physical pages.

[0024] This embodiment, while ensuring the efficiency of memory pool resource allocation or release, shrinks the memory pool when the network load changes from high to low, returning contiguous memory to the operating system and avoiding memory fragmentation.

[0025] Reference Figure 4The memory pool is divided into a base pool and an exp pool. During device initialization, the base pool requests memory from the operating system, while the exp pool does not. The base pool has a fixed size, while the exp pool has a dynamic size. During initialization, a number of memory units are requested, slightly exceeding the low-load forwarding memory requirement, and stored in the base pool. Memory resources from the base pool are allocated externally first. When the base pool is nearly exhausted, the exp pool is dynamically expanded, and memory from the exp pool is allocated externally only after the base pool is completely depleted.

[0026] Step S20: When forwarding a message, memory resources in the commonly used memory area or the extended memory area are allocated externally according to the current memory resource usage pointer for mapping and storing the message; wherein, each memory resource allocated externally in the commonly used memory area and the extended memory area has its corresponding tag; Furthermore, in one embodiment, reference is made to Figure 9 Step S20 includes: Step S201: Detect whether the current resource usage of the commonly used memory area is greater than a first preset number; Step S202: If the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, then memory resources are allocated externally according to the current memory resource usage pointer of the commonly used memory area. Step S203: If the current resource usage of the commonly used memory area is greater than the first preset amount, allocate a second preset amount of memory resources to the memory extension area; Step S204: When the current resource usage of the commonly used memory area reaches a third preset number, memory resources are allocated externally according to the current memory resource usage pointer of the memory extension area; wherein, the third preset number is the total number of memory resources in the commonly used memory area, and the third preset number is greater than the first preset number; Step S205: When the current resource usage of the memory expansion area reaches a second preset amount, the memory expansion area is expanded. Step S206: When the current resource usage of the memory expansion area is less than the fourth preset number, shrink the memory expansion area; wherein the fourth preset number is less than the second preset number.

[0027] In this embodiment, refer to Figure 5 When forwarding messages, if the traffic load is low, that is, when the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, memory resources are allocated externally from the commonly used memory area according to the Buf_cur_idx pointer.

[0028] When the load on the commonly used memory area increases to the point of exhaustion (the current resource usage of the commonly used memory area is greater than the first preset amount), the commonly used memory area will not expand its memory (i.e., the buf_top_idx of the commonly used area is fixed), and a second preset amount of memory resources will be allocated to the memory extension area, that is, the memory extension area will start to request a certain amount of contiguous memory from the operating system.

[0029] Once the memory in the frequently used memory area is exhausted (the current resource usage of the frequently used memory area reaches the third preset amount), memory resources in the extended memory area are allocated externally according to the current memory resource usage pointer, that is, memory is allocated externally according to the Buf_cur_idx of the extended area. The third preset amount is the total memory resources in the frequently used memory area, and this third preset amount is greater than the first preset amount.

[0030] If the memory resources of the memory extension area are nearly exhausted (the current resource usage of the memory extension area reaches the second preset amount), the memory of the extension area will be expanded (the buf_top_idx of the extension area will be dynamically increased).

[0031] When there are many unused memory resources in the memory extension area (the current resource usage of the memory extension area is less than the fourth preset number), the memory extension area is shrunk. The fourth preset number is less than the second preset number.

[0032] Since the frequently used area does not need to maintain the sorting of memory resources, the memory returned to the system from the frequently used area when it is idle is discontinuous, i.e., fragmented. In this embodiment, the frequently used area will not expand its memory (i.e., the buf_top_idx of the frequently used area is fixed). Even if fragmentation exists, it is suppressed within a certain range, and memory resources of the frequently used area of ​​the memory pool are allocated externally first. When the memory resources of the frequently used area of ​​the memory pool are about to be exhausted, the memory extension area is dynamically expanded. The memory resources of the extension area are only allocated externally after the memory of the frequently used area is completely exhausted (the current resource usage of the memory extension area reaches the second preset amount). This setting ensures that under low load, the memory resources of the memory extension area (exp) are all in an idle and unused state after multiple rounds of allocation and / or release, so as to achieve the goal of returning the complete memory extension area to the operating system and avoiding the residual memory fragments in the memory extension area.

[0033] Step S30: When the packet forwarding ends, based on the tag corresponding to the memory resource, the memory resource storing the packet is returned to the area corresponding to the memory pool.

[0034] In this embodiment, refer to Figure 6Each memory resource allocated by the memory pool carries a marker for the frequently used memory area and the extended memory area. When packet forwarding ends and the memory resource is returned to the memory pool, the corresponding memory pool is looked up based on the marker corresponding to the memory resource, and the memory resource is returned to the corresponding position in the memory pool according to Buf_cur_idx.

[0035] Furthermore, in one embodiment, the method further includes: Detect whether the current resource usage of the memory extension area is within a preset value; If it is a preset value, the memory extension area will be returned to the operating system; If it is not the preset value, after a preset interval, return to the step of checking whether the current resource usage of the memory extension area is the preset value.

[0036] In this embodiment, when both the base memory area and the extended memory area have free memory resources, memory resources from the base memory area will be allocated externally first. The data packet forwarding process will inevitably involve repeatedly requesting and / or releasing memory resources within the memory pool. (Refer to...) Figure 7 Under low load, after multiple rounds of allocation and / or release, all memory resources in the memory extension (exp) area will be in a state of idle and unused.

[0037] Reference Figure 8 The system checks whether all memory resources in the extended memory area are in a completely idle and unused state; that is, it checks whether the current resource usage of the extended memory area is zero. If the current resource usage of the extended memory area is zero, then all memory resources in the extended memory area are returned to the operating system. The extended memory area has a dynamic shrinking function; when all memory resources in the extended memory area are returned to the operating system, the size of the extended memory area becomes 0. The complete extended memory area is returned to the operating system, avoiding memory fragmentation.

[0038] In this embodiment, the memory pool is divided into a commonly used memory area and a memory extension area. The commonly used memory area has a fixed size, while the memory extension area has a dynamic size. When forwarding packets, memory resources in either the commonly used memory area or the memory extension area are allocated externally according to the current memory resource usage pointer for mapping and storing the packets. Each memory resource allocated externally in the commonly used memory area and the memory extension area has a corresponding tag. When packet forwarding ends, based on the tag corresponding to the memory resource, the memory resource storing the packet is returned to the corresponding area of ​​the memory pool. Through this embodiment, after packet forwarding ends, for each memory resource allocation and / or release action, there is no need to add complex algorithms for memory sorting. The solution is simple and does not affect the processing efficiency of packet forwarding, solving the technical problem in the prior art that only complex algorithms can be added to ensure the order and contiguousness of each resource in the memory pool.

[0039] Based on the same inventive concept, embodiments of the present invention also provide a memory management device for data forwarding.

[0040] In one embodiment, reference is made to Figure 10 , Figure 10 This is a functional module diagram of an embodiment of the memory management device for data forwarding according to the present invention. Figure 10 As shown, the memory management device for data forwarding includes: The memory pool partitioning module 10 is configured to divide the memory pool into a commonly used memory area and a memory extension area; wherein the commonly used memory area has a fixed size and the memory extension area has a dynamic size. The memory resource allocation module 20 is configured to allocate memory resources of the commonly used memory area or the extended memory area according to the current memory resource usage pointer when forwarding packets, so as to map and store the packets; wherein each memory resource allocated externally by the commonly used memory area and the extended memory area has its corresponding tag; The memory resource return module 30 is configured to return the memory resource storing the packet to the area corresponding to the memory pool based on the tag corresponding to the memory resource when the packet forwarding ends.

[0041] Optionally, in one embodiment, the memory resource allocation module 20 is specifically configured to: Detect whether the current resource usage of the commonly used memory area is greater than a first preset number; If the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, then memory resources are allocated externally according to the current memory resource usage pointer of the commonly used memory area.

[0042] Optionally, in one embodiment, the memory resource allocation module 20 is specifically configured to: If the current resource usage of the commonly used memory area is greater than the first preset amount, allocate a second preset amount of memory resources to the memory extension area; When the current resource usage of the commonly used memory area reaches a third preset amount, memory resources are allocated externally according to the current memory resource usage pointer of the memory extension area. The third preset quantity is the total number of memory resources in the commonly used memory area, and the third preset quantity is greater than the first preset quantity.

[0043] Optionally, in one embodiment, the memory resource allocation module 20 is specifically configured to: When the current resource usage of the memory expansion area reaches a second preset amount, the memory expansion area is expanded. When the current resource usage of the memory expansion area is less than the fourth preset number, the memory expansion area is shrunk. The fourth preset quantity is less than the second preset quantity.

[0044] Optionally, in one embodiment, the memory resource return module 30 is further configured to: Detect whether the current resource usage of the memory extension area is within a preset value; If it is a preset value, the memory extension area will be returned to the operating system; If it is not the preset value, after a preset interval, return to the step of checking whether the current resource usage of the memory extension area is the preset value.

[0045] The functions of each module in the memory management device for data forwarding correspond to the steps in the memory management method embodiment for data forwarding, and their functions and implementation processes will not be described in detail here.

[0046] Based on the same inventive concept, embodiments of the present invention also provide an electronic device, the structure of which is as follows: Figure 11 As shown, it includes: a memory and a processor, wherein the processor is used to read and execute computer programs stored in the memory to implement the aforementioned memory management method for data forwarding.

[0047] Based on the same inventive concept, embodiments of the present invention also provide a computer storage medium storing computer-executable instructions, which, when executed, implement the aforementioned method for memory management of data forwarding.

[0048] Finally, it should be noted that while some processes described in the embodiments of the present invention include multiple operations or steps that appear in a specific order, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of the present invention, or may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.

[0049] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A memory management method for data forwarding, characterized in that, The method includes: The memory pool is divided into a commonly used memory area and a memory expansion area; wherein, the commonly used memory area has a fixed size, and the memory expansion area has a dynamic size; When forwarding a message, memory resources in the commonly used memory area or the extended memory area are allocated externally according to the current memory resource usage pointer for mapping and storing the message; each memory resource allocated externally in the commonly used memory area and the extended memory area has its corresponding tag; When the packet forwarding ends, based on the tag corresponding to the memory resource, the memory resource storing the packet is returned to the area corresponding to the memory pool.

2. The memory management method for data forwarding according to claim 1, characterized in that, The process of allocating memory resources from the commonly used memory area or the extended memory area according to the current memory resource usage pointer includes: Detect whether the current resource usage of the commonly used memory area is greater than a first preset number; If the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, then memory resources are allocated externally according to the current memory resource usage pointer of the commonly used memory area.

3. The memory management method for data forwarding according to claim 2, characterized in that, After detecting whether the current resource usage of the commonly used memory area is greater than a first preset number, the process includes: If the current resource usage of the commonly used memory area is greater than the first preset amount, allocate a second preset amount of memory resources to the memory extension area; When the current resource usage of the commonly used memory area reaches a third preset amount, memory resources are allocated externally according to the current memory resource usage pointer of the memory extension area. The third preset quantity is the total number of memory resources in the commonly used memory area, and the third preset quantity is greater than the first preset quantity.

4. The memory management method for data forwarding according to claim 3, characterized in that, After allocating memory resources externally according to the current memory resource usage pointer of the memory extension area, the following steps are included: When the current resource usage of the memory expansion area reaches a second preset amount, the memory expansion area is expanded. When the current resource usage of the memory expansion area is less than the fourth preset number, the memory expansion area is shrunk. The fourth preset quantity is less than the second preset quantity.

5. The memory management method for data forwarding according to claim 1, characterized in that, The method further includes: Detect whether the current resource usage of the memory extension area is within a preset value; If it is a preset value, the memory extension area will be returned to the operating system; If it is not the preset value, after a preset interval, return to the step of checking whether the current resource usage of the memory extension area is the preset value.

6. A memory management device for data forwarding, characterized in that, The device includes: The memory pool partitioning module is configured to divide the memory pool into a commonly used memory area and a memory extension area; wherein the commonly used memory area has a fixed size and the memory extension area has a dynamic size. The memory resource allocation module is configured to allocate memory resources in the commonly used memory area or the extended memory area according to the current memory resource usage pointer when forwarding packets, so as to map and store the packets; wherein each memory resource allocated externally in the commonly used memory area and the extended memory area has its corresponding tag; The memory resource return module is configured to return the memory resource storing the packet to the area corresponding to the memory pool based on the tag corresponding to the memory resource when the packet forwarding ends.

7. The memory management device for data forwarding according to claim 6, characterized in that, The memory resource allocation module is specifically configured to: Detect whether the current resource usage of the commonly used memory area is greater than a first preset number; If the current resource usage of the commonly used memory area is less than or equal to the first preset quantity, then memory resources are allocated externally according to the current memory resource usage pointer of the commonly used memory area; If the current resource usage of the commonly used memory area is greater than the first preset amount, allocate a second preset amount of memory resources to the memory extension area; When the current resource usage of the commonly used memory area reaches a third preset amount, memory resources are allocated externally according to the current memory resource usage pointer of the memory extension area. When the current resource usage of the memory expansion area reaches a second preset amount, the memory expansion area is expanded. When the current resource usage of the memory expansion area is less than the fourth preset number, the memory expansion area is shrunk. The third preset quantity is the total number of memory resources in the commonly used memory area. The third preset quantity is greater than the first preset quantity, and the fourth preset quantity is less than the second preset quantity.

8. The memory management device for data forwarding according to claim 6, characterized in that, The memory resource return module is also configured to: Detect whether the current resource usage of the memory extension area is within a preset value; If it is a preset value, the memory extension area will be returned to the operating system; If it is not the preset value, after a preset interval, return to the step of checking whether the current resource usage of the memory extension area is the preset value.

9. An electronic device, characterized in that, include: Memory, processor; The processor is configured to read and execute the computer program stored in the memory to implement the memory management method for data forwarding as described in any one of claims 1-5.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed, implement the memory management method for data forwarding as described in any one of claims 1-5.