Memory management optimization method, device, electronic device and storage medium

By obtaining the rendering node and image URL address in the game engine, and automatically loading and releasing memory resources, the problem of troublesome use and poor performance of memory management in the existing technology is solved, and the automation of memory management and performance improvement are realized.

CN118193227BActive Publication Date: 2024-08-23HANGZHOU MOXI TECH DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410613075.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2024-08-23
Estimated Expiration
2044-05-17

AI Technical Summary

Technical Problem

Existing memory management techniques are cumbersome to use in game engines, prone to errors, and have poor performance, leading to memory leaks and increased CPU consumption.

Method used

By obtaining the rendering node and image URL address, calling the image resource loading interface to load the image into memory, mounting it on the rendering node, and automatically releasing the memory resource at the end of the life cycle, using scheduled polling to check the resource usage status, reducing memory Number of operations.

Benefits of technology

It implements automated memory management, avoids the problems of memory leaks and increased CPU consumption, and improves performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118193227B
    Figure CN118193227B
Patent Text Reader

Abstract

The present invention provides a memory management optimization method, device, electronic device and storage medium. Applied to a game engine, the method comprises: obtaining the URL address of the rendering node and the picture transmitted from the outside; calling the picture resource loading interface of the game engine based on the URL address of the picture to load the picture into the memory and obtain the picture resource memory object; increasing the number of references of the picture resource memory object by one; mounting the picture resource memory object on the rendering node; associating the picture resource memory object with the rendering node and storing the associated data in an array; if the life cycle of the rendering node in the associated data ends, reducing the number of references of the picture resource memory object by one and deleting the associated data; if the number of references of the picture resource memory object is reduced to 0, triggering the resource memory recycling mechanism. The memory management of resources such as pictures is taken over and processed uniformly, so that programmers do not need to care about the memory management issues of resources such as pictures and do not need to write memory management code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of game engine technology, and in particular to a memory management optimization method, device, electronic device and storage medium. Background Art

[0002] When using a game engine to develop a game, it is necessary to manage the memory of various game resources (such as pictures, music, configuration data, etc.). For games that are mainly run on mobile phones, the memory of the mobile phone is mostly limited, but the resources in the game are very large. If all the resources in the game are loaded, the memory of the mobile phone is not practical enough. Therefore, only the game resources currently in use should be retained in the memory, and the resources that are not currently in use should be deleted. This requires programmers to pay attention to memory management when writing code.

[0003] However, existing memory management technologies have the following defects:

[0004] 1. It is troublesome to use and prone to errors. The programmer must manually add the code to increase the resource reference count when the resource is loaded, and manually add the code to decrease the resource reference count when the resource is released. It is easy to forget to write the code to decrease the resource reference count, which leads to memory leaks.

[0005] 2. Poor performance. Some resources are used in many scenarios. Often, they are released one second ago and need to be loaded elsewhere the next second, which leads to too frequent memory operations and increases the consumption of CPU (Central Processing Unit) time. Summary of the invention

[0006] In view of this, the purpose of the present invention is to provide a memory management optimization method, device, electronic device and storage medium, which can take over and uniformly process the memory management of resources such as pictures, so that programmers no longer need to worry about memory management issues of resources such as pictures, do not need to write memory management code, and there will be no errors caused by forgetting to add memory management code, resulting in memory not being released in time; it can also avoid the situation where some resources are released and loaded again in a short period of time, reduce the number of memory operations, reduce CPU time consumption, and achieve the effect of improving performance.

[0007] In a first aspect, an embodiment of the present invention provides a memory management optimization method, which is applied to a game engine, and the method includes: obtaining URL addresses of a rendering node and a picture input from the outside; calling a picture resource loading interface of the game engine based on the URL address of the picture to load the picture into the memory, and obtaining a picture resource memory object; increasing the number of references of the picture resource memory object by one; mounting the picture resource memory object on the rendering node; associating the picture resource memory object with the rendering node, and saving the associated data in an array; if the life cycle of the rendering node in the associated data ends, reducing the number of references of the picture resource memory object by one, and deleting the associated data; if the number of references of the picture resource memory object is reduced to 0, triggering a resource memory recycling mechanism.

[0008] In an optional embodiment of the present application, the step of obtaining the URL addresses of the rendering nodes and images input from the outside includes: receiving the URL addresses of the rendering nodes and images input from the outside in the form of parameters through a function body.

[0009] In an optional embodiment of the present application, if the above-mentioned call of the picture resource loading interface is successful, a picture resource memory object is obtained.

[0010] In an optional embodiment of the present application, after the above step of mounting the image resource memory object on the rendering node, the method further includes: the rendering node displays the image information corresponding to the image resource memory object on the computer screen.

[0011] In an optional embodiment of the present application, the array stores multiple associated data of multiple image resource memory objects and multiple rendering nodes; after the step of saving the associated data in the array, the method further includes: traversing the array based on timed polling to check whether the life cycle of the rendering node in the multiple associated data in the array has ended.

[0012] In an optional embodiment of the present application, after the above step of checking whether the life cycle of the rendering node in the multiple associated data in the array has ended, the method further includes: for the currently traversed associated data, if the life cycle of the rendering node in the associated data has ended, reducing the number of references to the image resource memory object corresponding to the associated data by one, deleting the associated data, and continuing to traverse the next associated data in the array.

[0013] In an optional embodiment of the present application, after the step of checking whether the lifecycle of the rendering node in the plurality of associated data in the array has ended, the method further comprises: for the currently traversed associated data, if the lifecycle of the rendering node in the associated data has not ended, continuing to traverse the next associated data in the array.

[0014] In a second aspect, an embodiment of the present invention further provides a memory management optimization device, which is applied to a game engine, and the device includes: an external input module, which is used to obtain the URL address of the rendering node and the picture input externally; a picture loading module, which is used to call the picture resource loading interface of the game engine based on the URL address of the picture to load the picture into the memory, and obtain the picture resource memory object; increase the number of references of the picture resource memory object by one; a picture mounting module, which is used to mount the picture resource memory object on the rendering node; associate the picture resource memory object with the rendering node, and save the associated data in an array; an associated data deletion module, which is used to reduce the number of references of the picture resource memory object by one and delete the associated data if the life cycle of the rendering node in the associated data ends; and a resource memory recycling module, which is used to trigger the resource memory recycling mechanism if the number of references of the picture resource memory object is reduced to 0.

[0015] In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned memory management optimization method.

[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned memory management optimization method.

[0017] The embodiments of the present invention bring the following beneficial effects:

[0018] The embodiments of the present invention provide a memory management optimization method, device, electronic device and storage medium, which can take over and uniformly process the memory management of resources such as pictures, so that programmers no longer need to worry about memory management issues of resources such as pictures, do not need to write memory management code, and there will be no errors such as forgetting to add memory management code, resulting in memory not being released in time.

[0019] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.

[0020] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A schematic diagram of an existing memory management technology provided by an embodiment of the present invention;

[0023] Figure 2 A schematic diagram of a memory management optimization method provided by an embodiment of the present invention;

[0024] Figure 3 A flowchart of a memory management optimization method provided by an embodiment of the present invention;

[0025] Figure 4 A schematic diagram of another memory management optimization method provided by an embodiment of the present invention;

[0026] Figure 5 A flowchart of another memory management optimization method provided by an embodiment of the present invention;

[0027] Figure 6 A schematic diagram of the structure of a memory management optimization device provided by an embodiment of the present invention;

[0028] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] Currently, taking the example of rendering an image and releasing an image memory in the game, you can refer to Figure 1The schematic diagram of an existing memory management technology shown in the figure shows that when loading image resources, after successful loading, the number of image references increases by one, a node for rendering images is created and the loaded image is mounted on this node, and the image rendering is completed; when releasing image resources, the rendering node is deleted, the image is removed from the rendering node, and the number of image references decreases by one to trigger memory recycling. Among them, the programmer needs to manually add the code related to the number of image references plus one and the number of image references minus one to maintain the memory management of resources.

[0031] like Figure 1 As shown, the existing memory management technology has the following defects:

[0032] 1. It is troublesome to use and easy to make mistakes. Figure 1 As shown, the programmer must manually add the code to increase the resource reference count when the resource is loaded, and must manually add the code to decrease the resource reference count when the resource is released. It is often easy to forget to write the code to decrease the resource reference count, which leads to memory leaks.

[0033] 2. Poor performance. Figure 1 As shown, some resources will be used in many scenarios. Figure 1 The memory management technology shown is often released just one second and needs to be loaded somewhere else the next second, resulting in too frequent memory operations and increased CPU time consumption.

[0034] Based on this, the embodiments of the present invention provide a memory management optimization method, device, electronic device and storage medium, and specifically provide a memory management optimization method applied to the Cocos Creator engine, which can take over and uniformly process the memory management of resources such as pictures, so that programmers no longer need to worry about memory management issues of resources such as pictures, do not need to write memory management code, and will not have errors caused by forgetting to add memory management code, resulting in memory not being released in time; it can also avoid the situation where some resources are released and loaded again in a short period of time, reduce the number of memory operations, and reduce CPU time consumption, thereby achieving the effect of improving performance.

[0035] To facilitate understanding of this embodiment, a memory management optimization method disclosed in an embodiment of the present invention is first introduced in detail.

[0036] Embodiment 1:

[0037] The embodiment of the present invention provides a memory management optimization method, which is applied to a game engine. In this embodiment, the Cocos Creator engine is used as an example for explanation, and no further description is given hereafter. The Cocos Creator engine is a lightweight, efficient, free and open source cross-platform game engine, and is also a real-time 3D content creation platform. It not only supports 2D and 3D game development, but also provides a complete set of industry solutions in the fields of HMI (Human Machine Interface), IoT (Internet of Things), XR (Extended Reality), virtual puppets, etc.

[0038] Take rendering an image and releasing an image memory in the game as an example, you can refer to Figure 2 A schematic diagram of a memory management optimization method is shown. In this embodiment, when loading image resources, a rendering node is created, a functional API (interface) is called, and the rendering node and the image URL address are passed in as parameters, and the image rendering is completed; in this embodiment, when releasing image resources, the rendering node is directly deleted, and the deletion is completed, so that the programmer does not need to write relevant code for managing memory.

[0039] Based on the above description, see Figure 3 A flowchart of a memory management optimization method is shown, and the memory management optimization method includes the following steps:

[0040] Step S302: Obtain the URL address of the rendering node and the image input from the outside.

[0041] See also Figure 4 The schematic diagram of another memory management optimization method shown is firstly to obtain the URL address of the externally input rendering node and picture.

[0042] In some embodiments, the URL address of the rendering node and the image passed in from the outside in the form of parameters can be received through the function body. In this embodiment, the necessary parameters passed in from the outside can be received as a function body: the URL address of the rendering node and the image.

[0043] Step S304, based on the URL address of the picture, the picture resource loading interface of the game engine is called to load the picture into the memory to obtain a picture resource memory object; and the number of references to the picture resource memory object is increased by one.

[0044] like Figure 4As shown, the image can be loaded first, and after the loading of the image is completed, the number of image references increases by one. The number of image references is the number of references to the image resource memory object. When loading the image, this embodiment can call the image resource loading API in the Cocos Creator engine according to the URL address of the image to load the image into the memory.

[0045] In some embodiments, if the image resource loading interface is successfully called, the image resource memory object is obtained. In this embodiment, if the image resource loading API in the Cocos Creator engine is successfully called, the image resource memory object can be obtained.

[0046] It should also be noted that the resource memory management in the Cocos Creator engine of this embodiment is reference counting, and the user must do "reference count +1 when in use, reference count -1 when no longer in use". Therefore, after obtaining the image resource memory object, it is necessary to perform an operation of adding +1 to the reference count of the image resource memory object.

[0047] Step S306, mounting the image resource memory object on the rendering node; associating the image resource memory object with the rendering node, and storing the associated data in an array.

[0048] like Figure 4 As shown, this embodiment can mount the loaded image to the rendering node.

[0049] In addition, in some embodiments, the rendering node may also display the image information corresponding to the image resource memory object on the computer screen. If you want to display the image, this embodiment may also mount the image resource memory object on the rendering node, and the rendering node may display the image information on the computer screen.

[0050] like Figure 4 As shown, in this embodiment, the picture resource memory object and the rendering node can be bound and put into an array. Therefore, in this embodiment, the memory management of resources such as pictures can be taken over and processed uniformly, that is, the picture resource memory object and the rendering node are first associated, and then the associated data is stored in the array.

[0051] Step S308: if the life cycle of the rendering node in the associated data ends, the number of references to the image resource memory object is reduced by one, and the associated data is deleted.

[0052] If the life cycle of the rendering node in the associated data ends, the corresponding image reference count can be reduced by one, and the associated data can be deleted.

[0053] Step S310: If the number of references to the picture resource memory object is reduced to 0, the resource memory recycling mechanism is triggered.

[0054] If the number of references to the image resource memory object is reduced to 0, the resource memory recycling mechanism of the Cocos Creator engine can be triggered.

[0055] The embodiment of the present invention provides a memory management optimization method, which can take over and uniformly process the memory management of resources such as pictures, so that programmers no longer need to worry about memory management issues of resources such as pictures, do not need to write memory management code, and will not have errors such as forgetting to add memory management code that lead to memory not being released in time.

[0056] Embodiment 2:

[0057] This embodiment provides another memory management optimization method, which is implemented on the basis of the above embodiment. Figure 5 A flowchart of another memory management optimization method is shown, and the memory management optimization method includes the following steps:

[0058] Step S502: Obtain the URL address of the rendering node and the image input from the outside.

[0059] Step S504, based on the URL address of the picture, the picture resource loading interface of the game engine is called to load the picture into the memory to obtain a picture resource memory object; and the number of references to the picture resource memory object is increased by one.

[0060] Step S506, mounting the image resource memory object on the rendering node; associating the image resource memory object with the rendering node, and storing the associated data in an array.

[0061] Step S508 , traversing the array based on the timing polling, and checking whether the life cycle of the rendering node in the plurality of associated data in the array has ended.

[0062] In this embodiment, multiple image resource memory objects may be mounted on multiple rendering nodes respectively, and the multiple image resource memory objects and the multiple rendering nodes may be associated with each other to obtain multiple associated data, and the multiple associated data may be stored in the same array.

[0063] The array may store multiple associated data of multiple image resource memory objects and multiple rendering nodes. For example, the array structure is: Array = [{node: rendering node, asset: image resource memory object}, {node: rendering node 2, asset: image resource memory object 2}...].

[0064] In this embodiment, a timed polling mechanism may be set. Timed polling is a data acquisition mechanism in which the client periodically sends a request to the server to check whether there is new data. This mechanism usually involves using a timer to set a fixed time interval, and the client sends a request to the server every time interval. If the server has new data during this period, it will return the data; if there is no update, it may return an empty response or the same response as before.

[0065] Among them, in this embodiment, a timer callback can be set to enable a function to be called at a certain interval, and the specific time can be set.

[0066] Specifically, this embodiment may traverse the Array array mentioned above to check whether the life cycle of the rendering node in each piece of associated data has ended.

[0067] like Figure 4 As shown, the associated data can be traversed to detect whether the rendering node has been deleted. If the rendering node has been deleted, the life cycle of the rendering node has ended; if the rendering node has not been deleted, the life cycle of the rendering node has not ended.

[0068] Step S510 , for the currently traversed associated data, if the life cycle of the rendering node in the associated data ends, the number of references to the image resource memory object corresponding to the associated data is reduced by one, the associated data is deleted, and the next associated data in the array is traversed.

[0069] like Figure 4 As shown, for the currently traversed associated data, if the life cycle of the rendering node in the associated data ends, it is necessary to execute "reduce the number of image references by one and delete the associated data", and then continue to mutate the next associated data of the array.

[0070] Step S512: for the currently traversed associated data, if the life cycle of the rendering node in the associated data has not ended, continue to traverse the next associated data in the array.

[0071] like Figure 4 As shown, for the currently traversed associated data, if the life cycle of the rendering node in the associated data has not ended, there is no need to execute "reducing the number of image references by one and deleting the associated data", and the next associated data in the array can be traversed continuously.

[0072] It should also be noted that the resource memory management in the Cocos Creator engine of this embodiment is reference counting, and the user must do "reference count +1 when in use, reference count -1 when no longer in use". Therefore, after determining that the life cycle of the rendering node in the associated data has ended, it is necessary to perform a reference count -1 operation on the image resource memory object.

[0073] Step S514: If the number of references to the picture resource memory object is reduced to 0, the resource memory recycling mechanism is triggered.

[0074] The embodiment of the present invention provides a memory management optimization method. When resources are released, because the usage status of related resources is polled periodically, there is a certain delay in the middle, which can avoid the situation where some resources are released and loaded again in a short time, reduce the number of memory operations, reduce the consumption of CPU time, and achieve the effect of improving performance.

[0075] Embodiment three:

[0076] Corresponding to the above method embodiment, the embodiment of the present invention provides a memory management optimization device, which is applied to a game engine, see Figure 6 A schematic diagram of the structure of a memory management optimization device is shown, the memory management optimization device comprising:

[0077] The external input module 61 is used to obtain the URL address of the rendering node and the picture input from the outside;

[0078] The picture loading module 62 is used to call the picture resource loading interface of the game engine based on the URL address of the picture to load the picture into the memory, obtain the picture resource memory object; and increase the number of references of the picture resource memory object by one;

[0079] The image mounting module 63 is used to mount the image resource memory object on the rendering node; associate the image resource memory object with the rendering node, and store the associated data in an array;

[0080] The associated data deletion module 64 is used to reduce the number of references of the image resource memory object by one and delete the associated data if the life cycle of the rendering node in the associated data ends;

[0081] The resource memory recycling module 65 is used to trigger the resource memory recycling mechanism if the number of references of the picture resource memory object is reduced to 0.

[0082] The embodiment of the present invention provides a memory management optimization device, which can take over and uniformly process the memory management of resources such as pictures, so that programmers no longer need to worry about memory management issues of resources such as pictures, do not need to write memory management code, and there will be no errors such as forgetting to add memory management code, resulting in memory not being released in time.

[0083] The external input module is used to receive the URL addresses of the rendering nodes and images input from the outside in the form of parameters through the function body.

[0084] The above-mentioned picture loading module is used to obtain the picture resource memory object if the call of the picture resource loading interface is successful.

[0085] The above-mentioned device also includes: a picture information display module, which is used for the rendering node to display the picture information corresponding to the picture resource memory object on the computer screen.

[0086] The array stores multiple image resource memory objects and multiple associated data of multiple rendering nodes. After the step of storing the associated data in the array, the device further includes: a timed polling module, which is used to traverse the array based on timed polling to check whether the life cycle of the rendering node in the multiple associated data in the array has ended.

[0087] The timing polling module is also used to reduce the number of references to the image resource memory object corresponding to the currently traversed associated data by one, delete the associated data, and continue to traverse the next associated data in the array if the life cycle of the rendering node in the associated data ends.

[0088] The timing polling module is also used to continue traversing the next associated data in the array if the life cycle of the rendering node in the associated data is not over for the currently traversed associated data.

[0089] Technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, the specific working process of the registration switching system of the terminal device described above can refer to the corresponding process in the embodiment of the aforementioned memory management optimization method, and will not be repeated here.

[0090] Embodiment 4:

[0091] The embodiment of the present invention also provides an electronic device for executing the above memory management optimization method; see Figure 7 A structural schematic diagram of an electronic device is shown, which includes a memory 100 and a processor 101, wherein the memory 100 is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor 101 to implement the above-mentioned memory management optimization method.

[0092] Further, Figure 7 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .

[0093] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0094] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.

[0095] An embodiment of the present invention also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned memory management optimization method. The specific implementation can be found in the method embodiment, which will not be repeated here.

[0096] The computer program product of the memory management optimization method, device, electronic device and storage medium provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.

[0097] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and / or device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0098] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0099] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0100] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0101] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A memory management optimization method, characterized in that: Applied to a game engine, the method comprises: Get the URL address of the external rendering node and image; Based on the URL address of the picture, the picture resource loading interface of the game engine is called to load the picture into the memory to obtain a picture resource memory object; the number of references of the picture resource memory object is increased by one; Mounting the image resource memory object on the rendering node; associating the image resource memory object with the rendering node, and storing the associated data in an array; If the life cycle of the rendering node in the associated data ends, the number of references to the image resource memory object is reduced by one, and the associated data is deleted; If the number of references to the image resource memory object is reduced to 0, the resource memory recycling mechanism is triggered; The array stores a plurality of associated data of the plurality of image resource memory objects and the plurality of rendering nodes; after the step of storing the associated data in the array, the method further comprises: traversing the array based on timed polling to check whether the life cycle of the rendering nodes in the plurality of associated data in the array has ended; After the step of checking whether the lifecycles of the rendering nodes in the plurality of associated data in the array have ended, the method further comprises: for the currently traversed associated data, if the lifecycle of the rendering nodes in the associated data has ended, reducing the number of references of the image resource memory object corresponding to the associated data by one, deleting the associated data, and continuing to traverse the next associated data in the array; After the step of checking whether the lifecycles of the rendering nodes in the plurality of associated data in the array have ended, the method further comprises: for the currently traversed associated data, if the lifecycle of the rendering nodes in the associated data has not ended, continuing to traverse the next associated data in the array.

2. The method according to claim 1, characterized in that The steps to obtain the URL address of the externally input rendering node and image include: The function body receives the URL address of the rendering node and image passed in from the outside as parameters.

3. The method according to claim 1, characterized in that The steps to obtain the image resource memory object include: If the call to the picture resource loading interface is successful, the picture resource memory object is obtained.

4. The method according to claim 1, characterized in that: After the step of mounting the image resource memory object on the rendering node, the method further includes: The rendering node displays the image information corresponding to the image resource memory object on the computer screen.

5. A memory management optimization device, characterized in that: Applied to a game engine, the device comprises: The external input module is used to obtain the URL address of the external rendering node and image; A picture loading module, used to call the picture resource loading interface of the game engine based on the URL address of the picture to load the picture into the memory, obtain a picture resource memory object; and increase the number of references of the picture resource memory object by one; A picture mounting module, used for mounting the picture resource memory object on the rendering node; associating the picture resource memory object with the rendering node, and storing the associated data in an array; An associated data deletion module, configured to reduce the number of references to the image resource memory object by one and delete the associated data if the life cycle of the rendering node in the associated data ends; A resource memory recycling module, used to trigger a resource memory recycling mechanism if the number of references to the image resource memory object is reduced to 0; The array stores a plurality of the image resource memory objects and a plurality of associated data of the rendering nodes; the device further comprises: a timing polling module, configured to traverse the array based on timing polling to check whether the life cycle of the rendering nodes in the plurality of associated data in the array has ended; The timing polling module is further configured to, for the currently traversed associated data, if the life cycle of the rendering node in the associated data ends, reduce the number of references of the image resource memory object corresponding to the associated data by one, delete the associated data, and continue to traverse the next associated data in the array; The timing polling module is further configured to continue traversing the next associated data in the array for the currently traversed associated data if the life cycle of the rendering node in the associated data has not ended.

6. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the memory management optimization method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the memory management optimization method according to any one of claims 1 to 4.