Memory management method and device in three-dimensional geometric modeling scene and storage medium

By using multiple free linked lists and descriptor structures to manage memory in the 3D geometric modeling engine, the problem of low memory management efficiency of traditional engines is solved, efficient memory allocation and release is achieved, and memory leak detection is provided.

CN118819851APending Publication Date: 2024-10-22TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410937997.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

Traditional 3D geometric modeling engines lack automatic garbage collection, resulting in high memory management system overhead and low allocation and recycling efficiency.

Method used

Multiple free linked lists are used, and the memory slots of each linked list are of different sizes. Memory allocation and release are managed through the descriptor structure, and the audit mode is used to record memory identification information to achieve efficient memory allocation and release.

Benefits of technology

By reducing dependence on the operating system, it improves the efficiency of memory allocation and release, reduces memory management overhead, and provides memory leak detection and auditing functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819851A_ABST
    Figure CN118819851A_ABST
Patent Text Reader

Abstract

The invention provides a memory management method and device in a three-dimensional geometric modeling scene and a storage medium. The method comprises the following steps: initializing a plurality of free linked lists; creating a descriptor structure for each free linked list, wherein the descriptor structure is used for storing description information of the corresponding free linked list; when a three-dimensional geometric modeling object is created, comparing the memory size occupied by the object with the description information of the free linked list, and obtaining the free linked list matched with the memory size occupied by the object as an allocation linked list; returning memories corresponding to the free memory slots in the allocation chain table, and adjusting description information of the allocation chain table according to the number of the free memory slots in the allocation chain table after allocation is completed; when the three-dimensional geometric modeling object is destroyed, the release chain table and the corresponding release memory slot are positioned, the release memory slot is marked as idle, and description information of the release chain table is adjusted according to the idle memory slot number in the release chain table after recovery is completed, so that efficient management of memory application and release in the three-dimensional geometric modeling process is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer three-dimensional modeling, and in particular to a memory management method, device and storage medium in a three-dimensional geometric modeling scenario. Background Art

[0002] The memory management technology in the 3D geometry modeling engine is a complex and critical part. It ensures efficient data processing and stable operation of applications, and is essential to ensure the efficient operation of the engine when processing complex scenes and large amounts of data. The 3D geometry modeling process often requires a large amount of memory, and the memory management system needs to use performance optimization technologies such as memory compression or caching to reduce memory usage. Since the 3D geometry modeling process often involves the creation and destruction of a large number of objects, such as points, edges, and faces, the memory management system needs to efficiently allocate and release these memories. Traditional geometry modeling engines do not provide automatic garbage collection functions because they are developed using programming languages ​​that do not have automatic garbage collection (such as C++), or in order to pursue faster memory allocation and recovery speeds, resulting in large memory management system overhead and low allocation and recovery efficiency. Summary of the invention

[0003] The present invention provides a memory management method, device and storage medium in a three-dimensional geometric modeling scenario, which are used to solve the defects that the traditional geometric modeling engine does not provide an automatic garbage collection function, resulting in large memory management system overhead and low allocation and recovery efficiency.

[0004] The present invention provides a memory management method in a three-dimensional geometric modeling scenario, comprising: Initializing a plurality of free linked lists, wherein the memory slots of the plurality of free linked lists have different sizes; A descriptor structure is created for each free linked list, wherein the descriptor structure is used to store description information of the corresponding free linked list; When creating a three-dimensional geometric modeling object, compare the memory size occupied by the object with the description information of the free linked list, and obtain a free linked list matching the memory size occupied by the object as an allocation linked list; return the memory corresponding to the free memory slots in the allocation linked list, and adjust the description information of the allocation linked list according to the number of free memory slots in the allocation linked list after the allocation is completed; When destroying a 3D geometric modeling object, locate the release list and the corresponding released memory slot, mark the released memory slot as free, and adjust the description information of the release list according to the number of free memory slots in the release list after recycling is completed.

[0005] The memory management method in the three-dimensional geometric modeling scene provided by the present invention also includes: Get the usage ratio of memory slots in each free list; According to the usage ratio of the memory slots, the corresponding free linked list is divided into an open part and a closed part, the open part is used to store free memory nodes; the closed part is used to store allocated memory nodes; the memory recovery strategy corresponding to the free memory nodes in the open part includes a retention strategy and a timely release strategy.

[0006] According to the memory management method in the three-dimensional geometric modeling scene provided by the present invention, each node of the free linked list is a memory block of a preset size, each memory block is divided into memory slots of fixed size, and the first preset byte of each memory slot is written into the address of the next free memory slot. When creating a three-dimensional geometric modeling object, it also includes: Determine whether there is a free memory block in the allocation linked list that matches the memory size occupied by the object, if there is a free memory block, allocate a corresponding free memory slot, update the description information in the descriptor structure, and write the descriptor structure address into the first preset byte of the free memory slot; If there is no free memory block in the allocation linked list that matches the memory size occupied by the object, the full memory block is moved to the closed part of the allocation linked list, and a new memory block is requested from the operating system.

[0007] According to the memory management method in the three-dimensional geometric modeling scenario provided by the present invention, the description information of the free list includes the types of application and release, application and release file names and line number information, and the method further includes: After the audit mode is turned on, the type of application and release, application and release file name and line number information are output to the audit log.

[0008] According to the memory management method in the three-dimensional geometric modeling scenario provided by the present invention, after the audit mode is turned on, the method further includes: Record memory identification information each time memory is requested; When destroying a 3D geometric modeling object, find the memory identification information recorded when the memory to be released is applied; Check whether the memory identification information found matches the memory identification information recorded when the memory is applied; If they do not match, output the leaked memory allocation information.

[0009] According to the memory management method in the three-dimensional geometric modeling scenario provided by the present invention, the memory identification information is a key-value pair, and the output leaked memory allocation information includes: When creating a 3D geometric modeling object, a dictionary is used to record the key-value pairs for applying for memory; When destroying the three-dimensional geometric modeling object, detecting whether there is a key corresponding to the memory value to be released in the dictionary, and if so, deleting the key-value pair from the dictionary; After the program for applying for memory is finished running, the remaining key-value pairs in the dictionary are used as memory allocation information for generating memory leak.

[0010] According to the memory management method in the three-dimensional geometric modeling scene provided by the present invention, when creating the three-dimensional geometric modeling object, it also includes: If the memory size occupied by the object is larger than the largest memory slot size in the free list, memory is directly requested from the operating system. The requested memory size includes an identification byte, which is used to write a magic number. The magic number is used to indicate that the corresponding memory is memory requested directly from the operating system.

[0011] According to the memory management method in the 3D geometric modeling scenario provided by the present invention, when destroying the 3D geometric modeling object, the method further includes: Reading data in the identification byte of the memory to be released, and if the data includes a magic number, returning the memory to be released to the operating system; If the data does not include a magic number, updating the first preset byte of the memory slot address to the number of the next free memory slot, and updating the location of the memory slot and the number of free memory slots in the descriptor structure; If the memory block is in the closed part of the free list and the proportion of the free memory slots is greater than a preset ratio, the memory block is moved to the open part of the free list.

[0012] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the memory management method in a three-dimensional geometric modeling scenario as described in any one of the above items is implemented.

[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the memory management method in any of the above-mentioned three-dimensional geometric modeling scenarios is implemented.

[0014] The present invention provides a memory management method, device and storage medium in a three-dimensional geometric modeling scenario. The method includes initializing multiple free linked lists, wherein the memory slots of the multiple free linked lists have different sizes. A descriptor structure is created for each free linked list, wherein the descriptor structure is used to store description information of the corresponding free linked list. When creating a three-dimensional geometric modeling object, the memory size occupied by the object is compared with the description information of the free linked list, and a free linked list matching the memory size occupied by the object is obtained as an allocation linked list. The free memory slots in the allocation linked list are returned to the corresponding memory, and the description information of the allocation linked list is adjusted according to the number of free memory slots in the allocation linked list after the allocation is completed. When destroying the three-dimensional geometric modeling object, a release linked list and a corresponding released memory slot are located, and the released memory slot is marked as free. After the recovery is completed, the description information of the release linked list is adjusted according to the number of free memory slots in the release linked list. When the program needs to apply for memory, the free linked list will perform memory allocation without applying to the operating system each time. With a small amount of additional memory overhead, efficient allocation and release of memory are achieved, and the free linked list is used in a three-dimensional geometric modeling engine to achieve efficient management of memory application and release in the three-dimensional geometric modeling process. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0016] Figure 1 This is one of the flowcharts of the memory management method in the three-dimensional geometric modeling scenario provided by an embodiment of the present invention; Figure 2 This is a second flow chart of a memory management method in a three-dimensional geometric modeling scenario provided by an embodiment of the present invention; Figure 3 This is a third flow chart of a memory management method in a three-dimensional geometric modeling scenario provided by an embodiment of the present invention; Figure 4 This is a fourth flow chart of a memory management method in a three-dimensional geometric modeling scenario provided by an embodiment of the present invention; Figure 5 This is a fifth flow chart of a memory management method in a three-dimensional geometric modeling scenario provided by an embodiment of the present invention; Figure 6 It is a functional structure diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. 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.

[0018] Figure 1 A flowchart of a memory management method in a three-dimensional geometric modeling scenario provided by an embodiment of the present invention, such as Figure 1 As shown, the memory management method in the three-dimensional geometric modeling scenario provided by the embodiment of the present invention includes: Step 101, initializing a plurality of free linked lists, wherein the memory slot sizes of the plurality of free linked lists are different; In the embodiment of the present invention, a free linked list pool containing multiple memory slots of different sizes is designed, and different free linked lists are selected for allocation according to the requested memory size.

[0019] Step 102: Create a descriptor structure for each free linked list, wherein the descriptor structure is used to store description information of the corresponding free linked list; Step 103: when creating a three-dimensional geometric modeling object, compare the memory size occupied by the object with the description information of the free linked list, and obtain a free linked list that matches the memory size occupied by the object as an allocation linked list; return the memory corresponding to the free memory slot in the allocation linked list, and adjust the description information of the allocation linked list according to the number of free memory slots in the allocation linked list after the allocation is completed; Step 104: when destroying the three-dimensional geometric modeling object, locate the release linked list and the corresponding released memory slot, mark the released memory slot as free, and adjust the description information of the release linked list according to the number of free memory slots in the release linked list after recycling is completed.

[0020] In traditional 3D geometric modeling scenarios, the memory management system needs to use performance optimization technologies such as memory compression or caching to reduce memory usage. Since the 3D geometric modeling process often involves the creation and destruction of a large number of objects, such as points, edges, and faces, the memory management system needs to efficiently complete the allocation and release of these memories. Traditional geometric modeling engines either use modeling engines developed in programming languages ​​that do not have automatic garbage collection (such as C++), or do not provide automatic garbage collection in order to pursue faster memory allocation and recycling speeds, resulting in high memory management system overhead and low allocation and recycling efficiency.

[0021] The memory management method in a three-dimensional geometric modeling scenario provided by an embodiment of the present invention initializes multiple free linked lists, and the memory slot sizes of the multiple free linked lists are different; a descriptor structure is created for each free linked list, and the descriptor structure is used to store the description information of the corresponding free linked list; when creating a three-dimensional geometric modeling object, the memory size occupied by the object is compared with the description information of the free linked list, and a free linked list matching the memory size occupied by the object is obtained as an allocation linked list; the free memory slots in the allocation linked list are returned to the corresponding memory, and the description information of the allocation linked list is adjusted according to the number of free memory slots in the allocation linked list after the allocation is completed; when destroying the three-dimensional geometric modeling object, a release linked list and the corresponding released memory slots are located, and the released memory slots are marked as free, and the description information of the release linked list is adjusted according to the number of free memory slots in the release linked list after the recovery is completed. When the program needs to apply for memory, the free linked list will allocate the memory without applying to the operating system each time. Through a small amount of additional memory overhead, efficient allocation and release of memory are achieved, and it is used in a three-dimensional geometric modeling engine to achieve efficient management of memory application and release in the three-dimensional geometric modeling process.

[0022] Based on any of the above embodiments, the memory management method in the 3D geometric modeling scenario further includes: Get the usage ratio of memory slots in each free list; According to the usage ratio of the memory slots, the corresponding free linked list is divided into an open part and a closed part, the open part is used to store free memory nodes; the closed part is used to store allocated memory nodes; the memory recovery strategy corresponding to the free memory nodes in the open part includes a retention strategy and a timely release strategy.

[0023] In the embodiment of the present invention, Figure 2 As shown, each node of the free linked list is a memory block of a preset size, each memory block is divided into memory slots of a fixed size, and the first preset byte of each memory slot is written into the address of the next free memory slot.

[0024] In the embodiment of the present invention, each node of the free linked list is a 4KB memory block, and each memory block is divided into memory slots of a fixed size (such as 8 bytes, 16 bytes, etc.).

[0025] In an embodiment of the present invention, the description information of the free list includes the types of application and release, application and release file names and line number information, and the memory management method in the three-dimensional geometric modeling scenario also includes: After the audit mode is turned on, the type of application and release, application and release file name and line number information are output to the audit log.

[0026] In an embodiment of the present invention, the new and delete operators are implemented by overloading, so as to record the type of application and release, the application and release file name and line number and other information. When the audit option is turned on, this information is recorded and output to the audit log.

[0027] like Figure 3 As shown, when creating a 3D geometric modeling object, it also includes: Determine whether there is a free memory block in the allocation linked list that matches the memory size occupied by the object, if there is a free memory block, allocate a corresponding free memory slot, update the description information in the descriptor structure, and write the descriptor structure address into the first preset byte of the free memory slot; If there is no free memory block in the allocation linked list that matches the memory size occupied by the object, the full memory block is moved to the closed part of the allocation linked list, and a new memory block is requested from the operating system.

[0028] Based on any of the above embodiments, the creating of the three-dimensional geometric modeling object further includes: If the memory size occupied by the object is larger than the largest memory slot size in the free list, memory is directly requested from the operating system. The requested memory size includes an identification byte, which is used to write a magic number. The magic number is used to indicate that the corresponding memory is memory requested directly from the operating system.

[0029] Based on any of the above embodiments, Figure 4 As shown, when destroying the three-dimensional geometric modeling object, it also includes: Step 201: read the data in the identification byte of the memory to be released, and if the data includes a magic number, return the memory to be released to the operating system; Step 202: If the data does not include a magic number, update the first preset byte of the memory slot address to the number of the next free memory slot, and update the memory slot position and free memory slot quantity information in the descriptor structure; Step 203: If the memory block is in the closed part of the free list and the proportion of the free memory slots is greater than a preset ratio, move the memory block to the open part of the free list.

[0030] In the embodiment of the present invention, Figure 5 As shown, after the audit mode is turned on, the memory management method in the 3D geometric modeling scenario also includes: Step 301, record memory identification information each time memory is applied; Step 302: when destroying the 3D geometric modeling object, searching for the memory identification information recorded when the memory to be released is applied for; Step 303: Detect whether the found memory identification information matches the memory identification information recorded when the memory is applied; Step 304: If there is no match, output the leaked memory allocation information.

[0031] In the embodiment of the present invention, the memory identification information is a key-value pair, and the output leaked memory allocation information includes: Step 3041: When creating a 3D geometric modeling object, a key-value pair for applying for memory is recorded through a dictionary; Step 3042: when destroying the 3D geometric modeling object, check whether there is a key corresponding to the memory value to be released in the dictionary, and if so, delete the key-value pair from the dictionary; Step 3043: After the program that requested the memory is finished running, the remaining key-value pairs in the dictionary are used as memory allocation information that caused the memory leak.

[0032] Based on any of the above embodiments, the memory management method in the three-dimensional geometric modeling scenario provided by the embodiment of the present invention specifically includes: S1. Initialize the corresponding free list according to the set memory slot size. Each free list applies for a 4KB memory block from the operating system and creates a descriptor structure.

[0033] In the embodiment of the present invention, each memory block is divided into memory slots of a set size + 8 bytes, and the 8 bytes are filled in order as 1, 2, 3, ..., indicating the position of the next free memory block. For each 4KB memory block, a descriptor structure is created to record the slot size, number of free memory slots, and position of the first free memory slot of the memory block.

[0034] S2. When the user uses overloaded new to apply for memory (create a 3D geometric modeling object), the size of the memory applied determines which linked list to allocate it.

[0035] In the embodiment of the present invention, when the user applies for memory using the overloaded new, the linked list to be allocated is determined according to the size of the applied memory. If the size of the applied memory is larger than the maximum memory slot size, the memory is directly applied for from the operating system, and the size of the applied memory will also be 8 bytes more, which is used to write the magic number to identify the memory as the memory directly applied for from the operating system.

[0036] S3. When the linked list allocates memory, it will first find a free memory slot in the first memory block in the linked list and return that part of the memory. After allocation, the linked list will be adjusted according to the number of free memory blocks.

[0037] In the embodiment of the present invention, when the linked list allocates memory, it will first search for an empty memory slot from the first memory block in the open part of the linked list, write the descriptor address of the memory block into the first 8 bytes of the memory slot, and then return the memory. If the memory block is full after allocation, it will be moved to the closed part, and then a new 4KB memory block will be requested from the operating system, and the same operation as in S1 will be performed.

[0038] S4. When the user uses the overloaded delete to release memory, the memory is released according to the allocation situation.

[0039] In an embodiment of the present invention, when a user uses an overloaded delete to release memory, the first 8 bytes of data in the memory are read first. If it is a magic number, the memory is returned to the operating system; otherwise, it is returned to the memory block of the corresponding address, and its first 8 bytes are written as the first free memory slot position in the descriptor, and the value in the descriptor is updated to the position of this memory slot.

[0040] S5, when the linked list reclaims memory, the released memory is located at the corresponding memory slot, and the memory slot is marked as free. After the recycling, the linked list is adjusted according to the number of free memory blocks.

[0041] In the embodiment of the present invention, when the linked list reclaims memory, the corresponding descriptor is first found based on the first 8 bytes, then the first 8 bytes are written as the first free memory slot position in the descriptor, and finally the variable in the descriptor is updated to the position of this memory slot and the number of free memory slots. If the memory block is in the closed part of the linked list, and the proportion of free memory slots is greater than a certain proportion, it is moved to the open part.

[0042] S6. After the audit mode is turned on, additional information will be recorded for each memory request. When the memory is released, the information recorded during the request will be searched to check whether it matches. When the program ends, the leaked memory information will be output; In an embodiment of the present invention, when the audit mode is turned on, for each memory application, the application size, application type, application file and number of lines and other information will be recorded, and the memory pointer and information will be saved as a key-value pair in the dictionary, and the global information will be updated at the same time, including the maximum number of bytes allocated, the number of applications, etc. When the memory is released, the corresponding information will be searched in the dictionary according to the memory pointer, and it will be detected whether the release type matches the application type, and the global information will be updated. When the program ends, if the key-value pair still exists in the dictionary, the leaked memory allocation information will be output to the file.

[0043] The memory management method in the three-dimensional geometric modeling scenario provided by the embodiment of the present invention implements memory management based on the free linked list technology, and realizes efficient allocation and release of memory through a small amount of additional memory overhead. When the program needs to apply for memory, the free linked list will allocate the memory without applying to the operating system every time. The released memory will also be recovered by the free linked list until the next application of the program; and each time the information on memory application and release is recorded, it provides memory information statistics and memory auditing functions during the program running process.

[0044] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the server may include: a processor 610 , a communications interface 620 , a memory 630 and a communications bus 640 , wherein the processor 610 , the communications interface 620 , and the memory 630 communicate with each other via the communications bus 640 . The memory 630 includes a computer program, an operating system, and acquired graph structure data. The processor 610 can call the logic instructions in the memory 630 to execute a memory management method in a three-dimensional geometric modeling scenario, the method comprising: initializing multiple free linked lists, the memory slot sizes of the multiple free linked lists are different; creating a descriptor structure for each free linked list, the descriptor structure is used to store description information of the corresponding free linked list; when creating a three-dimensional geometric modeling object, comparing the memory size occupied by the object with the description information of the free linked list, and obtaining a free linked list matching the memory size occupied by the object as an allocation linked list; returning the corresponding memory of the free memory slots in the allocation linked list, and adjusting the description information of the allocation linked list according to the number of free memory slots in the allocation linked list after the allocation is completed; when destroying the three-dimensional geometric modeling object, locating the release linked list and the corresponding released memory slots, marking the released memory slots as free, and adjusting the description information of the release linked list according to the number of free memory slots in the release linked list after the recycling is completed.

[0045] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in 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 and other media that can store program codes.

[0046] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the memory management method in the three-dimensional geometric modeling scenario provided by the above-mentioned methods, the method comprising: initializing multiple free linked lists, the memory slot sizes of the multiple free linked lists being different; creating a descriptor structure for each free linked list, the descriptor structure being used to store description information of the corresponding free linked list; when creating a three-dimensional geometric modeling object, comparing the memory size occupied by the object with the description information of the free linked list, and obtaining a free linked list that matches the memory size occupied by the object as an allocation linked list; returning the corresponding memory of the free memory slots in the allocation linked list, and adjusting the description information of the allocation linked list according to the number of free memory slots in the allocation linked list after the allocation is completed; when destroying the three-dimensional geometric modeling object, locating the release linked list and the corresponding released memory slots, marking the released memory slots as free, and adjusting the description information of the release linked list according to the number of free memory slots in the release linked list after the recycling is completed.

[0047] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0048] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0049] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A memory management method in a 3D geometric modeling scenario, It is characterized in that include: Initializing a plurality of free linked lists, wherein the memory slots of the plurality of free linked lists have different sizes; A descriptor structure is created for each free linked list, wherein the descriptor structure is used to store description information of the corresponding free linked list; When creating a three-dimensional geometric modeling object, compare the memory size occupied by the object with the description information of the free linked list, and obtain a free linked list matching the memory size occupied by the object as an allocation linked list; return the memory corresponding to the free memory slots in the allocation linked list, and adjust the description information of the allocation linked list according to the number of free memory slots in the allocation linked list after the allocation is completed; When destroying a 3D geometric modeling object, locate the release list and the corresponding released memory slot, mark the released memory slot as free, and adjust the description information of the release list according to the number of free memory slots in the release list after recycling is completed.

2. The memory management method in a three-dimensional geometric modeling scenario according to claim 1, It is characterized in that Also includes: Get the usage ratio of memory slots in each free list; Dividing the corresponding free linked list into an open part and a closed part according to the usage ratio of the memory slots, wherein the open part is used to store free memory nodes; The closed part is used to store the allocated memory nodes; The memory recycling strategies corresponding to the idle memory nodes in the open part include a retention strategy and a timely release strategy.

3. The memory management method in a three-dimensional geometric modeling scenario according to claim 2, It is characterized in that Each node of the free linked list is a memory block of a preset size, each memory block is divided into memory slots of fixed size, and the first preset byte of each memory slot is written into the address of the next free memory slot. When creating a three-dimensional geometric modeling object, it also includes: Determine whether there is a free memory block in the allocation linked list that matches the memory size occupied by the object, if there is a free memory block, allocate a corresponding free memory slot, update the description information in the descriptor structure, and write the descriptor structure address into the first preset byte of the free memory slot; If there is no free memory block in the allocation linked list that matches the memory size occupied by the object, the full memory block is moved to the closed part of the allocation linked list, and a new memory block is requested from the operating system.

4. The memory management method in a three-dimensional geometric modeling scenario according to claim 1, It is characterized in that The description information of the free list includes the types of application and release, application and release file names and line number information, and the method further includes: After the audit mode is turned on, the type of application and release, application and release file name and line number information are output to the audit log.

5. The memory management method in a three-dimensional geometric modeling scenario according to claim 4, It is characterized in that After the audit mode is turned on, the method further includes: Record memory identification information each time memory is requested; When destroying a 3D geometric modeling object, find the memory identification information corresponding to the memory to be released; Check whether the memory identification information found matches the memory identification information recorded when the memory is applied; If they do not match, output the leaked memory allocation information.

6. The memory management method in a three-dimensional geometric modeling scenario according to claim 5, It is characterized in that The memory identification information is a key-value pair, and the output leaked memory allocation information includes: When creating a 3D geometric modeling object, a dictionary is used to record the key-value pairs for applying for memory; When destroying the three-dimensional geometric modeling object, detecting whether there is a key corresponding to the memory value to be released in the dictionary, and if so, deleting the key-value pair from the dictionary; After the program for applying for memory is finished running, the remaining key-value pairs in the dictionary are used as memory allocation information for generating memory leak.

7. The memory management method in a three-dimensional geometric modeling scene according to claim 1, It is characterized in that The creating of the three-dimensional geometric modeling object also includes: If the memory size occupied by the object is larger than the largest memory slot size in the free list, memory is directly requested from the operating system. The requested memory size includes an identification byte, which is used to write a magic number. The magic number is used to indicate that the corresponding memory is memory requested directly from the operating system.

8. The memory management method in a three-dimensional geometric modeling scenario according to claim 7, It is characterized in that The destroying of the three-dimensional geometric modeling object also includes: Reading data in the identification byte of the memory to be released, and if the data includes a magic number, returning the memory to be released to the operating system; If the data does not include a magic number, updating the first preset byte of the memory slot address to the number of the next free memory slot, and updating the location of the memory slot and the number of free memory slots in the descriptor structure; If the memory block is in the closed part of the free list and the proportion of the free memory slots is greater than a preset ratio, the memory block is moved to the open part of the free list.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the memory management method in the three-dimensional geometric modeling scenario is implemented as described in any one of claims 1 to 7.

10. A non-transitory readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the memory management method in a three-dimensional geometric modeling scenario as described in any one of claims 1 to 7 is implemented.