Memory management method and device, equipment, storage medium and product

By using memory management arrays in the memory pool of the database system to manage memory slices of different memory capacity that are freed, and crop the first memory block into memory slices of different capacity, the problem of memory waste and fragmentation in the database system is solved. Improved memory utilization.

CN119493662APending Publication Date: 2025-02-21TRANSWARP TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411522798.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

The existing memory pooling scheme is not applicable in database systems, resulting in memory waste and memory fragmentation, reducing memory utilization.

Method used

When receiving the memory application for objects in the target process, searching the memory management array based on the memory application, obtaining the target array index corresponding to the target memory capacity that can meet the memory application request; the memory management array is used to manage the different freed memory capacity. The memory slice is a slice cut from the reusable first memory block; if the target memory slice is mounted under the target array index, the target memory slice is allocated to the object.

Benefits of technology

By cropping the first memory block into memory slices of different capacity, adapting to objects with different memory requirements in the database system, memory waste and memory fragmentation are reduced, and memory utilization is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493662A_ABST
    Figure CN119493662A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method and device, equipment, a storage medium and a product, and relates to the technical field of computers. The method comprises the steps that when a memory application of an object in a target process is received, a memory management array is searched based on the memory application, and a target array index corresponding to the target memory capacity capable of meeting the memory application request is obtained; the memory management array is used for managing released memory slices with different memory capacities, and the memory slices are slices cut from a reusable first memory block; and if the target memory chip is mounted under the target array index, allocating the target memory chip to the object. By cutting the first memory block into the memory pieces with different capacities, objects with different memory requirements in a database system can be adapted, memory waste and memory fragmentation are reduced, the memory management array is adopted to manage the released memory pieces with different memory capacities, the memory pieces are reused, and the memory utilization rate is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a memory management method, device, equipment, storage medium and product. Background Art

[0002] When allocating memory, it is common to directly use APIs such as new and malloc to apply for memory allocation. However, since the size of the memory block applied for is uncertain, frequent use will cause a large amount of memory fragmentation and thus reduce performance. The memory allocation method of the memory pool (MemoryPool). Before actually using the memory, a certain number of memory blocks of equal size are applied for allocation as a backup. When there is a new memory demand, a part of the memory block is allocated from the memory pool. If the memory block is insufficient, new memory is applied for, thereby avoiding memory fragmentation as much as possible and improving the efficiency of memory allocation.

[0003] However, the existing memory pool solution is not applicable to the database system because the objects in the database system change greatly. Using a fixed memory memory pool to allocate memory will cause memory waste and memory fragmentation, thus reducing memory utilization. Summary of the invention

[0004] The present invention provides a memory management method, device, equipment, storage medium and product to solve the problem that the existing memory pool solution is not suitable for database systems, causing memory waste and memory fragmentation, resulting in low memory utilization.

[0005] In a first aspect, an embodiment of the present invention provides a memory management method, which is applied to a memory pool corresponding to a database system, and the method includes:

[0006] An index search module is used to search a memory management array based on the memory application when receiving a memory application of an object in a target process, and obtain a target array index corresponding to a target memory capacity that can satisfy the memory application request; the memory management array is used to manage released memory slices of different memory capacities, and the memory slices are slices cut from a reusable first memory block;

[0007] The first memory allocation module is used to allocate the target memory slice to the object if a target memory slice is mounted under the target array index.

[0008] In a second aspect, an embodiment of the present invention provides a memory management device, which is applied to a memory pool corresponding to a database system, and the device includes:

[0009] An index search module is used to search a memory management array based on the memory application when receiving a memory application of an object in a target process, and obtain a target array index corresponding to a target memory capacity that can satisfy the memory application request; the memory management array is used to manage released memory slices of different memory capacities, and the memory slices are slices cut from a reusable first memory block;

[0010] The first memory allocation module is used to allocate the target memory slice to the object if a target memory slice is mounted under the target array index.

[0011] In a third aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:

[0012] at least one processor; and

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

[0014] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the memory management method described in any embodiment of the present invention.

[0015] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the memory management method described in any embodiment of the present invention when executed.

[0016] In a fifth aspect, an embodiment of the present invention provides a computer program product including a computer program, and when the computer program is executed by a processor, the memory management method described in any embodiment of the present invention is implemented.

[0017] The technical solution of the embodiment of the present invention is to obtain a target array index corresponding to the target memory capacity that can meet the memory application request by searching the memory management array based on the memory application when receiving the memory application of the object in the target process; the memory management array is used to manage the released memory slices of different memory capacities, and the memory slices are slices cut from the reusable first memory block; if the target memory slice is mounted under the target array index, the target memory slice is allocated to the object. By cutting the first memory block into memory slices of different capacities, it is possible to adapt to objects with different memory requirements in the database system, which solves the problem that the existing memory pool solution is not suitable for the database system, generates memory waste and memory fragmentation, and leads to low memory utilization, reduces memory waste and memory fragmentation, and uses the memory management array to manage the released memory slices of different memory capacities, reuses the memory slices, and improves memory utilization.

[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 1 A flowchart of a memory management method provided in Embodiment 1 of the present invention;

[0021] Figure 2 A structural diagram of a memory management array in a memory management method provided in Example 1 of the present application;

[0022] Figure 3 A schematic diagram of the structure of a memory group in a memory management method provided in Embodiment 1 of the present application;

[0023] Figure 4 Schematic diagram of a storage linked list of the first memory block in a memory management method provided in Example 1 of the present application

[0024] Figure 5 A schematic diagram of the structure of a memory management device provided in Embodiment 2 of the present invention;

[0025] Figure 6 A schematic diagram of the structure of an electronic device for implementing the memory management method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 should fall within the scope of protection of the present invention.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention 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 inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Embodiment 1

[0029] Figure 1 This is a flowchart of a memory management method provided in the first embodiment of the present invention. This embodiment can be applied to the management of memory allocation and release of the memory pool corresponding to the database system. The memory pool is a pre-allocated continuous memory area used to cache frequently accessed data in the database, reducing I / O operations on the physical disk, thereby significantly improving the read and write performance of the database. The method can be executed by a memory management device, which can be implemented in the form of hardware and / or software, and the memory management device can be configured in an electronic device. Figure 1 As shown, the method includes:

[0030] S110. When a memory request for an object in a target process is received, a memory management array is searched based on the memory request to obtain a target array index corresponding to a target memory capacity that can satisfy the memory request; the memory management array is used to manage released memory slices of different memory capacities, and the memory slices are slices cut from the first memory block.

[0031] Among them, the target process can be understood as a process that accesses the stored data in the database system. The object in the target process is understood as the object generated when the target process executes a command statement to access the database system. It can be understood that there can be multiple command statements in the target process, and the execution of each command statement may generate one or more objects. Memory application can be understood as a request to apply to the memory pool for allocation of a certain amount of memory space for use. The target memory capacity can be understood as the memory capacity allocated by the memory pool to the object. It can be understood that in order to meet the memory requirements of the object, the target memory capacity can be determined based on the memory capacity requested by the memory application, and the target memory capacity is not less than the requested memory capacity.

[0032] The first memory block block can be understood as a memory block that the memory pool applies for from the operating system running the database system and is allocated to the memory application object after being cut. In this embodiment, the first memory block is a reusable memory block, and the first memory block is cut into memory pieces of different memory capacities for allocation to various objects. The meaning of a reusable memory block can be understood as a memory block that will not be returned to the operating system after being released, but will be stored in the memory pool for use by other objects again, unless the size of the memory pool changes, in which case the memory block will be returned to the operating system.

[0033] The memory slice can be considered as a slice cut from the first memory block. The memory slices of different memory capacities contained in the first memory block can meet the requirements of different objects for different memory capacities. In this embodiment, the memory management array can be understood as an array that manages the released memory slices of different memory capacities, and each array index of the memory management array corresponds to a different memory capacity. The target array index is the array index corresponding to the target memory capacity. After the memory slice is released, it will be mounted under the array index of the corresponding memory capacity of the memory management array. It should be noted that one or more memory slices of corresponding memory capacity can be mounted under each array index.

[0034] Specifically, when receiving a memory application for an object generated in a target process, the memory pool corresponding to the database system determines a target memory capacity that can meet the memory application requirement, and searches for a target array index corresponding to the target memory capacity in a memory management array of the memory pool.

[0035] S120: If a target memory slice is mounted under the target array index, the target memory slice is allocated to the object.

[0036] The target memory slice may be understood as a memory slice of a target memory capacity corresponding to a target array index.

[0037] Specifically, if a target memory slice is mounted under the target array index, it means that a target memory slice of released target memory capacity exists in the memory management array, and therefore, the target memory slice is allocated to the object requesting memory.

[0038] The technical solution of the embodiment of the present invention is to obtain a target array index corresponding to the target memory capacity that can meet the memory application request by searching the memory management array based on the memory application when receiving the memory application of the object in the target process; the memory management array is used to manage the released memory slices of different memory capacities, and the memory slices are slices cut from the reusable first memory block; if the target memory slice is mounted under the target array index, the target memory slice is allocated to the object. By cutting the first memory block into memory slices of different capacities, objects with different memory requirements in the database system can be adapted, reducing memory waste and memory fragmentation, and using the memory management array to manage the released memory slices of different memory capacities, the memory slices are reused, and the memory utilization rate is improved.

[0039] As an optional embodiment of the embodiment of the present application, the method further includes:

[0040] S210: If no target memory slice is mounted under the array index, determine whether there is a first memory block in the memory pool whose memory capacity can satisfy the memory application.

[0041] Specifically, if the target memory slice is not mounted under the array index, it means that the memory slice of the target memory capacity has been allocated to the object and has not been released, and the memory slice of the target memory capacity needs to be cut from the first memory block to the object. Therefore, it is first determined whether there is a first memory block in the memory pool with a memory capacity that can meet the memory request.

[0042] S220: If yes, allocate a memory slice of the target memory capacity to the object from the first memory block.

[0043] Specifically, if there is a first memory block in the memory pool whose memory capacity can satisfy the memory request, a memory slice of the target memory capacity is allocated to the object from the first memory block.

[0044] S230: If not, apply for a next first memory block from the operating system running the database system, and allocate a target memory slice of the target memory capacity to the object from the next first memory block.

[0045] Specifically, if the memory pool does not contain a first memory block whose memory capacity can satisfy the memory request, for example, it may include: the memory pool does not contain the first memory block, or the memory capacity of the first memory block in the memory pool cannot satisfy the memory request, then it is necessary to apply for the next first memory block from the operating system, and allocate the target memory slice of the target memory capacity in the next first memory block to the object of the memory request.

[0046] As an optional embodiment of the embodiment of the present application, the memory capacity of the first memory block applied to the operating system running the database system increases according to an exponential power of 2 of the minimum memory capacity until the maximum memory capacity.

[0047] Among them, the maximum memory capacity can be understood as the memory capacity of the first memory block, and the minimum memory capacity can be set according to the memory capacity of the operating system and the maximum memory requirement of the database system, and the minimum memory capacity can be set according to the minimum memory requirement, for example, the minimum memory capacity is 1K and the maximum memory capacity is 1M. The embodiments of the present application do not set any restrictions on this.

[0048] Specifically, the memory capacity of each first memory block is different, and the memory capacity of the first memory block applied to the operating system running the database system each time increases according to the exponential power of 2 of the minimum memory capacity until the maximum memory capacity; for example, 1K, 2K, 4K, 8K, 16K, 32K, 64K, 128K, 256K, 512K, 1M, 1M, ... Among them, the minimum memory capacity is 1K, and the maximum memory capacity is 1M.

[0049] This embodiment increases the memory capacity of the first memory block applied for each time by an exponential power of 2, which can be adapted to the binary computing logic of the computer, facilitates memory address alignment and efficient search, and improves the efficiency of memory allocation and management.

[0050] As an optional embodiment of the embodiment of the present application, the memory capacity of the memory slice managed by the memory management array is an exponential power of 2.

[0051] On the basis of the above embodiment, S110, the step of searching the memory management array based on the memory application to obtain the target array index corresponding to the target memory capacity that can satisfy the memory application request includes:

[0052] If the memory capacity requested by the memory application does not exceed the maximum memory capacity, the requested memory capacity is raised to the power of 2 as the target memory capacity, and the target array index corresponding to the target memory capacity in the memory management array is searched.

[0053] The memory management array can manage memory slices that do not exceed the maximum memory capacity, and the memory capacity of each memory slice is an exponential power of 2. Exemplarily, in the memory management array, the relationship between the array index i and the memory capacity C of the memory slice is C=16×2 i B,i=0,1,2,……,N; B represents byte, 16×2 N B is the maximum memory capacity (max size), and 16B is the minimum memory capacity (min size). Figure 2This is a structural diagram of a memory management array in a memory management method provided in Example 1 of the present application. Figure 2 As shown, the memory capacities of the memory slices corresponding to array indexes 0 to 16 are: 16B, 32B, 64B, 128B, 256B, 512B, 1k, 2k, 4k, 8k, 16k, 32k, 64k, 128k, 256k, 512k, and 1M.

[0054] Specifically, when a memory application for an object in the target process is received, if the memory capacity requested by the memory application does not exceed the maximum memory capacity, the requested memory capacity is raised to the power of 2 closest to the target memory capacity, and the target array index corresponding to the target memory capacity in the memory management array is searched.

[0055] For example, if the memory capacity requested by the object's memory application is 240B, the memory pool raises the requested memory capacity to the power of 2 to get 256B, and then queries whether there is a memory slice mounted under array[4] of the memory management array; if so, the mounted memory slice is determined as the target memory slice, and the target memory slice is allocated to the object of the memory application.

[0056] This embodiment can quickly allocate memory slices that meet memory requirements for objects with different memory requirements through a memory management array, thereby reducing memory fragmentation, and is particularly suitable for database systems with relatively large changes in object size; at the same time, the memory capacity allocated to each object is an exponential power of 2, which improves memory allocation efficiency, and although it cannot completely avoid memory waste, it greatly reduces memory waste compared to the memory allocation method of fixed memory blocks.

[0057] In another optional embodiment, if the memory capacity requested by the memory application exceeds the maximum memory capacity, a second memory block of the requested memory capacity is applied to the operating system running the database system and allocated to the object.

[0058] The second memory block may be considered as memory allocated to objects whose memory requirements exceed the maximum memory capacity.

[0059] Specifically, since the probability of large objects whose requested memory capacity exceeds the maximum memory capacity is low, the efficiency of using the memory management array to allocate memory is not significantly improved. However, since the actual allocated memory capacity is the requested memory capacity raised to the power of 2, a large amount of memory may be wasted. For example, the requested memory capacity is 1.02M, but the allocated target memory capacity is 2M, resulting in a waste of 0.98M of memory.

[0060] Therefore, in this embodiment, for large objects whose memory requirements exceed the maximum memory capacity, an independent second memory block is provided to be allocated to the large object. If the memory capacity requested by the memory application exceeds the maximum memory capacity, the memory pool does not need to search the memory management array based on the memory application, but directly applies to the operating system for the second memory block of the requested memory capacity, and directly allocates the second memory block to the object.

[0061] For large objects whose memory requirements exceed the maximum memory capacity, this embodiment directly applies to the operating system for a second memory block of the requested memory capacity to be allocated to the object. Since the memory capacity of the second memory block is large, memory fragmentation will not occur and no memory waste will occur.

[0062] As an optional embodiment of the embodiment of the present application, the method further includes:

[0063] S310, creating a memory group and a corresponding dictionary for each object generated by each command statement in the target process executed by the database system; wherein each target memory slice or second memory block in the memory group is connected based on a one-way linked list; and the dictionary uses the command identifier of the command statement as a key and the memory address of the target memory slice or second memory block allocated to each object as a value.

[0064] The command identifier query_id may be understood as a symbol that uniquely identifies a command statement, and may be represented by a natural number, such as 1, 2, 3, ...

[0065] Specifically, in the process of executing the command statement in the target process, the database system allocates the target memory slice or the second memory block according to the requested memory capacity for the object generated by executing each command statement, and creates a memory group and a corresponding dictionary. In the memory group, the target memory slice or the second memory block allocated to the object generated by a command statement is connected based on a one-way linked list. The dictionary corresponding to the memory group is used to store key values, with the command identifier of the command statement as the key and the memory address of the target memory slice or the second memory block allocated to each object as the value.

[0066] For example, Figure 3 This is a schematic diagram of the structure of a memory group in a memory management method provided in Example 1 of the present application. Figure 3 As shown, a one-way linked list is used to connect the target memory slices or second memory blocks allocated to each object generated by executing each command statement. In the one-way linked list, the pointer of each target memory slice or second memory block points to the next target memory slice or second memory block, and each one-way linked list is associated with the command identifier of the command statement.

[0067] In a database system, a large number of objects with different memory requirements are generated when each statement is executed. When the execution is completed, these objects must be destroyed and their memory must be released. If the workload is huge and it is easy to miss them one by one, the convenience advantage of the memory pool will not be reflected. This embodiment adds the concept of memory group to the memory pool, and uses memory group to uniformly release the memory allocated to each object generated by executing the command statement, so as to facilitate the automatic release of memory in the same group, and there is no need to release memory for each object separately.

[0068] Based on the above optional embodiment, the method further includes:

[0069] S410: Receive a target command identifier of the target command statement sent by the database system after the execution of the target command statement in the target process is completed.

[0070] Specifically, after the database system finishes executing the target command statement in the target process, it sends the target command identifier of the target command statement to the memory pool, so that the memory pool receives the target command identifier.

[0071] S420, searching the dictionary for a memory group corresponding to the target command identifier as a key, releasing all target memory slices contained in the memory group to the memory pool, and releasing all second memory blocks contained therein to the operating system; wherein the second memory blocks are non-reusable memories.

[0072] The meaning of the non-reusable memory block can be understood as the memory block will be returned to the operating system after being released.

[0073] Specifically, after receiving the target command identifier, the memory pool searches the dictionary based on the target command identifier, determines the memory group corresponding to the target command identifier as the key, and releases the memory in the memory group that is linked by a one-way linked list. The target memory slice contained in the memory group is reusable memory and is released to the memory pool; the second memory block contained in the memory group is non-reusable memory and is released to the operating system.

[0074] After the target command statement is executed, this embodiment uses a memory group to uniformly release the reusable memory slices allocated to each object generated by the execution command statement to the memory pool, and uniformly releases the non-reusable second memory blocks to the operating system, thereby improving the memory release efficiency of a single object.

[0075] As an optional embodiment of the embodiment of the present application, the first memory blocks existing in the memory pool are connected based on a bidirectional linked list; the method further includes:

[0076] S510: When the target process ends, all first memory blocks connected to the bidirectional linked list in the memory pool are released to the operating system running the database system.

[0077] Specifically, after the target process ends, the first memory block in the memory pool requested from the operating system needs to be released. Figure 4 A schematic diagram of a storage linked list of a first memory block in a memory management method provided in Example 1 of the present application, such as Figure 4 As shown, the first memory blocks in the memory pool are connected based on a bidirectional linked list. After any first memory block is found through the bidirectional linked list, all first memory blocks in the memory pool connected by the bidirectional linked list can be released to the operating system.

[0078] This embodiment connects the first memory blocks in the memory pool based on a bidirectional linked list, so that all the applied first memory blocks in the memory pool can be uniformly released after the target process ends, thereby further improving the efficiency of releasing memory from the memory pool.

[0079] Embodiment 2

[0080] Figure 5 This is a schematic diagram of the structure of a memory management device provided by Embodiment 2 of the present invention. Figure 5 As shown, the device includes: an index search module 510 and a first memory allocation module 520; wherein,

[0081] The index search module 510 is used to search the memory management array based on the memory application when receiving the memory application of the object in the target process, and obtain the target array index corresponding to the target memory capacity that can meet the memory application request; the memory management array is used to manage the released memory slices of different memory capacities, and the memory slices are slices cut from the reusable first memory block;

[0082] The first memory allocation module 520 is configured to allocate the target memory slice to the object if a target memory slice is mounted under the target array index.

[0083] The technical solution of the embodiment of the present invention is to obtain a target array index corresponding to the target memory capacity that can meet the memory application request by searching the memory management array based on the memory application when receiving the memory application of the object in the target process; the memory management array is used to manage the released memory slices of different memory capacities, and the memory slices are slices cut from the reusable first memory block; if the target memory slice is mounted under the target array index, the target memory slice is allocated to the object. By cutting the first memory block into memory slices of different capacities, objects with different memory requirements in the database system can be adapted, reducing memory waste and memory fragmentation, and using the memory management array to manage the released memory slices of different memory capacities, the memory slices are reused, and the memory utilization rate is improved.

[0084] Optionally, the memory capacity of the first memory block requested from the operating system running the database system increases according to an exponential power of 2 of the minimum memory capacity until reaching a maximum memory capacity.

[0085] Optionally, the memory capacity of the memory slice managed by the memory management array is an exponential power of 2.

[0086] Optionally, the index search module is specifically used to:

[0087] If the memory capacity requested by the memory application does not exceed the maximum memory capacity, the requested memory capacity is raised to the power of 2 as the target memory capacity, and the target array index corresponding to the target memory capacity in the memory management array is searched.

[0088] Optionally, the device further comprises:

[0089] A judgment module, configured to judge whether there is a first memory block in the memory pool whose memory capacity can satisfy the memory application if no target memory slice is mounted under the array index;

[0090] a second memory allocation module, configured to allocate a memory slice of the target memory capacity to the object from the first memory block;

[0091] The third memory allocation module is used for, if not, applying for a next first memory block from the operating system running the database system, and allocating a target memory slice of the target memory capacity to the object from the next first memory block.

[0092] Optionally, the device further comprises:

[0093] A memory group creation module is used to create a memory group and a corresponding dictionary for each object generated by each command statement in the target process executed by the database system; wherein each target memory slice or second memory block in the memory group is connected based on a one-way linked list; and the dictionary uses the command identifier of the command statement as a key and the memory address of the target memory slice or second memory block allocated to each object as a value.

[0094] Optionally, the device further comprises:

[0095] An identifier receiving module, used for receiving a target command identifier of the target command statement sent by the database system after the execution of the target command statement in the target process is completed;

[0096] The first memory release module is used to search the memory group corresponding to the target command identifier as a key in the dictionary, release all target memory slices contained in the memory group to the memory pool, and release all second memory blocks contained therein to the operating system running the database system; wherein the second memory block is a non-reusable memory.

[0097] Optionally, the first memory blocks in the memory pool are connected based on a bidirectional linked list.

[0098] Optionally, the device further comprises:

[0099] The second memory release module is used to release all first memory blocks connected to the bidirectional linked list in the memory pool to the operating system running the database system when the target process ends.

[0100] The memory management device provided in the embodiment of the present invention can execute the memory management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0101] Embodiment 3

[0102] Figure 6 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. 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 electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0103] like Figure 6As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and 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 to 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. An input / output (I / O) interface 15 is also connected to the bus 14.

[0104] A number of 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 disk, an optical disk, 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.

[0105] The processor 11 may be a variety of general and / or special 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 special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a memory management method.

[0106] In some embodiments, the memory management method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on 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 memory management method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the memory management method in any other appropriate manner (e.g., by means of firmware).

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

[0108] In some embodiments, the memory management method may be implemented as a computer program, which is invisibly included in a computer program product, which implements the memory management method of the present invention when executed by a processor, and the computer program product may be understood as a software product that implements its solution mainly through a computer program. The computer program for implementing the method of the present invention 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package and partially on a remote machine, or entirely on a remote machine or server.

[0109] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0110] To provide interaction with a user, the systems and techniques described herein may 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 trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

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

[0112] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0113] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0114] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A memory management method, characterized in that: Applied to a memory pool corresponding to a database system, the method comprises: When receiving a memory application of an object in a target process, searching a memory management array based on the memory application to obtain a target array index corresponding to a target memory capacity that can satisfy the memory application request; the memory management array is used to manage released memory slices of different memory capacities, the memory slices being slices cut from a reusable first memory block; If a target memory slice is mounted under the target array index, the target memory slice is allocated to the object.

2. The memory management method according to claim 1, characterized in that: The memory capacity of the first memory block requested from the operating system running the database system increases according to the exponential power of 2 of the minimum memory capacity until reaching the maximum memory capacity.

3. The memory management method according to claim 2, characterized in that: The memory capacity of the memory slice managed by the memory management array is an exponential power of 2; The step of searching the memory management array based on the memory application to obtain a target array index corresponding to a target memory capacity that can satisfy the memory application request comprises: If the memory capacity requested by the memory application does not exceed the maximum memory capacity, the requested memory capacity is raised to the power of 2 as the target memory capacity, and the target array index corresponding to the target memory capacity in the memory management array is searched.

4. The memory management method according to claim 1, characterized in that: Also includes: If no target memory slice is mounted under the array index, determining whether there is a first memory block in the memory pool whose memory capacity can satisfy the memory application; If yes, allocating a memory slice of the target memory capacity to the object from the first memory block; If not, apply for a next first memory block from the operating system running the database system, and allocate a target memory slice of the target memory capacity to the object from the next first memory block.

5. The method according to claim 1, characterized in that Also includes: If the memory capacity requested by the memory application exceeds the maximum memory capacity, a second memory block of the requested memory capacity is applied to the operating system running the database system and allocated to the object.

6. The memory management method according to claim 5, characterized in that: The method further comprises: Creating a memory group and a corresponding dictionary for each of the objects generated by each command statement in the target process executed by the database system; Among them, each target memory slice or second memory block in the memory group is connected based on a one-way linked list; the dictionary uses the command identifier of the command statement as a key and the memory address of the target memory slice or second memory block allocated to each object as a value.

7. The memory management method according to claim 6, characterized in that: The method further comprises: receiving a target command identifier of the target command statement sent by the database system after the execution of the target command statement in the target process is completed; Search the dictionary for a memory group corresponding to the target command identifier as a key, release all target memory slices contained in the memory group to the memory pool, and release all second memory blocks contained in the memory group to the operating system; wherein the second memory block is a non-reusable memory.

8. The memory management method according to any one of claims 1 to 7, characterized in that: The first memory blocks existing in the memory pool are connected based on a bidirectional linked list; the method further includes: When the target process ends, all first memory blocks connected to the bidirectional linked list in the memory pool are released to the operating system running the database system.

9. A memory management device, characterized in that: include: An index search module is used to search the memory management array based on the memory application when receiving a memory application of an object in the target process, and obtain a target array index corresponding to a target memory capacity that can satisfy the memory application request; The memory management array is used to manage released memory slices of different memory capacities, wherein the memory slices are slices cut from a reusable first memory block; The first memory allocation module is used to allocate the target memory slice to the object if a target memory slice is mounted under the target array index.

10. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the memory management method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the memory management method according to any one of claims 1 to 8 when executed.

12. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the memory management method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Index management method and index management system for memory database

    CN121301620A