Memory management method and processing device

By allocating and releasing memory for the first thread of the image decoding task, the problem of inefficient memory management in the prior art is solved, and more efficient memory resource utilization is achieved.

CN120256092APending Publication Date: 2025-07-04KUNLUNXIN TECHNOLOGY (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510221328.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the prior art, frequent allocation and release of memory when decoding multiple images leads to inefficiency and inability to efficiently manage memory resources.

Method used

By creating a first thread of the image decoding task, each first device allocates memory under the thread to cache the decoded image, and releases the memory uniformly after the task is completed.

Benefits of technology

It improves the efficiency of memory allocation and release, reduces the generation of memory fragmentation, and improves the overall efficiency of image decoding tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256092A_ABST
    Figure CN120256092A_ABST
Patent Text Reader

Abstract

The invention provides a memory management method and a processing device, and relates to the technical field of computers, in particular to the technical fields of image processing, memory allocation and the like. According to the specific implementation scheme, in response to a received request for starting an image decoding task, a first thread used for executing the image decoding task is created, and one or more first devices under the first thread are determined; a memory corresponding to each first device under the first thread is allocated to each first device in the one or more first devices, and the memory corresponding to each first device under the first thread is used for caching the decoded image of each first device under the first thread; and under the condition of determining that the first thread completes the image decoding task, releasing the memory corresponding to each piece of first equipment under the first thread.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to technical fields such as image processing and memory allocation. Background Art

[0002] In the prior art, when decoding multiple images, it is necessary to allocate memory for each image to cache the decoded image; after the image is decoded, the memory allocated for the image is released, which results in frequent allocation and release of memory for each image. Therefore, how to improve the efficiency of memory allocation and release during the decoding of multiple images becomes a technical problem to be solved. Summary of the Invention

[0003] The present disclosure provides a memory management method and a processing device.

[0004] According to one aspect of the present disclosure, there is provided a memory management method applied to a processing device, including:

[0005] In response to receiving a request to start an image decoding task, creating a first thread for executing the image decoding task, and determining one or more first devices under the first thread;

[0006] Allocating, for each of the one or more first devices, the memory corresponding to the first device under the first thread, where the memory corresponding to the first device under the first thread is used to cache the decoded image of the first device under the first thread;

[0007] When it is determined that the first thread has completed the image decoding task, releasing the memory corresponding to the first device under the first thread.

[0008] According to one aspect of the present disclosure, there is provided a processing device, including:

[0009] A thread creation module, configured to create a first thread for executing the image decoding task and determine one or more first devices under the first thread in response to receiving a request to start an image decoding task;

[0010] A memory management module, configured to allocate, for each of the one or more first devices, the memory corresponding to the first device under the first thread, where the memory corresponding to the first device under the first thread is used to cache the decoded image of the first device under the first thread; when it is determined that the first thread has completed the image decoding task, releasing the memory corresponding to the first device under the first thread.

[0011] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0012] at least one processor; and

[0013] a memory communicatively connected to the at least one processor; wherein,

[0014] the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute any one of the methods in the embodiments of the present disclosure.

[0015] According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute any one of the methods in the embodiments of the present disclosure.

[0016] According to another aspect of the present disclosure, there is provided a computer program product, comprising a computer program which, when executed by a processor, implements any one of the methods in the embodiments of the present disclosure.

[0017] According to another aspect of the present disclosure, there is provided an autonomous vehicle comprising the above-mentioned electronic device.

[0018] By adopting the method provided in this embodiment, the memory corresponding to each first device under the first thread for executing the image decoding task is allocated to each first device for caching the decoded images of each first device under the first thread; after the decoding task is completed, the memory corresponding to each first device under the first thread is released. In this way, the memory can be allocated to each first device only once under the first thread, and all the memory allocated to the first devices under the first thread can be released at once after the image decoding task is completed, without separately allocating and releasing the memory for each image among multiple images under the first thread, thereby improving the efficiency of memory allocation and release.

[0019] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings are used to better understand the solution and do not constitute a limitation to the present disclosure. Among them:

[0021] Figure 1 is a schematic flowchart of a memory management method according to an embodiment of the present disclosure;

[0022] Figure 2 is a schematic diagram of a scenario of a management linked list according to an embodiment of the present disclosure;

[0023] Figure 3 It is a schematic flowchart of sending the current image to be decoded to the target device according to an embodiment of the present disclosure;

[0024] Figure 4 It is a schematic flowchart of a memory management method according to another embodiment of the present disclosure;

[0025] Figure 5 It is a schematic block diagram of a processing device according to an embodiment of the present disclosure;

[0026] Figure 6 It is a schematic block diagram of a processing device according to another embodiment of the present disclosure;

[0027] Figure 7 It is a block diagram of an electronic device for implementing the embodiments of the present disclosure. Detailed implementation manners

[0028] The following describes exemplary embodiments of the present disclosure with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, descriptions of well-known functions and structures are omitted for clarity and conciseness.

[0029] Figure 1 It is a schematic flowchart of a memory management method provided according to an embodiment of the present disclosure, including:

[0030] S101. In response to receiving a request to start an image decoding task, create a first thread for executing the image decoding task, and determine one or more first devices under the first thread.

[0031] S102. Allocate memory corresponding to each of the one or more first devices under the first thread to each of the first devices, where the memory corresponding to each first device under the first thread is used to cache the decoded images of each first device under the first thread.

[0032] S103. When it is determined that the first thread has completed the image decoding task, release the memory corresponding to each first device under the first thread.

[0033] The memory management method provided in this embodiment can be applied to a processing device, which at least includes a processor and a memory. For example, the processor can be a Central Processing Unit (CPU) or other hardware or chips with computing capabilities, and the memory can be a Random Access Memory (RAM) or other memories with read / write capabilities.

[0034] By adopting the method provided in this embodiment, each first device executing an image decoding task in a first thread is allocated the memory corresponding to each first device under the first thread for caching the decoded images of each first device under the first thread; after the decoding task is completed, the memory corresponding to each first device under the first thread is released. In this way, the memory can be allocated to each first device only once under the first thread, and all the memory allocated to all first devices under the first thread can be released at once after the image decoding task is completed, without separately allocating and releasing the memory for the images to be decoded under the first thread, thus improving the efficiency of memory allocation and release.

[0035] In one implementation manner, the receiving a request to start an image decoding task includes: receiving a request to start an image decoding task sent by the data loader; the method further includes: determining that the first thread has completed the image decoding task when receiving an indication that the image decoding task sent by the data loader is completed.

[0036] The operations performed on the data loader side include: in response to a trigger operation for an image decoding task, sending a request to start an image decoding task to the processing device. Among them, the request to start an image decoding task is used for the processing device to create a first thread for executing the image decoding task.

[0037] The responding to a trigger operation for an image decoding task and sending a request to start an image decoding task to the processing device includes: in response to a first trigger operation for an image decoding task, determining one or more first devices for executing the image decoding task among the one or more candidate devices; in response to a second trigger operation for an image decoding task, generating a request to start an image decoding task carrying one or more first device identifiers, and sending the request to start an image decoding task to the processing device.

[0038] The first trigger operation can be: an operation in which a user selects one or more first devices among one or more candidate devices in a graphical user interface.

[0039] The second trigger operation can be: an operation in which a user clicks a button for requesting to start an image decoding task in a graphical user interface.

[0040] On the processing device side, in response to receiving a request to start an image decoding task, a first thread for executing the image decoding task is created, and one or more first devices under the first thread are determined, including: in response to receiving a request to start an image decoding task sent by the data loader, a first thread for executing the image decoding task is created; based on the identifiers of one or more first devices included in the request to start the image decoding task, one or more first devices occupied by the first thread are determined among one or more candidate devices.

[0041] The candidate device can be a graphics processing unit (GPU, Graphics Processing Unit) capable of communicating with the processing device, or other hardware, chips, etc. capable of communicating with the processing device and used for decoding images, which are not listed one by one here.

[0042] The data loader can be software or a program running on the processing device.

[0043] On the processing device side, after creating a first thread for executing the image decoding task and determining one or more first devices under the first thread, it further includes: creating an instance corresponding to each of the one or more first devices under the first thread, where the instance corresponding to each first device is used to record the state of each first device. Taking the j-th first device among the one or more first devices as an example (j is a positive integer), the instance corresponding to the j-th first device is used to record the state of the j-th first device, where the state includes an idle state or a decoding state, and the idle state can be a state where no decoding process is executed, and the decoding state can be a state where a decoding process is executed.

[0044] Allocating memory corresponding to each of the one or more first devices under the first thread for each first device can be: in memory that is unoccupied or idle, allocating physically contiguous memory pages for the instance corresponding to each of the one or more first devices; using the physically contiguous memory pages allocated to the instance corresponding to each first device as the memory corresponding to each first device under the first thread.

[0045] Among them, the memory with the status of unoccupied or idle is the memory that is not allocated to any one of the devices, and any one of the devices is one of the one or more candidate devices. The memory with consecutive physical pages can be multiple physical pages arranged consecutively in address in the memory, and the physical page can be a unit of memory division. The size of the memory corresponding to each first device under the first thread can be set according to actual situations, and this application does not limit it. The memory corresponding to each first device under the first thread can be the same or different, and this application does not limit it.

[0046] The processing device can perform the operation of allocating memory with consecutive physical pages for the instance corresponding to each first device among the one or more first devices in the memory with the status of unoccupied or idle by calling fastMalloc (Fast Memory Allocator). The specific execution manner of fastMalloc is not limited in this application.

[0047] Taking the j-th first device among the one or more first devices as an example, regarding the memory with consecutive physical pages allocated to the instance corresponding to each first device as the memory corresponding to each first device under the first thread may include: regarding the memory with consecutive physical pages allocated to the instance corresponding to the j-th first device as the memory corresponding to the j-th first device under the first thread.

[0048] On the side of the processing device, after allocating the memory corresponding to each first device under the first thread for each first device among the one or more first devices, the method further includes: switching the memory corresponding to each first device under the first thread from the unoccupied state to the occupied state.

[0049] On the side of the processing device, after allocating the memory corresponding to each first device under the first thread for each first device among the one or more first devices, the method further includes: associating and storing the identifier of the first thread, the identifier of the instance corresponding to each first device among the one or more first devices under the first thread, the state of each first device recorded by the instance corresponding to each first device, and the address of the memory corresponding to each first device under the first thread in the management linked list.

[0050] Taking the j-th first device among the one or more first devices as an example, the association manner of the identifier of the first thread in the management linked list, the identifiers of the instances corresponding to each of the one or more first devices under the first thread, the state of each first device recorded by each instance corresponding to each first device, and the address of the memory corresponding to each first device under the first thread can be: the identifier of the first thread, the identifier of the instance corresponding to the j-th first device, the state of the j-th first device recorded by the instance corresponding to the j-th first device, and the address of the memory corresponding to the j-th first device under the first thread.

[0051] The identifier of the instance corresponding to each of the one or more first devices under the first thread includes an order, and the sorting manner of the identifiers of the instances corresponding to the one or more first devices under the first thread is not limited in this application. For example, it can be sorted according to the creation time of the instances corresponding to the one or more first devices.

[0052] Combined with Figure 2 An exemplary illustration is given for the association of the identifier of the instance corresponding to each of the one or more first devices under the first thread, the state of each first device recorded by each instance corresponding to each first device, and the address of the memory corresponding to each first device under the first thread: When there are 3 one or more first devices under the first thread, the order of the identifiers of the instances corresponding to the 3 devices under the first thread in the management linked list can be the identifier of the instance corresponding to the first device 1, the identifier of the instance corresponding to the first device 2, and the identifier of the instance corresponding to the first device 3; and the identifier of the instance corresponding to the first device 1 is associated with the state of the first device 1 recorded by the instance corresponding to the first device 1, the identifier of the instance corresponding to the first device 2 is associated with the state of the first device 2 recorded by the instance corresponding to the first device 2, and the identifier of the instance corresponding to the first device 3 is associated with the state of the first device 3 recorded by the instance corresponding to the first device 3.

[0053] On the side of the processing device, the method further includes: in response to receiving the current image to be decoded under the image decoding task sent by the data loader, determining a target device in an idle state among the one or more first devices, where the current image to be decoded is one of the multiple images to be decoded under the image decoding task; sending the current image to be decoded to the target device, receiving the decoded current image under the first thread sent by the target device; caching the decoded current image under the first thread in the memory corresponding to the target device under the first thread; and sending the decoded current image under the first thread cached in the memory corresponding to the target device under the first thread to the data loader.

[0054] Among them, the format of the current image to be decoded can be one of the following: JPEG (Joint Photographic Experts Group), PNG (Portable Network Graphics), etc., which will not be listed one by one here.

[0055] Correspondingly, the operations performed on the data loader side further include: determining whether there are one or more first images to be decoded that have not been sent to the processing device among one or more images to be decoded in the image decoding task; in the case where there are one or more first images to be decoded that have not been sent to the processing device, taking any one of the one or more first images to be decoded as the current image to be decoded in the image decoding task; sending the current image to be decoded in the image decoding task to the processing device; waiting to receive the decoded current image sent by the processing device. Among them, the current image to be decoded is one of the multiple images to be decoded in the image decoding task.

[0056] On the processing device side, the method for determining the target device in the idle state among the one or more first devices can be: checking the state of each of the one or more first devices in the management linked list, and taking any one of the first devices in the idle state as the target device.

[0057] The operation of checking the state of each of the one or more first devices in the management linked list and taking any one of the first devices in the idle state as the target device may include: determining the identifier of the current instance based on the sorting of the identifiers of the instances corresponding to the one or more first devices in the management linked list; judging whether the state of the first device recorded in the current instance associated with the identifier of the current instance is the idle state; in the case where the state of the first device recorded in the current instance is the idle state, taking the first device corresponding to the current instance as the target device; in the case where the state of the first device recorded in the current instance is the decoding state (i.e., not the idle state), judging whether there is an identifier of the next instance in the sorting of the identifiers of the instances corresponding to the one or more first devices in the management linked list; in the case where there is an identifier of the next instance, taking the identifier of the next instance as the identifier of the current instance, continuing to judge whether the state of the first device recorded in the current instance associated with the identifier of the current instance is the idle state, and performing subsequent steps.

[0058] On the side of the processing device, it further includes: in the case where there is no identifier of the next instance, determining that there is no first device in the record of the instance corresponding to each first device among the one or more first devices in the management linked list whose state is the idle state; in the case where there is no first device in the record of the instance corresponding to each first device among the one or more first devices in the management linked list whose state is the idle state, continuing to check the state of each first device among the one or more first devices in the management linked list until a first device in the idle state is found.

[0059] On the side of the processing device, the sending of the current image to be decoded to the target device includes: in the case where it is determined that the memory corresponding to the target device under the first thread meets the condition, sending the current image to be decoded to the target device, where the condition is that the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the current image to be decoded under the first thread.

[0060] In the case where it is determined that the memory corresponding to the target device under the first thread meets the condition, sending the current image to be decoded to the target device may include: judging whether the memory corresponding to the target device under the first thread meets the condition; in the case where the memory corresponding to the target device under the first thread meets the condition, sending the current image to be decoded to the target device.

[0061] The method for judging whether the memory corresponding to the target device under the first thread meets the condition includes: based on the parameters of the current image to be decoded under the first thread, determining the size of the decoding storage space required for the current image to be decoded under the first thread; in the case where the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the current image to be decoded under the first thread, determining that the memory corresponding to the target device under the first thread meets the condition; in the case where the memory corresponding to the target device under the first thread is less than the size of the decoding storage space required for the current image to be decoded under the first thread, determining that the memory corresponding to the target device under the first thread does not meet the condition.

[0062] Wherein, the parameters of the current image to be decoded include at least one of the following: the height of the current image to be decoded, the width of the current image to be decoded, the number of bytes occupied by each pixel of the current image to be decoded, and the number of bytes occupied by each pixel of the current image to be decoded may be the number of bytes occupied by any one pixel in the current image to be decoded.

[0063] Determining the size of the decoding storage space required for the current image to be decoded under the first thread may include: multiplying the height of the current image to be decoded under the first thread by the width of the current image to be decoded under the first thread to obtain a first value; multiplying the first value by the number of bytes occupied by each pixel of the current image to be decoded to obtain the size of the decoding storage space required for the current image to be decoded under the first thread.

[0064] On the side of the processing device, sending the current image to be decoded to the target device includes: when it is determined that the memory corresponding to the target device under the first thread does not meet the condition, releasing the memory corresponding to the target device under the first thread, where the condition is that the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the current image to be decoded under the first thread; reallocating, based on the size of the decoding storage space required for the current image to be decoded under the first thread, the memory corresponding to the target device under the first thread for the target device; and sending the current image to be decoded to the target device.

[0065] The manner of determining whether the memory corresponding to the target device under the first thread meets the condition is the same as that in the above embodiment and will not be elaborated here.

[0066] The manner of determining the size of the decoding storage space required for the current image to be decoded under the first thread is the same as that in the above embodiment and will not be elaborated here.

[0067] Releasing the memory corresponding to the target device under the first thread may be: switching the memory corresponding to the target device under the first thread from the occupied state to the unoccupied state.

[0068] Reallocating, based on the size of the decoding storage space required for the current image to be decoded under the first thread, the memory corresponding to the target device under the first thread for the target device includes: reallocating, based on the size of the decoding storage space required for the current image to be decoded, physically contiguous memory for the target device from among the memory in the unoccupied or idle state; and using the physically contiguous memory reallocated for the target device as the memory corresponding to the target device under the first thread reallocated for the target device. The size of the memory corresponding to the target device under the first thread reallocated for the target device may be greater than or equal to the size of the decoding storage space required for the current image to be decoded.

[0069] On the side of the processing device, after reallocating the memory corresponding to the target device under the first thread for the target device, it further includes: converting the memory corresponding to the target device reallocated for the target device under the first thread from an unoccupied state to an occupied state.

[0070] On the side of the processing device, after reallocating the memory corresponding to the target device under the first thread for the target device, it further includes: replacing the address of the memory corresponding to the target device under the first thread associated with the identifier of the instance of the target device in the management linked list with the address of the memory corresponding to the target device reallocated for the target device under the first thread.

[0071] In this way, when it is determined that the memory corresponding to the target device under the first thread meets the conditions, the current image to be decoded is directly sent to the target device; when it is determined that the memory corresponding to the target device under the first thread meets the conditions, after reallocating the memory corresponding to the target device under the first thread for the target device based on the size of the decoding storage space required by the current image to be decoded under the first thread, the current image to be decoded is sent to the target device. In this way, it can be ensured that after sending the current image to be decoded to the target device, the memory corresponding to the target device in the processing device under the first thread can have enough space to store the decoded current image sent by the target device, improving the reliability of storage.

[0072] On the side of the processing device, before determining whether the memory corresponding to the target device under the first thread meets the conditions, the method further includes: determining whether to allocate the memory corresponding to the target device under the first thread for the target device.

[0073] The method for determining whether to allocate the memory corresponding to the target device under the first thread for the target device may include: determining whether there is an address of the memory corresponding to the target device under the first thread associated with the identifier of the instance of the target device in the management linked list; when there is an address of the memory corresponding to the target device under the first thread associated with the identifier of the instance of the target device in the management linked list, determining that the memory corresponding to the target device under the first thread has been allocated for the target device; when there is no address of the memory corresponding to the target device under the first thread associated with the identifier of the instance of the target device in the management linked list, determining that the memory corresponding to the target device under the first thread has not been allocated for the target device.

[0074] In the case where the memory corresponding to the target device under the first thread has been allocated to the target device, determine whether the memory corresponding to the target device under the first thread meets the conditions, and perform subsequent processing.

[0075] In the case where the memory corresponding to the target device under the first thread has not been allocated to the target device, based on the size of the decoding storage space required for the current image to be decoded under the first thread, allocate the memory corresponding to the target device under the first thread to the target device. The specific method is the same as the method of reallocating the memory corresponding to the target device under the first thread to the target device based on the size of the decoding storage space required for the current image to be decoded under the first thread, and will not be elaborated here.

[0076] On the side of the processing device, after allocating the memory corresponding to the target device under the first thread to the target device based on the size of the decoding storage space required for the current image to be decoded under the first thread, it further includes: associating and storing the address of the memory corresponding to the target device allocated to the target device under the first thread with the identifier of the instance corresponding to the target device in the management linked list in the management linked list.

[0077] In this way, before the current image to be decoded under the first thread is sent to the target device, a judgment mechanism for whether the target device has been allocated memory can be added, so as to avoid the failure of caching the decoded current image under the first thread sent by the target device in the case of missing allocation of the memory corresponding to the target device under the first thread, and improve the reliability of caching the decoded current image.

[0078] Combined Figure 3 An exemplary description is given of the processing device side sending the current image to be decoded to the target device in the above embodiment.

[0079] S301, determine whether the memory corresponding to the target device under the first thread has been allocated to the target device.

[0080] In the case where the memory corresponding to the target device under the first thread has been allocated to the target device, execute S302.

[0081] In the case where the memory corresponding to the target device under the first thread has not been allocated to the target device, allocate the memory corresponding to the target device under the first thread based on the size of the decoding storage space required for the current image to be decoded under the first thread, and execute S304.

[0082] S302, determine whether the memory corresponding to the target device under the first thread meets the conditions.

[0083] Execute S304 when the memory corresponding to the target device under the first thread meets the conditions.

[0084] Execute S303 when the memory corresponding to the target device under the first thread does not meet the conditions.

[0085] S303, release the memory corresponding to the target device under the first thread; re - allocate the memory corresponding to the target device under the first thread for the target device based on the size of the decoding storage space required for the current image to be decoded under the first thread.

[0086] S304, send the current image to be decoded to the target device.

[0087] The operations performed on the target device side include: receiving the current image to be decoded sent by the processing device; decoding the current image to be decoded to obtain the decoded current image under the first thread; caching the decoded current image under the first thread in the video memory of the target device, and sending the decoded current image under the first thread in the video memory to the processing device.

[0088] Among them, the specific method of decoding the current image to be decoded under the first thread to obtain the decoded current image under the first thread can be set according to the actual situation, and this application does not limit it.

[0089] Correspondingly, the operations performed on the processing device side include: receiving the decoded current image under the first thread sent by the target device.

[0090] On the processing device side, caching the decoded current image under the first thread in the memory corresponding to the target device under the first thread can be: determining the memory corresponding to the target device under the first thread based on the address of the memory corresponding to the target device under the first thread associated with the identifier of the instance corresponding to the target device in the management linked list, and caching the decoded current image under the first thread in the memory corresponding to the target device under the first thread.

[0091] On the processing device side, after caching the decoded current image under the first thread in the memory corresponding to the target device under the first thread, it includes: sending the decoded current image under the first thread cached in the memory corresponding to the target device under the first thread to the data loader.

[0092] On the side of the processing device, after sending the decoded current image under the first thread cached in the memory corresponding to the target device under the first thread to the data loader, the method further includes: deleting the decoded current image under the first thread cached in the memory corresponding to the target device under the first thread. In this way, the cache in the memory corresponding to the target device under the first thread can be cleared, so that when the decoded image under the first thread sent by the target device is received next time, it can continue to be cached in the memory allocated by the target device.

[0093] Correspondingly, the operations performed on the data loader side include: when receiving the decoded current image under the first thread sent by the processing device, taking the decoded current image under the first thread as the decoded current image in the image decoding task; determining whether there are one or more first images to be decoded that have not been sent to the processing device among one or more images to be decoded in the image decoding task; when there are one or more first images to be decoded that have not been sent to the processing device, taking any one of the one or more first images to be decoded as the next image to be decoded in the image decoding task; sending the next image to be decoded in the image decoding task to the processing device; waiting to receive the next decoded image sent by the processing device.

[0094] In this way, in response to receiving the current image to be decoded under the first thread sent by the data loader, the processing device sends the current image to be decoded under the first thread to the target device in an idle state among one or more first devices, and receives the decoded current image under the first thread sent by the target device; caches the decoded current image in the memory corresponding to the target device under the first thread, and sends the decoded current image to the data loader. In this way, an idle target device that can decode the current image to be decoded can be quickly determined among one or more first devices, reducing the waiting time for image decoding and improving the working efficiency of the image decoding task; moreover, during the decoding process of the current image to be decoded, it is not necessary to allocate and release memory for the current image to be decoded, avoiding allocating and releasing memory for the image during the execution of the image decoding task and improving the overall efficiency of image decoding; in addition, during the execution of the image decoding task, it is not necessary to frequently allocate and release memory for the images to be decoded under the first thread, which can reduce the generation of memory fragments.

[0095] In addition, on the data loader side, when there are no one or more first images to be decoded that have not been sent to the processing device, an indication that the image decoding task is completed is sent to the processing device.

[0096] Correspondingly, the operations performed by the processing device further include: when receiving the indication that the image decoding task sent by the data loader is completed, determining that the first thread has completed the image decoding task.

[0097] On the side of the processing device, after determining that the first thread has completed the image decoding task, it includes: releasing the memory corresponding to each first device under the first thread.

[0098] The releasing of the memory corresponding to each first device under the first thread may be: switching the memory corresponding to each first device under the first thread from the occupied state to the idle state, and deleting the address of the memory corresponding to each first device under the first thread in the management linked list.

[0099] On the side of the processing device, after releasing the memory corresponding to each first device under the first thread, it further includes: destroying the first thread.

[0100] The destroying of the first thread includes: deleting the identifier of the first thread, the identifiers of the instances corresponding to each of the one or more first devices in the management linked list; deleting the instances corresponding to the one or more first devices; deleting the first thread.

[0101] In this way, when receiving the indication that the image decoding task sent by the data loader is completed, it is determined that the first thread has completed the image decoding task. In this way, it is possible to more accurately determine that the first thread has completed the image decoding task. Additionally, after releasing the memory corresponding to each first device under the first thread, the first thread is destroyed. In this way, the first thread that executes the image decoding task and the memory corresponding to each first device under the first thread are released synchronously, which can make the memory corresponding to each first device under the first thread synchronized with the life cycle of each first device under the first thread, reduce the frequency of memory allocation and release during the image decoding process, improve the efficiency of memory allocation and release, and reduce the generation of memory fragmentation.

[0102] Combined Figure 4 An exemplary description of the above memory management method is as follows:

[0103] S401, on the side of the data loader, in response to the trigger operation of the image decoding task, send a request to start the image decoding task to the processing device, where the request to start the image decoding task includes the identifiers of one or more first devices.

[0104] S402, on the processing device side, in response to receiving the request from the data loader to start the image decoding task, create a first thread for executing the image decoding task; based on the identifiers of one or more first devices included in the request to start the image decoding task, determine one or more first devices occupied by the first thread among one or more candidate devices.

[0105] S403, on the processing device side, create an instance corresponding to each of the one or more first devices under the first thread, where the instance corresponding to each first device is used to record the state of each first device.

[0106] S404, on the processing device side, allocate physically contiguous memory for the instance corresponding to each first device in memory with an unoccupied or idle state; use the physically contiguous memory allocated to the instance corresponding to each first device as the memory corresponding to each first device under the first thread.

[0107] After completing S404, the operations performed by the data loader may include: determining whether there are one or more first images to be decoded that have not been sent to the processing device among the one or more images to be decoded under the image decoding task;

[0108] In the case where there are one or more first images to be decoded that have not been sent to the processing device, use any one of the one or more first images to be decoded as the current image to be decoded under the image decoding task, and execute S405;

[0109] In the case where there are no one or more first images to be decoded that have not been sent to the processing device, execute S410.

[0110] S405, on the data loader side, send the current image to be decoded under the image decoding task to the processing device.

[0111] S406, on the processing device side, in response to receiving the current image to be decoded under the image decoding task sent by the data loader, determine the target device in an idle state among the one or more first devices; send the current image to be decoded to the target device.

[0112] S407, on the target device side, receive the current image to be decoded under the first thread sent by the processing device; decode the current image to be decoded under the first thread to obtain the decoded current image under the first thread.

[0113] S408, on the target device side, send the decoded current image under the first thread to the processing device.

[0114] S409. On the processing device side, receive the decoded current image under the first thread sent by the target device; cache the decoded current image under the first thread in the memory corresponding to the target device under the first thread; send the decoded current image under the first thread cached in the memory corresponding to the target device under the first thread to the data loader. Correspondingly, on the data loader side, in the case of receiving the decoded current image sent by the processing device, return to execute the process of determining whether there are one or more first images to be decoded that have not been sent to the processing device among one or more images to be decoded under the image decoding task.

[0115] S410. On the data loader side, send an image decoding task completion indication to the processing device.

[0116] S411. On the processing device side, in the case of receiving the image decoding task completion indication sent by the data loader, determine that the first thread has completed the image decoding task; release the memory corresponding to each first device under the first thread; destroy the instance corresponding to each first device among one or more first devices under the first thread.

[0117] S412. Destroy the first thread.

[0118] Figure 5 The schematic block diagram of a processing device provided by an embodiment of the present disclosure is shown. As Figure 3 shown, it includes:

[0119] An image decoding task management module 501, configured to, in response to receiving a request to start an image decoding task, create a first thread for executing the image decoding task, and determine one or more first devices under the first thread;

[0120] A memory management module 502, configured to allocate memory corresponding to each first device under the first thread for each of the one or more first devices, where the memory corresponding to each first device under the first thread is used to cache the decoded images of each first device under the first thread; in the case of determining that the first thread has completed the image decoding task, release the memory corresponding to each first device under the first thread.

[0121] As Figure 6 shown, the processing device further includes:

[0122] The communication module 601 is configured to, in response to receiving the current image to be decoded under the image decoding task sent by the data loader, determine target devices in an idle state among the one or more first devices; send the current image to be decoded to the target devices, receive the decoded current image under the first thread sent by the target devices; cache the decoded current image under the first thread in the memory corresponding to the target devices under the first thread; and send the decoded current image under the first thread cached in the memory corresponding to the target devices under the first thread to the data loader.

[0123] The communication module is configured to, when determining that the memory corresponding to the target device under the first thread meets the condition, send the current image to be decoded to the target device, where the condition is that the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the current image to be decoded under the first thread.

[0124] The memory management module is configured to, when determining that the memory corresponding to the target device under the first thread does not meet the condition, release the memory corresponding to the target device under the first thread, where the condition is that the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the current image to be decoded under the first thread; and re-allocate the memory corresponding to the target device under the first thread for the target device based on the size of the decoding storage space required for the current image to be decoded under the first thread.

[0125] The communication module is configured to send the current image to be decoded to the target device.

[0126] The communication module is configured to receive a request for starting an image decoding task sent by the data loader.

[0127] The image decoding task management module is configured to, when receiving an indication that the image decoding task is completed sent by the data loader, determine that the first thread has completed the image decoding task.

[0128] The image decoding task management module is configured to destroy the first thread.

[0129] For the specific functions and examples of each module and sub-module of the device according to the embodiments of the present disclosure, reference may be made to the relevant descriptions of the corresponding steps in the above method embodiments, which will not be elaborated here.

[0130] In the technical solution of the present disclosure, the acquisition, storage, and application of the user's personal information involved all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.

[0131] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0132] Figure 7 FIG. shows a schematic block diagram of an exemplary electronic device 700 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, for example, a personal digital assistant, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0133] As Figure 7 shown, the electronic device 700 includes a computing unit 701 that can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0134] A plurality of components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0135] The computing unit 701 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 executes the various methods and processes described above. For example, in some embodiments, the above method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, at least one step of the method described above can be executed. Alternatively, in other embodiments, the computing unit 701 can be configured to execute the above method in any other suitable manner (e.g., by means of firmware).

[0136] Various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor, that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0137] The program code for implementing the methods of the present disclosure can be written in any combination of at least one programming language. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program codes can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0138] In the context of this disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on at least one wire, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0139] To provide for interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic, speech, or tactile input).

[0140] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0141] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is generated by computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server incorporating a blockchain.

[0142] It should be understood that the various forms of processes shown above can be used, with steps reordered, added or deleted. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitation is imposed herein.

[0143] The above specific embodiments do not constitute a limitation on the protection scope of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub - combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure shall be included within the protection scope of this disclosure.

Claims

1. A memory management method, applied to a processing device, comprising: responding to a request for starting an image decoding task, creating a first thread for executing the image decoding task, and determining one or more first devices under the first thread; allocating, for each first device among the one or more first devices, memory corresponding to the first device under the first thread, wherein the memory corresponding to each first device under the first thread is used for caching the decoded image of each first device under the first thread; releasing, when it is determined that the first thread has completed the image decoding task, the memory corresponding to each first device under the first thread.

2. The method according to claim 1, further comprising: responding to a currently to-be-decoded image under the image decoding task sent by a data loader, determining a target device in an idle state among the one or more first devices, wherein the currently to-be-decoded image is one of a plurality of to-be-decoded images under the image decoding task; sending the currently to-be-decoded image to the target device, and receiving the currently decoded image under the first thread sent by the target device; caching the currently decoded image under the first thread in the memory corresponding to the target device under the first thread; sending the currently decoded image under the first thread cached in the memory corresponding to the target device under the first thread to the data loader.

3. The method according to claim 2, wherein, The sending the currently to-be-decoded image to the target device includes: when it is determined that the memory corresponding to the target device under the first thread meets a condition, sending the currently to-be-decoded image to the target device, wherein the condition is that the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the currently to-be-decoded image under the first thread.

4. The method according to claim 2, wherein, The sending the currently to-be-decoded image to the target device includes: when it is determined that the memory corresponding to the target device under the first thread does not meet the condition, releasing the memory corresponding to the target device under the first thread, wherein the condition is that the memory corresponding to the target device under the first thread is greater than or equal to the size of the decoding storage space required for the currently to-be-decoded image under the first thread; reallocating, based on the size of the decoding storage space required for the currently to-be-decoded image under the first thread, the memory corresponding to the target device under the first thread for the target device; sending the currently to-be-decoded image to the target device.

5. The method according to any one of claims 1 to 4, wherein The receiving the request for starting an image decoding task includes: receiving the request for starting an image decoding task sent by the data loader; The method further comprises: when receiving an indication that the image decoding task sent by the data loader is completed, determining that the first thread has completed the image decoding task.

6. The method according to any one of claims 1 to 4, after releasing the memory corresponding to each of the first devices under the first thread, further comprising: Destroying the first thread.

7. A processing device, comprising: An image decoding task management module, configured to create a first thread for executing the image decoding task in response to receiving a request to start an image decoding task, and determine one or more first devices under the first thread; A memory management module, configured to allocate memory corresponding to each of the one or more first devices under the first thread for each of the first devices, wherein the memory corresponding to each of the first devices under the first thread is used to cache the decoded images of each of the first devices under the first thread; When it is determined that the first thread has completed the image decoding task, release the memory corresponding to each of the first devices under the first thread.

8. An electronic device, comprising: At least one processor; And A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the method according to any one of claims 1-6.

9. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.

10. A computer program product, comprising a computer program, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1-6.