Method, device and equipment for processing memory management information of open source geometry engine
By adding custom memory management information to the source code of the GEOS library and modifying the jump address in the dynamic library file through disassembly technology, the memory leakage problem of GEOS library in memory management is solved, and the memory allocation and release functions are replaced, which improves the stability of the database system.
Patent Information
- Application Number
- CN202510349227.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-06-27
AI Technical Summary
GEOS library has memory leak problems in memory management. Existing methods require extensive modification of the source code or overloading of new and delete operators of dynamic libraries, but these methods have problems with instability and unpredictability.
Add custom memory management information to the source code of the GEOS library, including preset jump address information of the memory application function and the release function, and modify the jump address in the dynamic library file through disassembly technology to realize the replacement of memory allocation and release function.
On the basis of not requiring major modifications to the GEOS library files, the replacement of memory allocation and release functions in the library is implemented, reducing the impact of memory leaks and improving the stability of the database system.
Smart Images

Figure CN120215901A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the technical field of database management, and in particular, to a method, an apparatus, and a device for processing memory management information of an open-source geometry engine. Background Art
[0002] The GEOS library is used to develop functions related to geometric graphics and geographic data. Its application programming interface (API) has comprehensive functions and high execution efficiency, and is favored by many large projects. At the same time, its stability and maturity have been verified by time and a large number of users. Introducing the GEOS library into a project can significantly improve the development progress and the reliability of the software. However, the GEOS library is not perfect in terms of memory management, and memory leaks may occur. Many authors of other third-party libraries have realized that they cannot guarantee to completely avoid the risk of memory leaks. Therefore, they encapsulate the memory allocation and release logic and provide users with a method to set callback functions to let users manage the memory application and release in the third-party library. When the functions in the library need to apply for and release memory, they all use the functions passed in by the user to execute. At this time, as long as the user's memory management function is designed reasonably, the impact of memory leaks can be reduced or even eliminated. However, the GEOS library does not have such a function.
[0003] For the GEOS library mainly using C++, the new and delete methods in each class (generally, each base class is overloaded) are overloaded, and then the corresponding callback functions are set to let the user specify the function addresses for memory application and release. This approach is the most common and stable. However, this method requires a huge amount of modification to the source code, and it cannot be guaranteed that the modifications made are complete. If the library also uses some other C++ template libraries, these libraries also need to be modified.
[0004] Another method is to overload the global new and delete operators in the dynamic library code. The amount of modification of this method is not related to the quantity of the source code, so the amount of modification is much smaller than the above method, and its scope of action is also wider. However, the final running effect after such overloading is related to the connection process when the operating system (such as Linux) loads the dynamic library. In some cases, it may occur that the overloading is successful but it does not take effect during runtime. In other cases, the new and delete operators in the main program and other dynamic libraries used by the main program may also be replaced, thus possibly causing unpredictable problems. Therefore, this obviously cannot meet the requirements of the database system. Summary of the Invention
[0005] Embodiments of the present disclosure provide a method, apparatus, and device for processing memory management information of an open-source geometry engine, which can replace the memory allocation and release functions in the library without making major modifications to the GEOS library file.
[0006] In a first aspect, a method for processing memory management information of an open-source geometry engine is provided, including:
[0007] Adding custom memory management information to the source code of the first open-source geometry engine GEOS to obtain a second open-source geometry engine GEOS, where the custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function;
[0008] Compiling the second open-source geometry engine GEOS into a dynamic library file;
[0009] Determining first address information and second address information according to the disassembly result of the dynamic library file, where the first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function, and the second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function;
[0010] For the disassembly instructions associated with the first address information, modifying the first address information with the second address information to obtain modified disassembly instructions associated with the second address information;
[0011] Wherein, the disassembly instructions are used for program jumps, and the type of the disassembly instructions is determined by the type of the central processing unit CPU.
[0012] In a second aspect, a device for processing memory management information of an open-source geometry engine is provided, including:
[0013] An information adding module, configured to add custom memory management information to the source code of the first open-source geometry engine GEOS to obtain a second open-source geometry engine GEOS, where the custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function;
[0014] A compiling module, configured to compile the second open-source geometry engine GEOS into a dynamic library file;
[0015] An information determining module, configured to determine first address information and second address information according to the disassembly result of the dynamic library file, where the first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function, and the second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function;
[0016] A modification module, configured to modify the first address information by using the second address information for a disassembly instruction associated with the first address information, so as to obtain a modified disassembly instruction associated with the second address information;
[0017] Wherein, the disassembly instruction is used for program jump, and the type of the disassembly instruction is determined by the type of a central processing unit (CPU).
[0018] In a third aspect, an electronic device is provided, and the electronic device includes:
[0019] One or more processors;
[0020] A storage device, configured to store one or more programs,
[0021] When the one or more programs are executed by the one or more processors, the one or more processors implement the memory management information processing method of the open source geometry engine as described in the first aspect above.
[0022] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the memory management information processing method of the open source geometry engine as described in the first aspect above is implemented.
[0023] In a fifth aspect, a computer program product is provided, and the computer program product includes a computer program, and when the computer program is executed by a processor, the memory management information processing method of the open source geometry engine as described in the first aspect above is implemented.
[0024] The embodiments of the present disclosure disclose a method, apparatus, and device for processing memory management information of an open-source geometry engine, including: adding custom memory management information to the source code of a first open-source geometry engine GEOS to obtain a second open-source geometry engine GEOS, where the custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function; compiling the second open-source geometry engine GEOS into a dynamic library file; determining first address information and second address information according to the disassembly result of the dynamic library file, where the first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function, and the second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function; for the disassembly instructions associated with the first address information, modifying the first address information using the second address information to obtain modified disassembly instructions associated with the second address information. This technical solution changes the original jump addresses of the memory application and release functions in the GEOS library file to preset jump address information, and realizes the replacement of the memory allocation and release functions in the library without making major modifications to the GEOS library file.
[0025] 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 embodiments of the present disclosure. Other features of the embodiments of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0027] Figure 1 is a flowchart of a method for processing memory management information of an open-source geometry engine provided in Embodiment 1 of the present disclosure;
[0028] Figure 2 is a schematic diagram of the process of processing memory management information of an open-source geometry engine provided in Embodiment 1 of the present disclosure;
[0029] Figure 3 is a schematic structural diagram of a device for processing memory management information of an open-source geometry engine provided in Embodiment 2 of the present disclosure;
[0030] Figure 4 A schematic structural diagram of an electronic device provided in Embodiment 3 of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0031] To enable those skilled in the art to better understand the solutions of the embodiments of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the embodiments of the present disclosure.
[0032] It should be noted that the terms "first", "second", etc. in the description and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0033] Embodiment 1
[0034] Figure 1 As shown in the flowchart of a method for processing memory management information of an open-source geometry engine provided in Embodiment 1 of the present disclosure, this embodiment is applicable to the situation of processing memory management information of an open-source geometry engine. This method can be executed by a device for processing memory management information of an open-source geometry engine. The device for processing memory management information of an open-source geometry engine can be implemented in the form of hardware and / or software, and the device for processing memory management information of an open-source geometry engine can be configured in an electronic device. The electronic device includes, but is not limited to, devices with data processing capabilities such as computers, laptops, terminals, and servers. As Figure 1 shown, the method includes:
[0035] S110. Add custom memory management information to the source code of the first open-source geometry engine GEOS to obtain a second open-source geometry engine GEOS. The custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function.
[0036] In this embodiment, the open-source geometry engine (Geometry Engine-Open Source, GEOS) is an open-source library written in C++, which is used to process two-dimensional geometric objects and provides rich spatial data type operations and spatial relationship query functions. The first open-source geometry engine GEOS can be the original GEOS library. By adding custom memory management information to the first open-source geometry engine GEOS, the second open-source geometry engine GEOS can be obtained. Among them, the custom memory management information can be pre-defined information for memory management. Exemplarily, the custom memory management information can include the preset jump address information of the memory application function and the preset jump address information of the memory release function.
[0037] Among them, the memory application function can be a function used to apply to the operating system for allocating a certain amount of memory space, and the memory release function can be a function that returns the previously applied memory space to the operating system. Exemplarily, the memory application function can be new, and the memory release function can be delete. It should be noted that the memory application function and the memory release function in this embodiment can also read the values of specific global variables, and thus can realize changing the jump addresses of the memory application function and the memory release function.
[0038] S120. Compile the second open-source geometry engine GEOS into a dynamic library file.
[0039] In this embodiment, after obtaining the second open-source geometry engine GEOS, the second open-source geometry engine GEOS can be compiled into a dynamic library file. Among them, the dynamic library file is a special program library that allows a program to load and use the code and resources in the library at runtime (instead of compile time). This type of library exists as an independent file in the operating system and is usually called during the execution of the program.
[0040] Specifically, the dependencies required for compiling GEOS can be installed (such as: CMake build tool and / or GNU Compiler Collection, etc.). Among them, CMake is a cross-platform automated build system that can use a configuration file (CMakeLists.txt) to generate standard build files; the GNU Compiler Collection (GCC) is a compiler collection developed by the GNU project that supports multiple operating systems and hardware architectures. Exemplarily, taking the Linux system as an example: the GEOS build system can be configured using CMake, and the option to build the dynamic library can be started. Use CMake to compile GEOS. After compilation, install GEOS to the standard library path of the system or other specified directories.
[0041] S130. Determine the first address information and the second address information according to the disassembly result of the dynamic library file. The first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function. The second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function.
[0042] It can be known that after obtaining the dynamic library file, the first address information and the second address information in the dynamic library binary file can be viewed through commands such as disassembly. The first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function. The second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function. Among them, the disassembly command can refer to the commands or operations used in the disassembler software to control the behavior of the disassembler, such as starting the disassembly process, selecting the code segment to be disassembled, jumping to a specified address, etc.
[0043] Exemplarily, the first address information may include that the original jump address of the memory application function is 1, and the original jump address information of the memory release function is 2. The second address information may include that the preset jump address information of the memory application function is 3, and the preset jump address information of the memory release function is 4.
[0044] S140. For the disassembly instructions associated with the first address information, modify the first address information by using the second address information to obtain the modified disassembly instructions associated with the second address information. Among them, the disassembly instructions are used for program jumps, and the type of the disassembly instructions is determined by the type of the central processing unit (CPU).
[0045] In this embodiment, the disassembly instructions may refer to the machine code instructions that have been disassembled into assembly language form. The disassembly instructions are the result of the disassembly process. In this embodiment, the disassembly instructions can be used for address jumps. When combined with the jump address of the memory application function or the jump address of the memory release function, the disassembly instructions can be used to implement memory management. The type of the disassembly instructions is determined by the type of the central processing unit (CPU).
[0046] Continuing with the above description, after obtaining the disassembly result (i.e., the disassembly instructions) of the dynamic library file through the disassembly command, for the disassembly instructions associated with the first address information, the first address information can be modified by using the second address information. The modification can be to modify the first address information to the second address information to obtain the modified disassembly instructions associated with the second address information.
[0047] This embodiment provides a method for processing memory management information of an open-source geometry engine, including: adding custom memory management information to the source code of the first open-source geometry engine GEOS to obtain a second open-source geometry engine GEOS, where the custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function; compiling the second open-source geometry engine GEOS into a dynamic library file; determining first address information and second address information according to the disassembly result of the dynamic library file, where the first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function, and the second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function; for the disassembly instructions associated with the first address information, modifying the first address information with the second address information to obtain modified disassembly instructions associated with the second address information. This technical solution modifies the original jump addresses of the memory application and release functions in the GEOS library file to preset jump address information, and replaces the memory allocation and release functions in the library without making major modifications to the GEOS library file.
[0048] Optionally, determining the type of disassembly instruction according to the type of CPU includes:
[0049] When the type of the CPU is the x86 microprocessor architecture, determining that the type of the disassembly instruction is the callq instruction;
[0050] When the type of the CPU is the MIPS64EL microprocessor architecture, determining that the type of the disassembly instruction is the bal instruction and / or the jal instruction;
[0051] When the type of the CPU is the ARM64 microprocessor architecture, determining that the type of the disassembly instruction is the bl instruction.
[0052] Specifically, the type of the CPU can be the model or architecture of the central processing unit. Different types of CPUs result in different determined disassembly instructions. In this embodiment, the type of the CPU can be the x86 microprocessor architecture, which is a widely used microprocessor instruction set architecture. When the type of the CPU is the x86 microprocessor architecture, the type of the disassembly instruction is the callq instruction, and callq is an instruction in x86 architecture assembly language that can be used to call a function or procedure and link to the current instruction address so that after the called code is executed, it can return to the call point to continue execution.
[0053] In this embodiment, the type of the CPU can be the MIPS64EL microprocessor architecture. The MIPS64EL microprocessor architecture is a 64-bit extended version of the MIPS architecture and is a processor architecture used in embedded systems and high-performance computing. When the type of the CPU is the MIPS64EL microprocessor architecture, the types of the disassembly instructions can be the bal instruction and / or the jal instruction. Among them, in the MIPS architecture, the bal instruction is used to conditionally jump to a label or address and save the address of the next instruction in a register, and is usually used to implement jumps in loops or conditional statements. The jal instruction in the MIPS architecture is used to unconditionally jump to a label or address and save the address of the next instruction in a register, and is usually used to implement function calls.
[0054] Continuing from the above, the type of the CPU can also be the ARM64 microprocessor architecture. ARM64 is the 64-bit version of the ARM architecture. The Advanced RISC Machine (ARM) architecture is a reduced instruction set computer (RISC) architecture. When the type of the CPU is the ARM64 microprocessor architecture, the type of the disassembly instruction is the bl instruction. Among them, the bl instruction is usually used to implement function calls. The bl instruction not only transfers control to the called function but also saves the return address so that the caller can return to the correct position to continue execution.
[0055] As an optional implementation manner, before using the second address information to modify the first address information for the disassembly instruction associated with the first address information, the method further includes:
[0056] Determine the address where the disassembly instruction associated with the first address information is located;
[0057] Specifically, before using the second address information to modify the first address information, the address where the disassembly instruction associated with the first address information is located can also be determined. Exemplarily, the disassembly instruction associated with the first address information can be represented as callq1, and the address where callq1 is located can be 5. It should be noted that the disassembly instruction can include multiple callq instructions, and there can be at least one callq1 instruction.
[0058] Then, using the second address information to modify the first address information includes:
[0059] Using the second address information to replace the first address information in the address.
[0060] Specifically, after determining the address where the disassembly instruction associated with the first address information is located, based on the address where the disassembly instruction associated with the first address information is located, the first address information in the address can be replaced with the second address information.
[0061] Exemplarily, the disassembly instruction associated with the first address information can be represented as callq1, the address where callq1 is located can be represented as 5, and the second address information can be represented as 3; then after determining the address 5, the 1 in the address 5 can be modified to 3. It should be noted that multiple callq1 instructions can be modified simultaneously. For example, when the disassembly instruction associated with the first address information is represented as callq1 and there are multiple callq1 instructions, the addresses where callq1 is located can be 5, 7, 9, and the second address information can be represented as 3. Then after determining the addresses 5, 7, 9, the 1 in the addresses 5, 7, 9 can be modified to 3.
[0062] As an alternative implementation, after modifying the first address information with the second address information for the disassembly instruction associated with the first address information to obtain the modified disassembly instruction associated with the second address information, the method further includes:
[0063] When the input address information of the main program is detected, use the input address information as the jump address of the memory application function and the jump address of the memory release function; wherein, the input address information includes the expected jump address of the memory application function and the expected jump address of the memory release function.
[0064] In this embodiment, after modifying the first address information with the second address information, when it is detected that the main program has input address information, the main program can be the technical solution provided in this embodiment, and the input address information can be used as the jump address of the memory application function and the jump address of the memory release function.
[0065] Among them, the input address information can be the input address information from outside the main program, and the input address information includes the expected jump address of the memory application function and the expected jump address of the memory release function. Exemplarily, the input address information can be the address information input from the main program, and the input address information can include the jump address 20 of the memory application function and the jump address 21 of the memory release function.
[0066] As an alternative implementation, the custom memory management information further includes callback functions and global variables. The callback functions include a first callback function and a second callback function; the global variables include a first global variable and a second global variable;
[0067] Using the input address information as the jump address of the memory application function and the jump address of the memory release function includes:
[0068] a1) Obtain the first input address information corresponding to the memory application function through the first callback function and save it in the first global variable;
[0069] It should be noted that when the input address information exists in the main program, the first input address information corresponding to the memory application function can be obtained through the first callback function. Among them, the first input address information can be the expected jump address of the memory application function in the input address information. Exemplarily, the first input address information can be 20.
[0070] Following the above description, after obtaining the first input address information through the first callback function, the first input address information can be saved in the first global variable.
[0071] b1) Use the expected jump address saved in the first global variable as the jump address of the memory application function;
[0072] Specifically, after saving the first input address information in the first global variable, the dynamic library can use the expected jump address (i.e., the first input address information) saved in the first global variable as the jump address of the memory application function.
[0073] c1) Obtain the second input address information corresponding to the memory release function through the second callback function and save it in the second global variable;
[0074] It should be noted that when the input address information exists in the main program, the second input address information corresponding to the memory release function can be obtained through the second callback function. Among them, the second input address information can be the expected jump address of the memory release function in the input address information. Exemplarily, the second input address information can be 21.
[0075] d1) Use the expected jump address saved in the second global variable as the jump address of the memory release function.
[0076] Specifically, after saving the second input address information in the second global variable, the dynamic library can use the expected jump address (i.e., the second input address information) saved in the second global variable as the jump address of the memory application function.
[0077] Exemplarily, when the main program detects the input address information, where the input address information is 20 and 21, 20 and 21 are respectively saved into the first global variable and the second global variable through the first callback function and the second callback function. When the memory application function and the memory release function in the GEOS library are needed, the values recorded in the first global variable (20) and the second global variable (21) can be used as the jump addresses. That is, when the memory application function and the memory release function in the GEOS library are to be called, the memory application function corresponding to address 20 and the memory release function corresponding to address 21 can be called.
[0078] As an alternative implementation, before using the input address information as the jump address of the memory application function and the jump address of the memory release function, it further includes:
[0079] Judging whether the input address information is a valid value; if the value of the input address information is a valid value, then use the input address information as the jump address of the memory application function and the jump address of the memory release function.
[0080] It should be noted that when the main program detects the input address information, it can also judge whether the input address information is a valid value. Exemplarily, it can judge whether the value of the input address information is a certain default illegal value. For example, when the input address information is NULL, it can be determined that it is not a valid value.
[0081] Continuing the above description, when it is determined that the input address information is a valid value, then the input address information can be used as the jump address of the memory application function and the jump address of the memory release function.
[0082] Figure 2 This is a schematic diagram of the memory management information processing process of an open-source geometry engine provided in this embodiment, as Figure 2As shown, in order for the database system to specify functions such as memory application and release of the database when using the GEOS library, the first thing to do is to modify the code of the GEOS library and add custom memory management information (memory management functions) etc. in the source code. However, in this step, only these functions need to be set up, and there is no need to call them anywhere in the library. After adding the functions and variables, compile the source code into a dynamic library binary file in the normal way. Obtain the function address information in the dynamic library file to prepare for modifying the call address. View the preset jump address information of the memory application function and the preset jump address information of the memory release function, the original jump address information of the memory application function and the original jump address information of the memory release function in the dynamic library binary file through disassembly and other commands. Since there are differences in the CPU instruction sets used on different platforms, according to the information obtained in the previous step, select different modification strategies corresponding to different CPU architectures and instruction sets to modify the dynamic library binary file: that is, modify all the original jump address information of the memory application function and the original jump address information of the memory release function used in the system in the dynamic library to the preset jump address information of the memory application function and the preset jump address information of the memory release function to obtain the final dynamic library file.
[0083] After the technical solution of this embodiment modifies the first address information using the second address information, the database needs to call a callback function once before using any function in the dynamic library, and pass the function addresses of the memory application and release of the database to the dynamic library. After that, when the new (memory application) and delete (memory release) operators are used to apply for memory in the library, the given functions will be executed. When executing a certain SQL statement that requires the GEOS library, the memory is allocated by the database, and the memory used in this statement can be released at one time after the execution of the SQL statement ends. In this way, even if there is a memory leak in a certain function, it can be released when the statement execution ends, reducing or even eliminating the impact brought by the memory leak and ensuring the stability of the database during operation. At the same time, because the interaction with the system's memory application and release interfaces is reduced, the execution speed of memory application and release can be accelerated to a certain extent. The method for processing memory management information of the open-source geometry engine provided by this technical solution only needs to make a small amount of modification to the GEOS library source code and perform a small amount of batch processing operations on the compiled dynamic library to add and use custom memory management information to the dynamic library. This method makes the use of the GEOS library in terms of memory safer and more stable.
[0084] Embodiment 2
[0085] Figure 3 is a schematic structural diagram of a device for processing memory management information of an open-source geometry engine provided by the second embodiment of the present disclosure; as Figure 3As shown, the device includes: an information adding module 210, a compiling module 220, an information determining module 230, and a modifying module 240.
[0086] Among them, the information adding module 210 is used to add custom memory management information to the source code of the first open-source geometry engine GEOS to obtain the second open-source geometry engine GEOS. The custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function.
[0087] The compiling module 220 is used to compile the second open-source geometry engine GEOS into a dynamic library file.
[0088] The information determining module 230 is used to determine first address information and second address information according to the disassembly result of the dynamic library file. The first address information includes the original jump address information of the memory application function and the original jump address information of the memory release function. The second address information includes the preset jump address information of the memory application function and the preset jump address information of the memory release function.
[0089] The modifying module 240 is used to modify the first address information with the second address information for the disassembly instructions associated with the first address information to obtain the modified disassembly instructions associated with the second address information.
[0090] Among them, the disassembly instructions are used for memory management, and the type of the disassembly instructions is determined by the type of the central processing unit CPU.
[0091] Embodiment 2 of the present disclosure provides a memory management information processing device for an open-source geometry engine, which realizes the replacement of memory allocation and release functions in the library without making large modifications to the GEOS library file.
[0092] Further, the device further includes: a disassembly instruction determining module, and the disassembly instruction determining module is used for:
[0093] When the type of the CPU is an x86 microprocessor architecture, determining that the type of the disassembly instruction is a callq instruction;
[0094] When the type of the CPU is a MIPS64EL microprocessor architecture, determining that the type of the disassembly instruction is a bal instruction and / or a jal instruction;
[0095] When the type of the CPU is an ARM64 microprocessor architecture, determining that the type of the disassembly instruction is a bl instruction.
[0096] Further, the device further includes: an address determining module, and the address determining module is used for:
[0097] Determine the address where the disassembly instruction associated with the first address information is located;
[0098] The modification module 240 can also be used for:
[0099] Replace the first address information in the address with the second address information.
[0100] Furthermore, the device further includes:
[0101] A jump address determination module, configured to use the input address information as the jump address of the memory application function and the jump address of the memory release function when detecting the input address information of the main program;
[0102] Wherein, the input address information includes the expected jump address of the memory application function and the expected jump address of the memory release function.
[0103] Furthermore, the custom memory management information further includes a callback function and global variables, the callback function includes a first callback function and a second callback function; the global variables include a first global variable and a second global variable;
[0104] The jump address determination module is further configured to:
[0105] Obtain first input address information corresponding to the memory application function through the first callback function, and save it to the first global variable;
[0106] Use the expected jump address saved in the first global variable as the jump address of the memory application function;
[0107] Obtain second input address information corresponding to the memory release function through the second callback function, and save it to the second global variable;
[0108] Use the expected jump address saved in the second global variable as the jump address of the memory release function.
[0109] Furthermore, the device further includes:
[0110] An input address information judgment module, configured to judge whether the input address information is a valid value; if the value of the input address information is a valid value, use the input address information as the jump address of the memory application function and the jump address of the memory release function.
[0111] The memory management information processing device of the open-source geometry engine provided by the embodiments of the present disclosure can execute the memory management information processing method of the open-source geometry engine provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects for executing the method.
[0112] Embodiment III
[0113] Figure 4 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the embodiments of the present disclosure described and / or claimed herein.
[0114] As Figure 4 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0115] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0116] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microprocessor, etc. The processor 11 executes the various methods and processes described above, such as the memory management information processing method of the open-source geometry engine.
[0117] In some embodiments, the method for processing memory management information of an open-source geometry engine may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for processing memory management information of the open-source geometry engine described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for processing memory management information of the open-source geometry engine by any other suitable means (e.g., by means of firmware).
[0118] The various embodiments of the systems and techniques described above in this document may be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on a chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0119] The computer programs for implementing the methods of the embodiments of the present disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer programs are executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer programs may 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.
[0120] In the context of embodiments of the present disclosure, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage 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. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, 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.
[0121] To provide for interaction with a user, the systems and techniques described herein can be implemented on an electronic device 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 electronic device. 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 input, voice input, or tactile input).
[0122] The systems and techniques described herein can be implemented in a computing system that includes a back-end component (e.g., as a data server), or a computing system that includes a middleware component (e.g., an application server), or a computing system that includes a front-end component (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, middleware, 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: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0123] A computing system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The relationship between the client and the server is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0124] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the embodiments of the present disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of the embodiments of the present disclosure can be achieved, and no limitation is imposed herein.
[0125] The above specific embodiments do not constitute a limitation on the protection scope of the embodiments of the present 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 replacements, and improvements made within the spirit and principles of the embodiments of the present disclosure shall be included within the protection scope of the embodiments of the present disclosure.
[0126] The embodiments of the present disclosure also provide a computer program product, including a computer program and / or instructions, which, when executed by a processor, implement the memory management information processing method of the open-source geometry engine provided in any embodiment of the present application.
[0127] In the process of implementing the computer program product, computer program code for performing the operations of the embodiments of the present disclosure can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network - including a local area network (LAN) or a wide area network (WAN) - or can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0128] Note that the above is only the preferred embodiment of the present disclosure and the technical principles applied. Those skilled in the art will understand that the embodiments of the present disclosure are not limited to the specific embodiments here, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the embodiments of the present disclosure. Therefore, although the embodiments of the present disclosure have been described in more detail through the above embodiments, the embodiments of the present disclosure are not limited to the above embodiments. Without departing from the concept of the embodiments of the present disclosure, more other equivalent embodiments can be included, and the scope of the embodiments of the present disclosure is determined by the scope of the appended claims.
Claims
1. A memory management information processing method for an open source geometry engine, characterized in that: include: Adding custom memory management information in the source code of the first open source geometry engine GEOS to obtain a second open source geometry engine GEOS, wherein the custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function; Compile the second open source geometry engine GEOS into a dynamic library file; Determining first address information and second address information according to the disassembly result of the dynamic library file, wherein the first address information includes original jump address information of the memory application function and original jump address information of the memory release function, and the second address information includes preset jump address information of the memory application function and preset jump address information of the memory release function; For the disassembly instruction associated with the first address information, modify the first address information using the second address information to obtain a modified disassembly instruction associated with the second address information; The disassembly instruction is used for program jump, and the type of the disassembly instruction is determined by the type of the central processing unit CPU.
2. The method according to claim 1, characterized in that Determine the type of disassembled instruction based on the type of CPU, including: When the type of the CPU is an x86 microprocessor architecture, determining that the type of the disassembled instruction is a callq instruction; When the type of the CPU is a MIPS64EL microprocessor architecture, determining that the type of the disassembled instruction is a bal instruction and / or a jal instruction; When the type of the CPU is an ARM64 microprocessor architecture, it is determined that the type of the disassembly instruction is a bl instruction.
3. The method according to claim 1, characterized in that Before modifying the first address information using the second address information for the disassembly instruction associated with the first address information, the method further includes: Determine the address of the disassembly instruction associated with the first address information; The modifying the first address information by using the second address information includes: The first address information in the address is replaced with the second address information.
4. The method according to claim 1, characterized in that: After modifying the first address information using the second address information for the disassembly instruction associated with the first address information to obtain the modified disassembly instruction associated with the second address information, the method further includes: When the input address information of the main program is detected, the input address information is used as the jump address of the memory application function and the jump address of the memory release function; The input address information includes an expected jump address of a memory application function and an expected jump address of a memory release function.
5. The method according to claim 4, characterized in that The custom memory management information also includes a callback function and a global variable, wherein the callback function includes a first callback function and a second callback function; the global variable includes a first global variable and a second global variable; Using the input address information as the jump address of the memory application function and the jump address of the memory release function includes: Obtaining first input address information corresponding to the memory application function through the first callback function, and saving it to the first global variable; Using the expected jump address stored in the first global variable as the jump address of the memory request function; Obtaining second input address information corresponding to the memory release function through the second callback function, and saving it to the second global variable; The expected jump address stored in the second global variable is used as the jump address of the memory release function.
6. The method according to claim 4, characterized in that Before using the input address information as the jump address of the memory application function and the jump address of the memory release function, the method further includes: Determine whether the input address information is a valid value; If the value of the input address information is a valid value, the input address information is used as the jump address of the memory application function and the jump address of the memory release function.
7. A memory management information processing device for an open source geometry engine, characterized in that: include: An information adding module is used to add custom memory management information in the source code of the first open source geometry engine GEOS to obtain the second open source geometry engine GEOS, wherein the custom memory management information includes preset jump address information of a memory application function and preset jump address information of a memory release function; A compiling module, used for compiling the second open source geometry engine GEOS into a dynamic library file; An information determination module, used to determine first address information and second address information according to the disassembly result of the dynamic library file, wherein the first address information includes original jump address information of the memory application function and original jump address information of the memory release function, and the second address information includes preset jump address information of the memory application function and preset jump address information of the memory release function; A modification module, configured to modify the first address information using the second address information for the disassembly instruction associated with the first address information, so as to obtain a modified disassembly instruction associated with the second address information; The disassembly instruction is used for program jump, and the type of the disassembly instruction is determined by the type of the central processing unit CPU.
8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the memory management information processing method of the open source geometry engine as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the memory management information processing method of the open source geometry engine as described in any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the memory management information processing method of the open source geometry engine as described in any one of claims 1 to 6.