Cross-process data zero copy method and device

By using multi-capacity shared memory blocks and ring queues in inter-process data transmission, the frequent memory release and allocation problems caused by changes in data volume are solved, and the speed of inter-process data transmission is improved.

CN119292804APending Publication Date: 2025-01-10IGRS ENG LAB(SHENZHEN) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411316662.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

When existing shared memory methods transmit data between processes, memory blocks are frequently released and redistributed due to changes in data volume, resulting in a decrease in the speed of data transmission between processes.

Method used

Using the zero copy method of data across processes, by creating multiple shared memory blocks with different capacity at the start of the first process, and matching and updating the memory blocks according to the amount of data passed each time, reducing the number of freeing and allocating memory blocks, using rings Queue organizes memory blocks to achieve efficient memory utilization.

Benefits of technology

It improves the speed of data transmission between processes, reduces the number of memory releases and redistributions caused by changes in data volume, and improves system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292804A_ABST
    Figure CN119292804A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-process data zero copy method and device, and relates to the technical field of cross-process communication, and the method comprises the steps: when a process is started, creating a shared memory, and dividing the shared memory into a plurality of memory blocks with different capacities; when data is transmitted between the two processes, matching a memory block with a corresponding capacity in the shared memory according to the data volume transmitted for the first time; when the data volume transmitted this time is not more than the data volume transmitted last time, updating the use length and the overflow mark of the currently used memory block; when the data size transmitted this time is larger than the data size transmitted last time and does not exceed the preset capacity, a memory block with the corresponding capacity is matched in the shared memory according to the data size transmitted this time, the content of the currently used memory block is copied to the memory block, and then the currently used memory block is released. According to the method, the number of times of releasing and reallocating the memory blocks due to the change of the transmission data volume is reduced, so that the inter-process data transmission speed is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cross-process communication technology, and in particular to a cross-process data zero-copy method and device. Background Art

[0002] In a non-real-time operating system, the system is divided into kernel space and user space. When processes need to exchange data, the zero-copy method is usually used to reduce the number of copies of data between kernel space and user space, thereby improving the efficiency of data transmission. Since there are requirements for the access speed of kernel space and user space during process communication, shared memory is usually used to achieve zero copy.

[0003] Existing shared memory methods usually allocate large blocks of memory and then divide the allocated content into fixed-length small memory blocks for management. When processes communicate, suitable memory blocks are selected from each memory block as shared memory according to actual conditions. After the communication is completed, the called memory block is released for next use.

[0004] However, since the existing shared memory method determines the size of the memory block at the beginning of process communication, when the amount of data to be transferred by the process changes, the system needs to release the original memory block first and then reallocate a new memory block. Moreover, since the size of the memory block is fixed, multiple allocations may be required to meet the transmission requirements of large amounts of data, which greatly reduces the speed of data transmission between processes. Summary of the invention

[0005] The present application provides a method and device for zero-copying data across processes, which can reduce the number of times memory blocks are released and reallocated due to changes in the amount of transmitted data, thereby increasing the speed of data transmission between processes.

[0006] In a first aspect, an embodiment of the present application provides a method for zero-copying data across processes, the method comprising:

[0007] When the first process is started, a shared memory is created, and the shared memory is divided into a plurality of memory blocks with different capacities;

[0008] When data is transferred between two processes, a memory block of corresponding capacity is matched in the shared memory according to the amount of data transferred initially;

[0009] When the amount of data transferred this time is no more than the amount of data transferred last time, the used length and overflow mark of the currently used memory block are updated;

[0010] When the amount of data transmitted this time is greater than the amount of data transmitted last time and does not exceed the preset first capacity, a first memory block of corresponding capacity is matched in the shared memory according to the amount of data transmitted this time, and the contents of the currently used memory block are copied to the first memory block, and then the currently used memory block is released.

[0011] In combination with the first aspect, in one implementation, when the first process is started, creating a shared memory includes:

[0012] When the first process is started, the first process is switched to kernel state, and the operating system creates a shared memory based on the ID of the first process;

[0013] Switch the first process to user mode and map the shared memory to user space.

[0014] In combination with the first aspect, in one implementation, after the shared memory is divided into a plurality of memory blocks with different capacities, the method further includes:

[0015] The multiple memory blocks with different capacities are organized into a ring queue.

[0016] In combination with the first aspect, in one implementation, matching a memory block of corresponding capacity in the shared memory according to the amount of data initially transferred includes:

[0017] Traversing the circular queue to determine whether there is a second memory block with a capacity equal to the amount of data transferred;

[0018] If so, use the second memory block as the memory block used for the initial transfer, and remove the second memory block from the circular queue;

[0019] If not, apply to the operating system for a third memory block with a capacity equal to the amount of data to be transferred, use the third memory block as the memory block used for the initial transfer and add it to the circular queue.

[0020] In combination with the first aspect, in one implementation, a process of releasing a memory block includes:

[0021] Add a memory block to the location pointed to by the tail pointer of the circular queue.

[0022] In combination with the first aspect, in one implementation, the method further includes:

[0023] After each data transfer, if the two processes end the communication, the currently used memory block is released.

[0024] In combination with the first aspect, in one implementation, the method further includes:

[0025] When the amount of data transferred this time exceeds the preset first capacity, applying to the operating system for a fourth memory block with a capacity equal to the amount of data transferred this time;

[0026] The content of the currently used memory block is copied to the fourth memory block, and then the currently used memory block is released.

[0027] In combination with the first aspect, in one implementation, the method further includes:

[0028] After each data transfer is completed, if the capacity of the currently used memory block exceeds the preset first capacity, the operating system reclaims the currently used memory block.

[0029] In combination with the first aspect, in one implementation, the operating system reclaims a currently used memory block, including:

[0030] Determine whether the overflow flag value of the currently used memory block has been changed;

[0031] If yes, the operating system records the timestamp and context information of this data transfer in the preset error log, and then reclaims the memory block;

[0032] If not, the operating system reclaims the memory block.

[0033] In a second aspect, an embodiment of the present application provides a cross-process data zero copy device, characterized in that the device includes:

[0034] A construction module, used for creating a shared memory when the first process is started, and dividing the shared memory into a plurality of memory blocks with different capacities;

[0035] An allocation module, used for matching a memory block of corresponding capacity in the shared memory according to the amount of data initially transferred when data is transferred between two processes;

[0036] An update module is used to update the usage length and overflow mark of the currently used memory block when the amount of data transferred this time is less than the amount of data transferred last time; it is also used to match a first memory block of corresponding capacity in the shared memory according to the amount of data transferred this time, copy the content of the currently used memory block to the first memory block, and then release the currently used memory block when the amount of data transferred this time is more than the amount of data transferred last time and does not exceed a preset first capacity.

[0037] The beneficial effects brought by the technical solution provided in the embodiments of the present application include:

[0038] When the amount of data being transferred decreases, the usage length and overflow mark of the memory block being used are updated to reduce the number of times memory is released; when the amount of data being transferred increases, the memory block suitable for the current amount of data is directly allocated to avoid multiple allocations of fixed small-capacity memory due to large-capacity memory requirements. Combining the above two methods, the number of times memory blocks are released and reallocated due to changes in the amount of data being transferred is reduced, thereby increasing the speed of data transmission between processes. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A schematic diagram of the process of a zero-copy method for data across processes according to an embodiment of the present application;

[0040] Figure 2 A schematic diagram of the process of creating a shared memory in the method for zero-copying data across processes according to an embodiment of the present application;

[0041] Figure 3 This is a flow chart of shared memory usage in the cross-process data zero-copy method according to an embodiment of the present application. DETAILED DESCRIPTION

[0042] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0043] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0044] First, please refer to Figure 1 , Figure 1 The cross-process data zero-copy method provided in this embodiment includes the following steps:

[0045] Step S1: When the first process is started, a shared memory is created and divided into a plurality of memory blocks with different capacities.

[0046] Step S2: When data is transferred between two processes, a memory block of corresponding capacity is matched in the shared memory according to the amount of data transferred initially.

[0047] Step S3: Determine whether the amount of data transferred this time is greater than the amount of data transferred last time. If so, proceed to step S4; if not, proceed to step S5.

[0048] Step S4: When the amount of data transferred this time does not exceed the preset first capacity, match the first memory block of corresponding capacity in the shared memory according to the amount of data transferred this time, copy the content of the currently used memory block to the first memory block, and then release the currently used memory block.

[0049] Step S5: Update the usage length and overflow flag of the currently used memory block.

[0050] This application reduces the number of memory releases by updating the usage length and overflow mark of the memory block in use when the amount of data being transmitted decreases; when the amount of data being transmitted increases, directly allocates a memory block suitable for the current amount of data, avoiding multiple allocations of fixed small-capacity memory due to large-capacity memory requirements. Combining the above two methods, the number of times memory blocks are released and reallocated due to changes in the amount of data being transmitted is reduced, thereby increasing the speed of data transmission between processes.

[0051] It should be noted that in non-real-time operating systems, when the system is divided into the kernel area and the user area, the communication methods for exchanging data are usually: anonymous pipes, named pipes, signals, message queues, semaphores, sockets, files, etc. Among them, pipes (anonymous pipes, named pipes) are simple data channels; semaphores are used for mutually exclusive access to resources; message queues allow storage and retrieval of data blocks; signals are used to handle abnormal situations; sockets support cross-network process communication; shared memory allows multiple processes to directly read and write the same memory space, which is the fastest and most available form of IPC (Inter-Process Communication).

[0052] When using sockets, pipes, and message queues for inter-process communication, the data transfer mode is: process A copies the data to the buffer kernel area and notifies process B; after receiving the notification, process B copies the data from the kernel to the process buffer and then processes the data. In this mode, valid data needs to be copied twice between the process state and the user state, and the program operation efficiency is low.

[0053] When shared memory is used for inter-process communication, the data transfer mode is: process A writes data into shared memory and notifies process B; after being notified, process B directly reads the data from shared memory. In this mode, valid data does not need to be copied between process state and user state, which improves efficiency compared to the previous mode. However, the action of process A notifying process B needs to be implemented through a short message, which still needs to copy data from the process address space to the kernel address space, reducing system performance.

[0054] Although there is a problem of common access, shared memory is still the fastest way to access between processes. In non-real-time operating systems, due to the speed requirements for accessing the kernel area and user area, the most efficient shared memory is usually selected to achieve zero copy.

[0055] In some embodiments, in the above step S1, when the first process is started, creating a shared memory includes the following steps:

[0056] First, when the first process is started, the first process is switched to kernel mode, and the operating system creates a shared memory based on the ID of the first process.

[0057] Afterwards, the first process is switched to user mode, and the shared memory is mapped to user space.

[0058] It should be noted that since there may be multiple shared memories in the kernel state, it is necessary to bind the shared memory through the process ID so that the process can use the shared memory it created independently.

[0059] In this embodiment, please refer to Figure 2 , Figure 2 The following is a flow chart of creating a shared memory in the method for zero-copying data across processes according to an embodiment of the present application. In the above step S1, when the first process is started, a shared memory is created and divided into a plurality of memory blocks with different capacities. The specific steps are as follows:

[0060] Step S11: The user state process calls a command to create a shared memory.

[0061] Step S12: After receiving the command, the kernel state creates a shared memory.

[0062] Step S13: Apply for shared memory in kernel mode, divide the shared memory into memory pools, and register corresponding miscellaneous devices.

[0063] Step S14: Notify the user-mode process that the shared memory creation is complete.

[0064] Step S15: After receiving the message that the shared memory is created, the user state process calls the mapping function.

[0065] Step S16: open the corresponding miscellaneous device and use mmap to map the shared memory.

[0066] Step S17: Associate the file handle with the shared memory.

[0067] Step S18: Map the shared memory to the user space.

[0068] It should be noted that using a memory pool to divide the shared memory and managing the divided memory blocks can effectively reduce the number of times the operating system is requested to release memory during process communication, thereby increasing the data transmission speed of process communication. At the same time, using a memory pool to manage shared memory can effectively reduce memory fragmentation caused by multiple requests for release, thereby reducing the probability of memory leaks and memory overflows.

[0069] Specifically, when the shared memory is divided by the memory pool, the capacity and number of the memory blocks can be set, the memory blocks with the same capacity can be put into the same memory linked list, and a check bit can be set for each memory block.

[0070] In the above step S16, open and mmap are system calls of the operating system. The open system call is used to open a file or device and return a file descriptor, which is used to reference the opened file and device. Opening the corresponding miscellaneous device actually requests the operating system to create a file descriptor for the miscellaneous device so that the miscellaneous device can be read and written through the file descriptor later.

[0071] The mmap system call is used to map a file or other object into the address space of a process. In this way, the process can access the contents of the file just like accessing ordinary memory without performing additional data copying operations. Using mmap to map shared memory actually maps the shared memory into the address space of the process. Once the mapping is completed, the process can directly access the shared memory through a pointer without having to use a system call to read and write data.

[0072] After the shared memory is initialized, the user mode and kernel mode processes can simultaneously call malloc, free, queue, dequeue and other functions to operate the shared memory and perform data processing.

[0073] In some embodiments, in the above step S1, after the shared memory is divided into a plurality of memory blocks with different capacities, the following steps are further included:

[0074] Organize multiple memory blocks of different capacities into a ring queue.

[0075] It should be noted that a circular queue is a data structure that uses a limited array space to simulate queue operations. The end of the array is connected to the beginning. This structure allows the circular queue to return to the beginning of the array when it reaches the physical boundary, thereby realizing the recycling of limited space and reducing memory fragmentation caused by frequent memory application and release.

[0076] Moreover, in a multi-process environment, the circular queue can implement synchronization by controlling the access to the head or tail pointer. This synchronization mechanism has lower overhead than other synchronization methods (such as locks) and can improve the overall speed of data transmission between processes.

[0077] In some embodiments, in the above step S2, matching a memory block of corresponding capacity in the shared memory according to the amount of data initially transferred includes the following steps:

[0078] First, traverse the circular queue to determine whether there is a second memory block with a capacity equal to the amount of data transferred.

[0079] If so, the second memory block is used as the memory block used for the initial transfer, and the second memory block is removed from the circular queue.

[0080] If not, apply to the operating system for a third memory block whose capacity is equal to the amount of data to be transferred, use the third memory block as the memory block used for the initial transfer and add it to the circular queue.

[0081] In some embodiments, in the above step S4, the process of releasing the memory block includes the following steps:

[0082] Add the memory block to the location pointed to by the tail pointer of the ring queue.

[0083] In some embodiments, the above cross-process data zero copy method further includes the following steps:

[0084] After each data transfer, if the two processes end the communication, the currently used memory block is released.

[0085] In some embodiments, the above cross-process data zero copy method further includes the following steps:

[0086] First, when the amount of data transferred this time exceeds the above-mentioned preset first capacity, a fourth memory block with a capacity equal to the amount of data transferred this time is requested from the operating system.

[0087] Then, the content of the currently used memory block is copied to the fourth memory block, and then the currently used memory block is released.

[0088] In some embodiments, the above cross-process data zero copy method further includes the following steps:

[0089] After each data transfer is completed, if the capacity of the currently used memory block exceeds the preset first capacity, the operating system reclaims the currently used memory block.

[0090] In some embodiments, the operating system reclaims the currently used memory block, including the following steps:

[0091] Determines whether the overflow flag value of the currently used memory block has been changed.

[0092] If so, the operating system records the timestamp and context information of this data transfer in the preset error log, and then reclaims the memory block.

[0093] If not, the operating system reclaims the memory block.

[0094] In this embodiment, please refer to Figure 3 , Figure 3 This is a shared memory usage flow chart of the cross-process data zero copy method of the embodiment of the present application. Based on the above cross-process data zero copy method and actual equipment, a more specific shared memory usage process is obtained, which includes the following steps:

[0095] Step A01: Device A applies for the memory required by SDU (Service Data Unit) in user mode.

[0096] Step A02: Device A applies for the memory required for PDU (Protocol Data Unit) in user mode.

[0097] Step A03: Device A releases the memory of the SDU in user mode.

[0098] Step A04: Device A stores the PDU into a ring queue in user mode.

[0099] Step A05: Device A takes out the PDU from the ring queue in kernel mode.

[0100] Step A06: Device A executes the service operation in the kernel state, stores the data of the service operation into the socket buffer, and transmits the socket buffer to device B.

[0101] Step A07: Device A releases the memory of the PDU in kernel mode.

[0102] Step A08: Device B applies for the memory required by the PDU in kernel mode.

[0103] Step A09: Device B performs service operations in kernel mode, reads data of device A's service operations from the socket buffer, and stores the data of device B's service operations into the PDU.

[0104] Step A10: Device B stores the PDU into a ring queue in kernel mode.

[0105] Step A11: Device B takes out the PDU from the ring queue in user mode.

[0106] Step A12: Device B applies for the memory required by the SDU in user mode.

[0107] Step A13: Device B releases the memory of the PDU in user mode.

[0108] Step A14: Device B releases the memory of the SDU in user mode.

[0109] It should be noted that PDU is a protocol data unit, which is the basic unit of data exchange between entities working at the same protocol layer. In the TCP / IP (Transmission Control Protocol / Internet Protocol) model, the PDU of the physical layer is bit (bit stream), the PDU of the data link layer is frame (frame), the PDU of the network layer is packet (packet), and the PDU of the transport layer is segment (segment) or datagram (datagram).

[0110] SDU is a service data unit. The lower layer protocol provides services for the upper layer protocol, and the PDU of the upper layer protocol will become the SDU of the lower layer. For example, after the PDU of the application layer is transmitted to the transport layer, it becomes the SDU of the transport layer; the SDU of the transport layer plus the header information of the transport layer constitute the PDU of the transport layer, and the PDU of the transport layer is transmitted to the network layer, which becomes the SDU of the network layer; the SDU of the network layer plus the header information of the network layer constitutes the PDU of the network layer, and after the PDU of the network layer is transmitted to the data link layer, it becomes the SDU of the data link layer; the SDU of the data link layer plus the frame header and frame trailer constitute the PDU of the physical layer.

[0111] In a second aspect, the present application provides a cross-process data zero-copy device, which includes a construction module, an allocation module and an update module.

[0112] The construction module is used to create a shared memory when the first process is started, and divide the shared memory into a plurality of memory blocks with different capacities.

[0113] When the allocation module is used for data transfer between two processes, a memory block of corresponding capacity is matched in the shared memory according to the amount of data initially transferred.

[0114] The update module is used to update the usage length and overflow mark of the currently used memory block when the amount of data transferred this time is less than the amount of data transferred last time.

[0115] The update module is also used to match a first memory block of corresponding capacity in the shared memory according to the amount of data transmitted this time, and copy the contents of the currently used memory block to the first memory block, and then release the currently used memory block when the amount of data transmitted this time is more than the amount of data transmitted last time and does not exceed the preset first capacity.

[0116] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0117] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.

[0118] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.

[0119] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.

[0120] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the 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 in sequence or in parallel, and these operations or steps may be combined.

[0121] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.

[0122] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for zero-copying data across processes, characterized in that: The method comprises: When the first process is started, a shared memory is created, and the shared memory is divided into a plurality of memory blocks with different capacities; When data is transferred between two processes, a memory block of corresponding capacity is matched in the shared memory according to the amount of data transferred initially; When the amount of data transferred this time is no more than the amount of data transferred last time, the used length and overflow mark of the currently used memory block are updated; When the amount of data transmitted this time is greater than the amount of data transmitted last time and does not exceed the preset first capacity, a first memory block of corresponding capacity is matched in the shared memory according to the amount of data transmitted this time, and the contents of the currently used memory block are copied to the first memory block, and then the currently used memory block is released.

2. The cross-process data zero copy method according to claim 1, characterized in that: When the first process is started, a shared memory is created, including: When the first process is started, the first process is switched to kernel state, and the operating system creates a shared memory based on the ID of the first process; Switch the first process to user mode and map the shared memory to user space.

3. The cross-process data zero copy method according to claim 1, characterized in that: After dividing the shared memory into a plurality of memory blocks with different capacities, the method further includes: The multiple memory blocks with different capacities are organized into a ring queue.

4. The cross-process data zero copy method according to claim 3, characterized in that: The matching of a memory block of corresponding capacity in the shared memory according to the amount of data initially transferred comprises: Traversing the circular queue to determine whether there is a second memory block with a capacity equal to the amount of data transferred; If so, use the second memory block as the memory block used for the initial transfer, and remove the second memory block from the circular queue; If not, apply to the operating system for a third memory block with a capacity equal to the amount of data to be transferred, use the third memory block as the memory block used for the initial transfer and add it to the circular queue.

5. The cross-process data zero copy method according to claim 3, characterized in that: The process of releasing a memory block includes: Add a memory block to the location pointed to by the tail pointer of the circular queue.

6. The cross-process data zero copy method according to claim 1, characterized in that: Also includes: After each data transfer, if the two processes end the communication, the currently used memory block is released.

7. The cross-process data zero copy method according to claim 1, characterized in that: Also includes: When the amount of data transferred this time exceeds the preset first capacity, applying to the operating system for a fourth memory block with a capacity equal to the amount of data transferred this time; The content of the currently used memory block is copied to the fourth memory block, and then the currently used memory block is released.

8. The cross-process data zero copy method according to claim 1, characterized in that: Also includes: After each data transfer is completed, if the capacity of the currently used memory block exceeds the preset first capacity, the operating system reclaims the currently used memory block.

9. The cross-process data zero copy method according to claim 8, characterized in that: The operating system reclaims the currently used memory block, including: Determine whether the overflow flag value of the currently used memory block has been changed; If yes, the operating system records the timestamp and context information of this data transfer in the preset error log, and then reclaims the memory block; If not, the operating system reclaims the memory block.

10. A cross-process data zero copy device based on the method according to any one of claims 1 to 9, characterized in that: The device comprises: A construction module, used for creating a shared memory when the first process is started, and dividing the shared memory into a plurality of memory blocks with different capacities; An allocation module, used for matching a memory block of corresponding capacity in the shared memory according to the amount of data initially transferred when data is transferred between two processes; An update module is used to update the usage length and overflow mark of the currently used memory block when the amount of data transferred this time is less than the amount of data transferred last time; it is also used to match a first memory block of corresponding capacity in the shared memory according to the amount of data transferred this time, copy the content of the currently used memory block to the first memory block, and then release the currently used memory block when the amount of data transferred this time is more than the amount of data transferred last time and does not exceed a preset first capacity.