CN109388497B - Memory pool management method, device, equipment and readable storage medium - Google Patents

Memory pool management method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN109388497B
CN109388497B CN201811308495.9A CN201811308495A CN109388497B CN 109388497 B CN109388497 B CN 109388497B CN 201811308495 A CN201811308495 A CN 201811308495A CN 109388497 B CN109388497 B CN 109388497B
Authority
CN
China
Prior art keywords
memory
application program
pool
request
memory pool
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811308495.9A
Other languages
Chinese (zh)
Other versions
CN109388497A (en
Inventor
邹虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201811308495.9A priority Critical patent/CN109388497B/en
Publication of CN109388497A publication Critical patent/CN109388497A/en
Application granted granted Critical
Publication of CN109388497B publication Critical patent/CN109388497B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool

Abstract

The invention discloses a management method, a device, equipment and a computer readable storage medium of a memory pool, comprising the following steps: in response to the memory application of the application program, packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request; judging whether the application program applies for an available memory; if not, the memory request is mounted to a waiting queue of the memory pool, so that when the memory space in the memory pool is released, the memory request is activated and executed, and the application program applies for the available memory. By utilizing the memory pool management method, the device, the equipment and the computer readable storage medium provided by the invention, the thread of the application program cannot be trapped in endless loop query memory under the condition of no memory, the efficiency of a CPU is saved, and the response speed of the application program is improved.

Description

Memory pool management method, device, equipment and readable storage medium
Technical Field
The present invention relates to the field of computer storage technologies, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for managing a memory pool.
Background
In application development, memory is typically required to be applied on the stack for use. For example, a function such as malloc is used for application, and an application program can continue to process by using the internal memory after the application is successful. In general, for a general application program, since an operating system provides virtual memory management on the bottom layer, it is difficult to apply for a memory. However, for some special cases, such as using the memory Pool that is applied for in advance, and in other cases, most of the memory is used by other programs.
In a general method, if calling a function such as malloc to apply for a memory fails, a-1 return code is returned to tell an application program that there is no memory temporarily, and the application program needs to process a scene without memory at this time, wait for a period of time, and then retry. Similar applications need a round-robin function, which is very inefficient for applications requiring high response speed, and frequent rounds also affect the utilization efficiency of the CPU. From the above, it can be seen that how to make the thread of the application program not enter endless loop query memory without memory is a problem to be solved at present.
Disclosure of Invention
The invention aims to provide a memory pool management method, a memory pool management device, memory pool management equipment and a computer readable storage medium, which are used for solving the problems that in the prior art, under the condition of no memory, the thread of an application program can be involved in endless cyclic memory query operation, so that the response speed of the application program is low and the use efficiency of a CPU (Central processing Unit) is low.
In order to solve the above technical problem, the present invention provides a method for managing a memory pool, including: in response to the memory application of the application program, packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request; judging whether the application program applies for an available memory; if not, the memory request is mounted to a waiting queue of the memory pool, so that when the memory space in the memory pool is released, the memory request is activated and executed, and the application program applies for the available memory.
Preferably, the encapsulating the operation of the application program applying for the memory in the preselected memory pool as a memory request includes:
and packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request, and establishing a linked list node in the memory request.
Preferably, if not, the mounting the memory request to the waiting queue of the memory pool includes:
and if the application program does not apply for the available memory, mounting the linked list node of the memory request of the application program on a linked list head pre-established in the memory pool so as to facilitate the application program to enter a silent state.
Preferably, the mounting the memory request to a waiting queue of the memory pool so that the memory request is activated and executed when a memory space in the memory pool is released, so as to apply for an available memory for the application program includes:
mounting a linked list node of the application program in a linked list head of the memory pool, and generating a new available memory when a memory space is released in the memory pool;
judging whether the mounted memory request exists on a linked list head of the memory pool or not;
and if so, activating and executing the memory request so as to apply for the application program to the available memory.
Preferably, the encapsulating, in response to the memory application of the application program, the operation of the application program applying for the memory in the preselected memory pool as a memory request further includes:
and dividing a memory pool used by an application program in a storage system so as to facilitate the application program to apply for a block of memory with a preset size in the memory pool for use.
The invention also provides a management device of the memory pool, which comprises:
the packaging module is used for responding to the memory application of the application program and packaging the operation of the application program for applying the memory in the pre-selected memory pool into a memory request;
the judging module is used for judging whether the application program applies for the available memory;
and the activation module is used for mounting the memory request into a waiting queue of the memory pool if the application program does not apply for the available memory, so that the memory request is activated and executed when the memory space in the memory pool is released, and the application program applies for the available memory.
Preferably, the encapsulation module is specifically configured to:
and packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request, and establishing a linked list node in the memory request.
Preferably, the activation module is specifically configured to:
and if the application program does not apply for the available memory, mounting the linked list node of the memory request of the application program on a linked list head pre-established in the memory pool so as to facilitate the application program to enter a silent state.
The invention also provides a management device of the memory pool, which comprises:
a memory for storing a computer program; and the processor is used for realizing the steps of the management method of the memory pool when executing the computer program.
The present invention also provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-mentioned method for managing a memory pool.
The management method of the memory pool provided by the invention responds to the memory application of the application program, and encapsulates the operation of the application program for applying the memory in the preselected memory pool into a memory request. When the application program does not apply for the available memory, namely the preselected memory pool does not have enough available memory, the memory request is mounted in a waiting queue of the memory pool, so that the application program enters a silent state when the application program does not apply for the memory, and the utilization rate of a CPU (Central processing Unit) is not wasted due to training. And when a new memory space in the memory pool is released, namely available memory exists in the memory pool, activating and executing the memory request to allocate the available memory for the application program. The memory pool management technology provided by the invention modifies the polling mechanism applying the memory in the prior art into the interrupt mechanism, so that the waste of CPU (Central processing Unit) use resources can not be caused when the application program does not apply the memory; the response speed of the application program is improved.
Drawings
In order to more clearly illustrate the embodiments or technical solutions of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
Fig. 1 is a flowchart of a first embodiment of a method for managing a memory pool according to the present invention;
fig. 2 is a flowchart of a method for managing a memory pool according to a second embodiment of the present invention;
fig. 3 is a block diagram of a management apparatus for a memory pool according to an embodiment of the present invention.
Detailed Description
The core of the invention is to provide a management method, a device, equipment and a computer readable storage medium of a memory pool, which saves the efficiency of a CPU and improves the response speed of an application program.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for managing a memory pool according to a first embodiment of the present invention; the specific operation steps are as follows:
step S101: in response to the memory application of the application program, packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request;
dividing a memory pool available for the application program in a storage system in advance; and all the used memories of the application programs are applied for using a fixed-size memory from the memory pool.
In this embodiment, the operation of the application program applying for the memory in the memory pool is encapsulated as a memory request; and establishing a node of a linked list in the memory request. And establishing a head of a linked list in the memory pool.
Step S102: judging whether the application program applies for an available memory;
and when the application program applies for the available memory in the memory pool, no processing is performed.
Step S103: if not, the memory request is mounted to a waiting queue of the memory pool, so that when the memory space in the memory pool is released, the memory request is activated and executed, and the application program applies for the available memory.
And if the application program does not apply for the available memory, mounting the linked list node of the application program on the linked list head of the memory pool. And the application program enters a silent state when the application program can not apply for the memory. After other threads of the program process own tasks, the memory is released, and at this time, the memory pool has new available memory to be allocated, so that the memory request of the application program is excited and executed, and the available memory is allocated for the application program. The management method for the memory pool provided by the embodiment greatly improves the efficiency of applying for the memory and the response speed of the program.
Based on the above embodiments, in this embodiment, when the application program does not apply for an available memory, the linked list node of the application program is mounted in the linked list head of the memory pool. When the memory space in the memory pool is released, generating a new available memory; judging whether the mounted memory request exists on a linked list head of the memory pool or not; if yes, activating and executing the memory request. Referring to fig. 2, fig. 2 is a flowchart illustrating a memory pool management method according to a second embodiment of the present invention. The specific operation steps are as follows:
step S201: in response to the memory application of an application program, packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request, and establishing a linked list node in the memory request;
step S202: judging whether the application program applies for an available memory;
step S203: if the application program does not apply for the available memory, mounting a linked list node of the memory request of the application program on a linked list head pre-established in the memory pool so as to facilitate the application program to enter a silent state;
step S204: when the memory space in the memory pool is released and a new available memory is generated, judging whether the mounted memory request exists on a linked list head of the memory pool;
step S205: and if so, activating and executing the memory request so as to apply for the application program to the available memory.
The method provided by this embodiment stores a linked list for each memory area, and when the memory is insufficient, the request of the application program is hung on the linked list as a memory request. When a new memory is released, the memory module takes a request from the linked list to notify the corresponding application program to continue executing. Therefore, the original round training mechanism is rather modified into an interruption mechanism, and the efficiency of waiting for the memory in the application program is greatly improved. And when available memory exists, the waiting application program can be instantly informed, and the response speed of the program is improved.
Referring to fig. 3, fig. 3 is a block diagram of a management apparatus for a memory pool according to an embodiment of the present invention; the specific device may include:
the encapsulating module 100 is configured to encapsulate, in response to a memory application of an application program, an operation of the application program applying for a memory in a preselected memory pool as a memory request;
a judging module 200, configured to judge whether the application applies for an available memory;
an activation module 300, configured to mount the memory request to a waiting queue of the memory pool if the application program does not apply for an available memory, so that when there is a memory space in the memory pool to be released, the memory request is activated and executed, so as to apply for the application program for the available memory.
The management device of the memory pool in this embodiment is used to implement the management method of the memory pool, and therefore, specific embodiments in the management device of the memory pool may refer to the foregoing embodiment parts of the management method of the memory pool, for example, the encapsulation module 100, the judgment module 200, and the activation module 300, which are respectively used to implement steps S101, S102, and S103 in the management method of the memory pool.
A specific embodiment of the present invention further provides a device for managing a memory pool, including: a memory for storing a computer program; and the processor is used for realizing the steps of the management method of the memory pool when executing the computer program.
The specific embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for managing a memory pool are implemented.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The method, the apparatus, the device and the computer readable storage medium for managing the memory pool provided by the present invention are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (6)

1. A management method of a memory pool is characterized by comprising the following steps:
in response to the memory application of the application program, packaging the operation of the application program for applying for the memory in the preselected memory pool into a memory request;
judging whether the application program applies for an available memory;
if not, mounting the memory request into a waiting queue of the memory pool, so that when a memory space in the memory pool is released, activating and executing the memory request, and applying for an available memory for the application program;
the encapsulating of the operation of the application program for applying for the memory in the preselected memory pool as a memory request comprises:
packaging the operation of the application program for applying for the memory in the pre-selection memory pool into a memory request, and establishing a linked list node in the memory request;
if not, the mounting the memory request to the waiting queue of the memory pool comprises:
and if the application program does not apply for the available memory, mounting the linked list node of the memory request of the application program on a linked list head pre-established in the memory pool so as to facilitate the application program to enter a silent state.
2. The method of claim 1, wherein the mounting the memory request to a wait queue of the memory pool, such that when memory space in the memory pool is released, activating and executing the memory request to apply for available memory for the application comprises:
mounting a linked list node of the application program in a linked list head of the memory pool, and generating a new available memory when a memory space is released in the memory pool;
judging whether the mounted memory request exists on a linked list head of the memory pool or not;
and if so, activating and executing the memory request so as to apply for the application program to the available memory.
3. The method of claim 1, wherein said encapsulating an operation of an application program applying for memory in a preselected memory pool as a memory request in response to the application program's memory application further comprises:
and dividing a memory pool used by an application program in a storage system so as to facilitate the application program to apply for a block of memory with a preset size in the memory pool for use.
4. An apparatus for managing a memory pool, comprising:
the packaging module is used for responding to the memory application of the application program and packaging the operation of the application program for applying the memory in the pre-selected memory pool into a memory request;
the judging module is used for judging whether the application program applies for the available memory;
the activation module is used for mounting the memory request into a waiting queue of the memory pool if the application program does not apply for the available memory, so that the memory request is activated and executed when the memory space in the memory pool is released, and the application program applies for the available memory;
the encapsulation module is specifically configured to:
packaging the operation of the application program for applying for the memory in the pre-selection memory pool into a memory request, and establishing a linked list node in the memory request;
the activation module is specifically configured to:
and if the application program does not apply for the available memory, mounting the linked list node of the memory request of the application program on a linked list head pre-established in the memory pool so as to facilitate the application program to enter a silent state.
5. A management apparatus for a memory pool, comprising:
a memory for storing a computer program;
a processor for implementing the steps of a method for managing a memory pool according to any one of claims 1 to 3 when executing said computer program.
6. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of a method for managing memory pools according to any one of claims 1 to 3.
CN201811308495.9A 2018-11-05 2018-11-05 Memory pool management method, device, equipment and readable storage medium Active CN109388497B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811308495.9A CN109388497B (en) 2018-11-05 2018-11-05 Memory pool management method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811308495.9A CN109388497B (en) 2018-11-05 2018-11-05 Memory pool management method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN109388497A CN109388497A (en) 2019-02-26
CN109388497B true CN109388497B (en) 2021-08-31

Family

ID=65428415

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811308495.9A Active CN109388497B (en) 2018-11-05 2018-11-05 Memory pool management method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN109388497B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111367671B (en) * 2020-03-03 2023-12-29 深信服科技股份有限公司 Memory allocation method, device, equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104182350A (en) * 2013-05-28 2014-12-03 中国银联股份有限公司 Memory management method and device aiming at application containing multiple processes
CN104881324A (en) * 2014-09-28 2015-09-02 北京匡恩网络科技有限责任公司 Memory management method in multi-thread environment
CN105988876A (en) * 2015-03-27 2016-10-05 杭州迪普科技有限公司 Memory allocation method and apparatus
US9471378B2 (en) * 2012-05-31 2016-10-18 Apple Inc. Adaptive resource management of a data processing system
CN108304259A (en) * 2017-01-11 2018-07-20 中兴通讯股份有限公司 EMS memory management process and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9471378B2 (en) * 2012-05-31 2016-10-18 Apple Inc. Adaptive resource management of a data processing system
CN104182350A (en) * 2013-05-28 2014-12-03 中国银联股份有限公司 Memory management method and device aiming at application containing multiple processes
CN104881324A (en) * 2014-09-28 2015-09-02 北京匡恩网络科技有限责任公司 Memory management method in multi-thread environment
CN105988876A (en) * 2015-03-27 2016-10-05 杭州迪普科技有限公司 Memory allocation method and apparatus
CN108304259A (en) * 2017-01-11 2018-07-20 中兴通讯股份有限公司 EMS memory management process and system

Also Published As

Publication number Publication date
CN109388497A (en) 2019-02-26

Similar Documents

Publication Publication Date Title
CN107526624B (en) Intelligent contract execution engine based on Java virtual machine
CN106250434B (en) Load the method and device of webpage
CA3000422C (en) Workflow service using state transfer
CN108334396B (en) Data processing method and device, and resource group creation method and device
US9231995B2 (en) System and method for providing asynchrony in web services
CN107479981B (en) Processing method and device for realizing synchronous call based on asynchronous call
CN103605568A (en) Multithread management method and device
CN107818012B (en) Data processing method and device and electronic equipment
CN111104227A (en) Resource control method and device of K8s platform and related components
CN103761474A (en) Method and device for monitoring execution time of monitoring method
CN109388497B (en) Memory pool management method, device, equipment and readable storage medium
CN104917817A (en) Client side and data communication method
CN105354079B (en) The method for improving Installed System Memory utilization rate
KR102485288B1 (en) Controller for vehicle and operating system scheduling method thereof
CN111198689B (en) Code execution method, device and computer readable storage medium
CN115344371A (en) Interface calling method and device, storage medium and computer equipment
CN113687931A (en) Task processing method, system and device
CN106997304B (en) Input and output event processing method and device
WO2018040271A1 (en) Thread processor and thread processing method
CN113032128A (en) Multitask control method and device, electronic equipment and storage medium
CN113704355A (en) Data synchronization method, electronic device and storage medium
CN112181640A (en) Task processing method and device
CN105488169A (en) Multi-process file conversion method and apparatus
CN112114862B (en) Method and device for concurrency processing of spring boot instances
US9304841B2 (en) Dispatcher framework to provide inter-application communication

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant