Memory management method and device, computer equipment, storage medium and program product
By detecting the free memory blocks managed by the target application's idle linked list, determining and decoding the mapping relationship between user storage space and the kernel's physical memory pages, the problems of waste caused by excessive memory wholesale and failure of memory allocation between processes are solved, and timely release and efficient management of memory are achieved.
Patent Information
- Application Number
- CN202411667354.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-04
AI Technical Summary
In existing memory management technologies, too much memory wholesale but too little retail, resulting in a large amount of memory waste, or memory hoarding in process A causes memory allocation to process B to fail.
By detecting the free memory block managed by the free linked list of the target application, it is determined whether the mapping relationship between the user's storage space and the kernel's physical memory page in the target memory block has been released. If it is not released, the starting address and space length will be determined, and the kernel will be controlled to unplug the mapping relationship to free memory.
It realizes the timely release of free memory, avoids memory waste and memory allocation failures between processes, and improves the efficiency of memory management.
Smart Images

Figure CN119557094A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of memory management technology, and in particular to a memory management method, apparatus, computer equipment, storage medium and program product. Background Art
[0002] In the process of accelerating the construction of digital economy, it is particularly important to improve software development technology. Software development is mainly realized through computers, and mainly consists of hardware, operating system, glibc software package and application program (business code). Among them, the application program uses the functions provided by the operating system through the glibc software package.
[0003] Memory management is an important function of the Glibc software package. The Glibc software package manages memory by wholesale memory from the operating system and then retailing it to applications. However, if too much memory is wholesaled and too little is retailed, a large amount of memory will be stored in glibc, resulting in a large amount of memory waste. Alternatively, if glibc in process A stores a large amount of memory, glibc in process B will fail to wholesale memory from the operating system. Therefore, good memory management is crucial to improving software development technology. Summary of the invention
[0004] Based on this, it is necessary to provide a memory management method, apparatus, computer equipment, storage medium and program product to address the above technical problems, which can release free memory in a timely manner.
[0005] In a first aspect, the present application provides a memory management method, the method comprising:
[0006] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0007] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0008] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0009] In one embodiment, detecting that a target memory block exists in a free memory block managed by a free linked list of a target application includes:
[0010] A memory reclaim message initiated by the kernel is received, and it is detected that a target memory block exists in the free memory blocks managed by the free list of the target application.
[0011] In one embodiment, determining a state of releasing a mapping relationship between a user storage space in a target memory block and a corresponding physical memory page in a kernel includes:
[0012] Obtain a mapping release identifier associated with the target memory block; and determine the mapping release status between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier.
[0013] In one embodiment, determining the mapping release state between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier includes:
[0014] When the mapping release identifier is the first identifier, the mapping relationship release state is determined to be not released; wherein the first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is not released; when the mapping release identifier is the second identifier, the mapping relationship release state is determined to be released; wherein the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is released.
[0015] In one embodiment, it includes:
[0016] When it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set as the second identifier.
[0017] In one of the embodiments, the physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space.
[0018] In a second aspect, the present application further provides a memory management device, the device comprising:
[0019] a state determination module, for determining, when detecting that a target memory block exists in the free memory blocks managed by the free linked list of the target application, a state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0020] A space determination module, used for determining the starting address and space length of the user storage space when the mapping relationship release state is not released;
[0021] The relationship release module is used to control the kernel to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and space length.
[0022] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0023] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0024] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0025] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0026] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0027] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0028] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0029] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0030] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0031] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0032] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0033] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0034] The above-mentioned memory management method, device, computer equipment, storage medium and program product detect the free memory blocks managed by the free linked list of the target application, so as to further determine the release state of the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel when the target memory block is detected, thereby realizing the detection of the free memory blocks and timely releasing the free memory; further, when the mapping relationship release state is not released, the starting address and space length of the user storage space are determined, providing a data basis for determining the physical memory page corresponding to the target memory block; finally, by controlling the kernel to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and space length, the release of the free memory is realized. This scheme lays the foundation for discovering the target memory block by detecting the free memory blocks managed by the free linked list; furthermore, by determining the starting address and space length of the user storage space in the target memory block, a basis is provided for releasing the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, and finally the release of the memory is realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0036] FIG1 is an application environment diagram of a memory management method provided in an embodiment of the present application;
[0037] FIG2 is a schematic diagram of a memory management process provided in an embodiment of the present application;
[0038] FIG3 is a schematic diagram of a flow chart of memory management in a memory alarm situation provided in an embodiment of the present application;
[0039] FIG4 is a schematic diagram of a process for determining a mapping relationship release state provided in an embodiment of the present application;
[0040] FIG5 is a structural block diagram of a memory management device provided in an embodiment of the present application;
[0041] FIG6 is a structural block diagram of another memory management device provided in an embodiment of the present application;
[0042] FIG. 7 is an internal structure diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] The memory management method provided in the embodiment of the present application can be applied to the application environment as shown in Figure 1. Among them, each target application has a corresponding memory monitoring module, and the target application and the memory monitoring module communicate with the kernel through instructions. Multiple target applications can be integrated on a personal computer at the same time, and the corresponding kernel is the kernel corresponding to the personal computer; wherein, the device integrating the target application is not limited to a personal computer, but can also be a laptop computer, a smart phone, a tablet computer, a portable wearable device or an Internet of Things device, and the Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart car-mounted device, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The kernel can be implemented with an independent server or a server cluster consisting of multiple servers.
[0045] In an exemplary embodiment, as shown in FIG. 2 , a memory management method is provided, which is described by taking the method applied to a memory monitoring module in any target application in FIG. 1 as an example, and may include the following steps:
[0046] S201, when it is detected that a target memory block exists in the free memory blocks managed by the free linked list of the target application, determining a release state of the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel.
[0047] Among them, the free list can be used to centrally manage free memory blocks; the memory block can represent the memory block in the virtual memory space, including user storage space and management storage space, the user storage space can be used to store user data, that is, relevant data of the target application, and the management storage space can be used to store relevant data of the memory block; the storage capacity of the user storage space in the target memory block is greater than the set threshold; the physical memory page can represent the actual physical memory block; the mapping relationship release status may include but is not limited to released and not released.
[0048] Exemplarily, the memory monitoring module can scan or query the free list of the target application in real time or periodically to promptly discover the existence of the target memory block in the free memory block; further, after monitoring the existence of the target memory block in the free memory block managed by the free list of the target application, the page table or virtual memory area structure that maintains the mapping relationship between the user storage space and the physical memory page can be queried based on the user storage space in the target memory block to determine whether the user storage space is mapped to a physical memory page and whether the mapping relationship is valid, etc., and finally determine the release status of the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel.
[0049] S202: When the mapping relationship release state is not released, determine the start address and space length of the user storage space.
[0050] It should be noted that a memory block is a continuous address space region in a virtual memory space. Therefore, by determining the starting address and space length of the user storage space in the target memory block, the address space region corresponding to the user storage space can be determined.
[0051] Exemplarily, when the mapping relationship release state is not released, the starting address and space length of the user storage space can be determined based on the data of each field (such as fd and bk fields) in the target memory block. Optionally, the virtual address (i.e., the starting address) of the user storage space can be directly obtained, and the space length can be determined by subtracting the size of the management storage space from the size of the target memory block.
[0052] S203, controlling the kernel to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0053] Exemplarily, based on the starting address and space length, the kernel can be notified through instructions to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel to release the relevant physical memory page; further, after the mapping relationship is released, the cache content can be refreshed to update the page table or virtual memory area structure that maintains the mapping relationship.
[0054] It should be noted that the mapping relationship is released, but the virtual memory space corresponding to the target application is not deleted. Therefore, when the target application accesses the target memory block next time, a page fault exception will occur. At this time, the kernel will re-apply for physical memory and re-establish the page table mapping, and then the target application can access the memory normally. That is, the kernel allocates memory to the target application on demand, which can be completely transparent to the target application.
[0055] The above-mentioned memory management method detects the free memory blocks managed by the free linked list of the target application, so as to further determine the release state of the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel when the target memory block is detected, thereby realizing the detection of the free memory blocks and timely releasing the free memory; further, when the mapping relationship release state is not released, the starting address and space length of the user storage space are determined, providing a data basis for determining the physical memory page corresponding to the target memory block; finally, by controlling the kernel to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and space length, the release of the free memory is realized. This scheme lays the foundation for discovering the target memory block by detecting the free memory blocks managed by the free linked list; furthermore, by determining the starting address and space length of the user storage space in the target memory block, a basis is provided for releasing the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, and finally the release of the memory is realized.
[0056] On the basis of the above-mentioned embodiments, the embodiment of the present application further explains the detailed process of the memory management method. As shown in Figure 3, when the target application A detects the kernel memory alarm (i.e., step A1), the bins (i.e., the free list for managing free memory blocks) in the memory allocation area of the target application A are scanned. If the target memory block (i.e., free_chunk_B in Figure 3) is scanned, the page table mapping corresponding to the target memory block is sent to the kernel to release (i.e., step A2); further, after releasing the page table mapping corresponding to the target memory block, the memory is returned to the memory management system (i.e., step A3); further, when the target application B needs to apply for memory through the malloc instruction or function (i.e., step B1), it can apply for physical memory from the memory management system (i.e., step B2). If there is enough allocable memory in the memory management system, the applied memory is allocated to the target application B (i.e., step B3), and further, by establishing a page table mapping between the virtual memory address of the target application B and the actual physical address in the kernel (i.e., step B4), the memory is allocated to the target application B.
[0057] The embodiment of the present application also explains the above embodiment S201 in detail. Specifically, the embodiment of the present application also involves a process of detecting that a target memory block exists in the free memory blocks managed by the free list of the target application, specifically including: receiving a memory reclaim message initiated by the kernel, and detecting that a target memory block exists in the free memory blocks managed by the free list of the target application.
[0058] It should be noted that when the memory allocatable in the kernel is less than the preset allocation threshold or the memory allocatable in the kernel cannot satisfy the memory requested by the process, a memory recovery message can be sent to the memory monitoring module to instruct the memory monitoring module to scan the free memory blocks.
[0059] Exemplarily, after the memory monitoring module receives the memory reclaiming message sent by the kernel, the free memory blocks managed by the free list can be detected. If it is detected that the target memory block exists in the free memory blocks managed by the free list, the relevant operations of releasing the mapping relationship can be performed to release the memory; if the target memory block is not detected in the free memory blocks managed by the free list, a message "there is no releasable memory" can be sent to the kernel to respond to the memory reclaiming message.
[0060] In the embodiment of the present application, by introducing memory reclaim messages, a solution is provided for coping with memory shortage, and memory can also be managed in a timely manner.
[0061] Based on the above embodiment, the embodiment of the present application explains the above embodiment S201 in detail. Specifically, the embodiment of the present application involves a process of determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel, as shown in FIG4 , and specifically includes the following steps:
[0062] S401, obtaining a mapping undo identifier associated with a target memory block.
[0063] The mapping undo identifier may be used to characterize the mapping undo status of the memory block, that is, the mapping status of the target memory block may be judged according to the mapping undo identifier.
[0064] Exemplarily, the data corresponding to the mapping release field of the target memory block may be directly obtained to obtain the mapping release identifier associated with the target memory block.
[0065] S402: Determine a mapping release state between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier.
[0066] In one achievable manner, when the mapping release identifier is the first identifier, the mapping relationship release state is determined to be not released; when the mapping release identifier is the second identifier, the mapping relationship release state is determined to be released.
[0067] The first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel has not been released; the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel has been released.
[0068] Exemplarily, the release status of the mapping relationship can be determined by an identifier. For example, the first identifier can be 0. When the mapping release identifier is 0, it indicates that the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel has not been released, and the mapping relationship is still valid, that is, it still occupies physical memory; the second identifier can be 1. When the mapping release identifier is 1, it indicates that the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel has been released, and the mapping relationship has become invalid, that is, it does not occupy physical memory.
[0069] Further, when it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set as the second identifier.
[0070] As shown in the above example, when the mapping release identifier is the first identifier (i.e. 0), the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel is released; further, after the mapping relationship is released, the mapping release identifier associated with the target memory block can be adjusted to the second identifier, i.e. 1.
[0071] It should be noted that the physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space. That is, when performing the relationship release operation, the mapping relationship between the user storage space for storing user data in the target memory block and the physical memory page corresponding to the user storage space in the kernel is released, while the mapping relationship between the management storage space for storing management data in the target memory block and the physical memory page corresponding to the management storage space in the kernel is retained.
[0072] Another possible implementation method is to input the mapping release identifier into a state determination model, which analyzes the mapping release identifier and determines the mapping release state between the user storage space in the target memory block and the corresponding physical memory page in the kernel.
[0073] In the embodiment of the present application, by introducing a mapping release identifier, it provides convenience for determining the mapping release status and improves the efficiency of memory management.
[0074] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0075] Based on the same inventive concept, the embodiment of the present application also provides a memory management device for implementing the memory management method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more memory management device embodiments provided below can refer to the limitations on the memory management method above, and will not be repeated here.
[0076] In an exemplary embodiment, as shown in FIG5 , a memory management device 1 is provided, comprising: a state determination module 10, a space determination module 20 and a relationship removal module 30, wherein:
[0077] The state determination module 10 is used to determine the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel when detecting that the target memory block exists in the free memory blocks managed by the free list of the target application; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data.
[0078] The space determination module 20 is used to determine the starting address and space length of the user storage space when the mapping relationship release state is not released.
[0079] The relationship release module 30 is used to control the kernel to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0080] In one embodiment, the state determination module 10 is specifically used for:
[0081] A memory reclaim message initiated by the kernel is received, and it is detected that a target memory block exists in the free memory blocks managed by the free list of the target application.
[0082] In one embodiment, as shown in FIG6 , the state determination module 10 specifically further includes:
[0083] The first acquisition unit 11 is used to acquire a mapping release identifier associated with a target memory block.
[0084] The first determining unit 12 is used to determine the mapping release state between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier.
[0085] In one embodiment, the first determining unit 12 is specifically configured to:
[0086] When the mapping release identifier is the first identifier, the mapping relationship release state is determined to be not released; wherein the first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is not released; when the mapping release identifier is the second identifier, the mapping relationship release state is determined to be released; wherein the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is released.
[0087] In one embodiment, the first determining unit 12 is further configured to:
[0088] When it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set as the second identifier.
[0089] In one embodiment, the physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space.
[0090] Each module in the above memory management device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0091] In an exemplary embodiment, a computer device is provided, which may be a device integrating multiple target applications, and the specific implementation process of the memory monitoring module in the target application may be executed by the computer device; wherein, the computer device may be a server, and its internal structure diagram may be shown in FIG7. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. wherein, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. wherein, the processor of the computer device is used to provide computing and control capabilities. the memory of the computer device includes a non-volatile storage medium and an internal memory. the non-volatile storage medium stores an operating system, a computer program and a database. the internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. the database of the computer device is used to store memory data. the input / output interface of the computer device is used to exchange information between the processor and an external device. the communication interface of the computer device is used to communicate with an external terminal through a network connection. the computer program is executed by the processor to implement a memory management method.
[0092] Those skilled in the art will understand that the structure shown in FIG. 7 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0093] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0094] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0095] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0096] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0097] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0098] A memory reclaim message initiated by the kernel is received, and it is detected that a target memory block exists in the free memory blocks managed by the free list of the target application.
[0099] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0100] Obtain a mapping release identifier associated with the target memory block; and determine the mapping release status between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier.
[0101] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0102] When the mapping release identifier is the first identifier, the mapping relationship release state is determined to be not released; wherein the first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is not released; when the mapping release identifier is the second identifier, the mapping relationship release state is determined to be released; wherein the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is released.
[0103] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0104] When it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set as the second identifier.
[0105] In one embodiment, the physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space.
[0106] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0107] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0108] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0109] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0110] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0111] A memory reclaim message initiated by the kernel is received, and it is detected that a target memory block exists in the free memory blocks managed by the free list of the target application.
[0112] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0113] Obtain a mapping release identifier associated with the target memory block; and determine the mapping release status between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier.
[0114] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0115] When the mapping release identifier is the first identifier, the mapping relationship release state is determined to be not released; wherein the first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is not released; when the mapping release identifier is the second identifier, the mapping relationship release state is determined to be released; wherein the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is released.
[0116] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0117] When it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set as the second identifier.
[0118] In one embodiment, the physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space.
[0119] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0120] When it is detected that the target memory block exists in the free memory blocks managed by the free linked list of the target application, determining the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data;
[0121] When the mapping relationship release state is not released, determining the starting address and space length of the user storage space;
[0122] The control kernel releases the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
[0123] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0124] A memory reclaim message initiated by the kernel is received, and it is detected that a target memory block exists in the free memory blocks managed by the free list of the target application.
[0125] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0126] Obtain a mapping release identifier associated with the target memory block; and determine the mapping release status between the user storage space in the target memory block and the corresponding physical memory page in the kernel according to the mapping release identifier.
[0127] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0128] When the mapping release identifier is the first identifier, the mapping relationship release state is determined to be not released; wherein the first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is not released; when the mapping release identifier is the second identifier, the mapping relationship release state is determined to be released; wherein the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is released.
[0129] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0130] When it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set as the second identifier.
[0131] In one embodiment, the physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space.
[0132] It should be noted that the information (including but not limited to application information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0133] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0134] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0135] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A memory management method, characterized in that: The method comprises: When it is detected that a target memory block exists in the free memory blocks managed by the free linked list of the target application, determining a state in which a mapping relationship between a user storage space in the target memory block and a corresponding physical memory page in the kernel is released; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data; In a case where the mapping relationship release state is not released, determining a starting address and a space length of the user storage space; The kernel is controlled to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
2. The method according to claim 1, characterized in that The detecting that the target memory block exists in the free memory blocks managed by the free linked list of the target application includes: A memory reclaiming message initiated by the kernel is received, and it is detected that a target memory block exists in the free memory blocks managed by the free linked list of the target application.
3. The method according to claim 1, characterized in that The determining of the state of releasing the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel includes: Obtaining a mapping undo identifier associated with the target memory block; According to the mapping release identifier, a mapping relationship release state between the user storage space in the target memory block and the corresponding physical memory page in the kernel is determined.
4. The method according to claim 3, characterized in that The determining, according to the mapping release identifier, a mapping release state between the user storage space in the target memory block and the corresponding physical memory page in the kernel comprises: In the case where the mapping release identifier is a first identifier, determining that the mapping relationship release state is not released; wherein the first identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is not released; In the case where the mapping release identifier is a second identifier, the mapping relationship release state is determined to be released; wherein the second identifier is used to indicate that the mapping relationship between the user storage space and the corresponding physical memory page in the kernel is released.
5. The method according to claim 4, characterized in that The method further comprises: In a case where it is determined that the kernel has released the mapping relationship between the user storage space and the corresponding physical memory page in the kernel, the mapping release identifier is set to the second identifier.
6. The method according to any one of claims 1 to 5, characterized in that: The physical memory page corresponding to the management storage space for storing management data in the target memory block is different from the physical memory page corresponding to the user storage space.
7. A memory management device, characterized in that: The device comprises: a state determination module, configured to determine, when detecting that a target memory block exists in the free memory blocks managed by the free linked list of the target application, a state in which the mapping relationship between the user storage space in the target memory block and the corresponding physical memory page in the kernel is released; wherein the storage capacity of the user storage space in the target memory block is greater than a set threshold, and the user storage space is used to store user data; A space determination module, used for determining the starting address and space length of the user storage space when the mapping relationship release state is not released; The relationship release module is used to control the kernel to release the mapping relationship between the user storage space and the corresponding physical memory page in the kernel according to the starting address and the space length.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.