CN112799832A - Memory allocation control method, device, equipment and storage medium - Google Patents

Memory allocation control method, device, equipment and storage medium Download PDF

Info

Publication number
CN112799832A
CN112799832A CN202110069958.6A CN202110069958A CN112799832A CN 112799832 A CN112799832 A CN 112799832A CN 202110069958 A CN202110069958 A CN 202110069958A CN 112799832 A CN112799832 A CN 112799832A
Authority
CN
China
Prior art keywords
memory
application
size
idle
memory block
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.)
Pending
Application number
CN202110069958.6A
Other languages
Chinese (zh)
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.)
Hangzhou Hollysys Automation Co Ltd
Original Assignee
Hangzhou Hollysys Automation 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 Hangzhou Hollysys Automation Co Ltd filed Critical Hangzhou Hollysys Automation Co Ltd
Priority to CN202110069958.6A priority Critical patent/CN112799832A/en
Publication of CN112799832A publication Critical patent/CN112799832A/en
Pending legal-status Critical Current

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

The application discloses a memory allocation control method, which comprises the following steps: receiving a memory application sent by an application party, wherein the memory application carries information of the size of the applied memory; traversing the free memory block list, and searching for a free memory block with the total memory size same as the size of the application memory; and allocating the memory to the application party in the searched idle memory block. By applying the technical scheme provided by the application, the generation of memory fragments can be avoided as much as possible, and the problem of resource shortage is relieved. The application also discloses a memory allocation control device, equipment and a storage medium, and the memory allocation control device, the equipment and the storage medium have corresponding technical effects.

Description

Memory allocation control method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer application technologies, and in particular, to a method, an apparatus, a device, and a storage medium for controlling memory allocation.
Background
With the rapid development of computer technology, the development speed of industrial field automation and intellectualization is also faster and faster, and the service configuration puts higher requirements on configuration software such as DCS (Distributed Control System), for example, the requirements on functions such as real-time debugging and incremental downloading are stronger. Frequent operations of logic modification, increment and deletion of variables, increment and downloading and the like need to be continuously applied for the memory.
At present, when the memory allocation of a control system is carried out, a free memory block with the total memory size larger than the applied memory size is randomly found out for carrying out the memory allocation, so that memory fragments are easy to generate, and the problem of resource shortage is aggravated by the increase of the memory fragments.
Therefore, how to perform memory allocation control and minimize the generation of memory fragments is a technical problem that needs to be solved by those skilled in the art.
Disclosure of Invention
The application aims to provide a memory allocation control method, a memory allocation control device, memory allocation control equipment and a memory medium, so that memory fragments are reduced as much as possible, and the problem of resource shortage is relieved.
In order to solve the technical problem, the application provides the following technical scheme:
a memory allocation control method comprises the following steps:
receiving a memory application sent by an application party, wherein the memory application carries information of the size of the applied memory;
traversing the free memory block list, and searching for a free memory block with the total memory size same as the size of the application memory;
and allocating the memory to the application party in the searched idle memory block.
In a specific embodiment of the present application, after traversing the free memory block list, the method further includes:
if the idle memory blocks with the total memory size same as the application memory size are not found, determining a set to be allocated according to the application memory size, wherein the ratio of the total memory size of each idle memory block in the set to be allocated to the application memory size is larger than a set proportion threshold;
and selecting an idle memory block in the set to be allocated, and allocating a memory to the applicant.
In a specific embodiment of the present application, the selecting one free memory block in the set to be allocated, and allocating a memory to the applicant includes:
and selecting the idle memory block with the maximum total memory size in the set to be allocated, and allocating the memory to the applicant.
In one embodiment of the present application, the method further includes:
obtaining a recovered memory block;
determining whether memory blocks with continuous addresses exist in the idle memory block list or not according to the addresses of the recovered memory blocks;
and if so, merging the memory blocks with continuous addresses.
In a specific embodiment of the present application, the free memory blocks in the free memory block list are arranged according to a front-back order of addresses.
In a specific embodiment of the present application, the requesting party is a structure object, and the memory application carries information of an application memory size of each field included in the structure object;
the searching for the idle memory block with the total memory size same as the application memory size includes:
searching for an idle memory block with the total memory size same as the applied memory size of the current field aiming at each field contained in the structure object;
correspondingly, the allocating the found idle memory blocks to the applicant includes:
and aiming at each field contained in the structure body object, allocating the memory of the searched idle memory block with the total memory size being the same as the applied memory size of the current field to the current field.
A memory allocation control apparatus comprising:
the memory application receiving module is used for receiving a memory application sent by an application party, wherein the memory application carries information of the size of the applied memory;
the idle memory block searching module is used for traversing the idle memory block list and searching the idle memory blocks with the total memory size same as the application memory size;
and the memory allocation module is used for allocating the memory to the applicant in the searched idle memory blocks.
In a specific embodiment of the present application, the memory allocation module is further configured to:
after traversing the free memory block list, if no free memory block with the same total memory size as the application memory size is found, determining a set to be allocated according to the application memory size, wherein the ratio of the total memory size of each free memory block in the set to be allocated to the application memory size is larger than a set proportion threshold;
and selecting an idle memory block in the set to be allocated, and allocating a memory to the applicant.
A memory allocation control device comprising:
a memory for storing a computer program;
a processor, configured to implement the steps of the memory allocation control method according to any one of the above when the computer program is executed.
A computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the memory allocation control method of any one of the above.
By applying the technical scheme provided by the embodiment of the application, when a memory application sent by an applicant is received, the free memory block list is traversed, the free memory blocks with the total memory size same as that of the applied memory are searched, and the memory is allocated to the applicant in the searched free memory blocks, so that the generation of memory fragments can be avoided as much as possible, and the problem of resource shortage is solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart illustrating an implementation of a memory allocation control method according to an embodiment of the present disclosure;
FIG. 2 is a diagram illustrating a free memory block list according to an embodiment of the present application;
FIG. 3 is another diagram illustrating a free memory block list according to an embodiment of the present application;
FIG. 4 is another diagram illustrating a free memory block list according to an embodiment of the present application;
fig. 5 is a schematic diagram of a free memory block list subjected to recovery and merging processing in the embodiment of the present application;
FIG. 6 is a diagram illustrating a free memory block list without performing a recycle merge process in the embodiment of the present application;
fig. 7 is a schematic structural diagram of a memory allocation control apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a memory allocation control device in an embodiment of the present application.
Detailed Description
The core of the application is to provide a memory allocation control method, and the generation of memory fragments is reduced as much as possible by controlling the memory allocation. In fact, the memory fragments exist not only in the control system, but also in the upper computer. The upper computer is logic configuration software of the control system and mainly writes and configures control logic.
In the application, after a memory application sent by an applicant is received, the free memory block list is traversed, free memory blocks with the total memory size same as that of the applied memory are searched, and memories are allocated to the applicant in the searched free memory blocks. That is, the just available free memory blocks are searched for memory allocation, so that the generation of memory fragments can be reduced as much as possible, and the problem of resource shortage is solved.
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. 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 application.
Referring to fig. 1, an implementation flowchart of a memory allocation method of a control system provided in an embodiment of the present application is shown, where the method may include the following steps:
s110: and receiving the memory application sent by the application party.
The memory application carries information of the applied memory size.
In the embodiment of the present application, the application party may be any party having a memory application requirement, such as a service party, a control party, and the like. When the memory application requirement exists, the application party can send out a corresponding memory application, and the information of the memory size can be carried in the memory application.
And under the condition of receiving the memory application sent by the applicant, continuously executing the operation of the subsequent step.
S120: and traversing the free memory block list, and searching the free memory blocks with the total memory size same as the size of the applied memory.
In practical application, the free memory blocks may be managed in a form of a list, where the free memory block list may include all current free memory blocks, and total memory sizes of different free memory blocks may be the same or different. As shown in fig. 2, the free memory block list includes four free memory blocks, and the total memory size is: 6 bytes, 8 bytes, 2 bytes, and 4 bytes.
When a memory application sent by an application party is received, the free memory block list can be traversed, the total memory size of each free memory block in the free memory block list is checked one by one, and the free memory blocks with the same total memory size as the applied memory size are searched. If the memory block is found, the operation of step S130 is continuously executed, and if the memory block is not found, the memory allocation may be performed through other manners, for example, randomly finding a free memory block whose total memory size is larger than the application memory size.
S130: and allocating the memory to the application party in the searched idle memory block.
And traversing the free memory block list, and if the free memory blocks with the total memory size same as the size of the application memory can be found, allocating the memory to the application party in the found free memory blocks. If there are multiple idle memory blocks with the same total memory size as the applied memory size, one of the idle memory blocks can be selected for memory allocation.
For example, if the size of the application memory is 4 bytes, the free memory block with the total memory size of 4 bytes can be found in the free memory block list shown in fig. 2. If memory allocation is performed by traversing the idle memory block list and traversing the first idle memory block with the total memory size of 6 bytes, 2-byte memory fragments are generated after the memory allocation is performed. By applying the scheme, the idle memory blocks with the total memory size same as the application memory size are searched, and memory allocation is carried out, so that memory fragments are not brought.
By applying the method provided by the embodiment of the application, when the memory application sent by the applicant is received, the free memory block list is traversed, the free memory blocks with the total memory size same as that of the applied memory are searched, and the memory is allocated to the applicant in the searched free memory blocks, so that the generation of memory fragments can be avoided as much as possible, and the problem of resource shortage is solved.
In an embodiment of the present application, after traversing the free memory block list, the method may further include the following steps:
the method comprises the following steps: if the idle memory blocks with the same total memory size as the application memory size are not found, determining a set to be allocated according to the application memory size, wherein the ratio of the total memory size of each idle memory block in the set to be allocated to the application memory size is larger than a set proportion threshold;
step two: and selecting an idle memory block in the set to be allocated, and allocating the memory to the application party.
For convenience of description, the above two steps are combined for illustration.
In the embodiment of the present application, when a memory application sent by an applicant is received, the free memory block list is traversed, and the traversal is completed, and if a free memory block having a total memory size that is the same as that of the application memory is not found, it is indicated that no free memory block that can be used just exists in the current free memory block list. In this case, according to the size of the application memory, the idle memory blocks, of which the ratio of the total memory size to the size of the application memory is greater than the set proportion threshold, may be searched in the idle memory block list to form a set to be allocated.
A proportional threshold may be preset, and the proportional threshold is greater than 1, such as 1.5, 2, etc. For an idle memory block, the larger the ratio of the total memory size to the applied memory size is, the larger the remaining memory size is after the memory is allocated to the application party in the idle memory block, the less memory fragments are generated.
The determined to-be-allocated set may include a plurality of idle memory blocks, and one idle memory block may be selected from the to-be-allocated set to allocate a memory to the applicant. Such as randomly selecting a free memory block.
In a specific embodiment of the present application, a free memory block with the largest total memory size may be selected from the to-be-allocated set, and a memory may be allocated to the applicant.
The ratio of the total memory size of each idle memory block in the to-be-allocated set to the application memory size is greater than a set proportion threshold, and the idle memory block with the largest total memory size can be selected from the to-be-allocated set and allocated to the application party.
For example, if the size of the application memory is 4 bytes and the ratio threshold is 1, in the free memory block list shown in fig. 3, a free memory block with a total memory size of 4 bytes is not found, and the set to be allocated determined according to the size of the application memory includes: free memory blocks with a total memory size of 6 bytes and free memory blocks with a total memory size of 8 bytes. The free memory block with the maximum total memory size, that is, the total memory size is 8 bytes, can be selected from the set to be allocated, and the memory is allocated to the applicant. The remaining memory size after memory allocation is thus 4 bytes. If the memory allocation is performed in the free memory block with the total memory size of 6 bytes, the size of the remaining memory after the memory allocation is performed is 2 bytes, which obviously results in more memory fragments compared with the former scheme in this example.
That is to say, the larger the free memory blocks have higher availability, so that, under the condition that no free memory block with the total memory size the same as that of the application memory is found, the free memory block with the maximum total memory size can be selected from the determined to-be-allocated set, and the memory is allocated to the application party, so that the generation of memory fragments can be reduced as much as possible.
In one embodiment of the present application, the method may further comprise the steps of:
the first step is as follows: obtaining a recovered memory block;
the second step is that: determining whether the memory blocks with continuous addresses exist in the idle memory block list or not according to the addresses of the recovered memory blocks, and if so, executing a third step;
the third step: and merging the memory blocks with continuous addresses.
For convenience of description, the above three steps are combined for illustration.
In the system operation process, memory application and release are carried out, and when the released memory exists, the memory can be recycled and distributed to other application parties for use.
After the recovered memory blocks are obtained, whether memory blocks with continuous addresses exist in the idle memory block list or not can be determined according to the addresses of the recovered memory blocks. The idle memory blocks in the idle memory block list may be arranged in a front-back order of addresses, so as to facilitate checking the address of each idle memory block. If the memory blocks with continuous addresses exist in the free memory block list, the memory blocks with continuous addresses may be merged, so that the total memory size of the free memory blocks in the free memory block list is as large as possible.
For example, the free memory block list in fig. 4 includes free memory blocks:
the idle memory block 1: address 0x00000000, total memory size 6 bytes,
And 2, idle memory block: address 0x0000010, total memory size 8 bytes,
Idle memory block 3: address 0x000001C, total memory size 2 bytes,
The idle memory block 4: the address is 0x0000022, and the total memory size is 3 bytes.
If the 4 bytes of memory on the address of 0x0000018 are recovered, that is, the address of the recovered memory block is 0x0000018, and the total memory size is 4 bytes, it may be determined that memory blocks with continuous addresses exist in the free memory block list, that is, the addresses of the free memory block 2, the recovered memory block, and the free memory block 3 are continuous, according to the address of the recovered memory block. The three memory blocks may be merged to obtain an idle memory block list shown in fig. 5, where the idle memory block list includes idle memory blocks:
the address is idle memory block of 0x00000000, total memory size is 6 bytes;
the address is idle memory block of 0x0000010, the total memory size is 14 bytes;
free memory block with address 0x0000022 and total memory size of 3 bytes.
The memory blocks with continuous addresses are merged, and compared with an uncombined mode, the usability is higher. As shown in fig. 6, in a non-merging manner, all the idle memory blocks included in the idle memory block list have a smaller total memory size, and memory fragments are easily generated after memory allocation is performed.
Of course, according to the address of the recovered memory block, if it is determined that there is no memory block with continuous addresses in the free memory block list, the recovered memory block may be directly recorded in the free memory block list according to a preset rule without performing other processing.
In an embodiment of the present application, the requesting party is a structure object, and the memory application carries information of the application memory size of each field included in the structure object; searching for the idle memory blocks with the same total memory size as the applied memory size includes:
aiming at each field contained in the structure object, searching an idle memory block with the total memory size being the same as the applied memory size of the current field;
correspondingly, allocating the found idle memory blocks to the application party includes:
and aiming at each field contained in the structure body object, allocating the memory of the searched idle memory block with the total memory size being the same as the applied memory size of the current field to the current field.
In the embodiment of the present application, if the requestor is a structure object, the byte alignment requirement needs to be considered. In the related art, for convenience, the memory application of the structure object is entirely allocated, which easily increases the memory occupation size.
For example, the structural objects are as follows:
Figure BDA0002905423280000081
the above structure object includes three fields, the occupied bytes are different in size, and all require byte alignment. If the memory is allocated in whole, the size of the memory application in whole can only be performed with the maximum byte alignment requirement in consideration of the byte alignment requirement, that is, 3 × 4-12 bytes require 4 bytes alignment. The free memory blocks that satisfy the alignment requirement and the request memory size requirement are not easily found. In the application, the memory application carries information of the size of the application memory of each field included in the structure object, and for each field included in the structure object, a free memory block with the total memory size same as the size of the application memory of the current field can be searched, and the memory of the free memory block with the total memory size same as the size of the application memory of the current field is allocated to the current field. I.e. memory is allocated separately for each field, which reduces the requirement for free memory blocks. As shown in the above example, allocation is required three times, only 1 byte alignment and 1 byte memory size are required for the first field, only 2 byte alignment and 2 byte memory size are required for the second field, and only 4 byte alignment and 4 byte memory size are required for the third field. The total memory size allocated in this way is 1+2+ 4-7 bytes. The memory utilization rate can be improved, and the memory allocation can be performed by effectively utilizing smaller memory fragments.
Corresponding to the above method embodiments, the present application further provides a memory allocation control device, and the memory allocation control device and the memory allocation control method described below may be referred to in correspondence with each other.
Referring to fig. 7, the apparatus may include the following modules:
a memory application receiving module 710, configured to receive a memory application sent by an application party, where the memory application carries information of a memory size to be applied;
an idle memory block searching module 720, configured to traverse the idle memory block list, and search for an idle memory block having a total memory size that is the same as the size of the application memory;
the memory allocation module 730 is configured to allocate a memory to the requestor in the found idle memory block.
By applying the device provided by the embodiment of the application, when a memory application sent by an applicant is received, the free memory block list is traversed, the free memory blocks with the total memory size same as that of the applied memory are searched, and the memory is allocated to the applicant in the searched free memory blocks, so that the generation of memory fragments can be avoided as much as possible, and the problem of resource shortage is solved.
In an embodiment of the present application, the memory allocation module 730 is further configured to:
after traversing the free memory block list, if no free memory block with the same total memory size as the application memory size is found, determining a set to be allocated according to the application memory size, wherein the ratio of the total memory size of each free memory block in the set to be allocated to the application memory size is larger than a set proportion threshold;
and selecting an idle memory block in the set to be allocated, and allocating the memory to the application party.
In an embodiment of the present application, the memory allocation module 730 is further configured to:
and selecting the idle memory block with the maximum total memory size in the set to be allocated, and allocating the memory to the application party.
In a specific embodiment of the present application, the system further includes a recycling processing module, configured to:
obtaining a recovered memory block;
determining whether memory blocks with continuous addresses exist in an idle memory block list or not according to the addresses of the recovered memory blocks;
and if so, merging the memory blocks with continuous addresses.
In a specific embodiment of the present application, the free memory blocks in the free memory block list are arranged according to a front-back order of addresses.
In a specific embodiment of the present application, the requesting party is a structure object, and the memory application carries information of the application memory size of each field included in the structure object;
a free memory block searching module 720, configured to:
aiming at each field contained in the structure object, searching an idle memory block with the total memory size being the same as the applied memory size of the current field;
accordingly, the memory allocation module 730 is configured to:
and aiming at each field contained in the structure body object, allocating the memory of the searched idle memory block with the total memory size being the same as the applied memory size of the current field to the current field.
Corresponding to the above method embodiment, an embodiment of the present application further provides a memory allocation control device, including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the memory allocation control method when executing the computer program.
As shown in fig. 8, which is a schematic view of a structure of a memory allocation control device, the memory allocation control device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through a communication bus 13.
In the embodiment of the present application, the processor 10 may be a Central Processing Unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, etc.
The processor 10 may call a program stored in the memory 11, and in particular, the processor 10 may perform operations in the embodiment of the memory allocation control method.
The memory 11 is used for storing one or more programs, the program may include program codes, the program codes include computer operation instructions, in this embodiment, the memory 11 stores at least the program for implementing the following functions:
receiving a memory application sent by an application party, wherein the memory application carries information of the size of the applied memory;
traversing the free memory block list, and searching for a free memory block with the total memory size same as the size of the application memory;
and allocating the memory to the application party in the searched idle memory block.
In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a data communication function, a list traversal function), and the like; the data storage area can store data created in the using process, such as memory size data, comparison result data and the like.
Further, the memory 11 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid state storage device.
The communication interface 12 may be an interface of a communication module for connecting with other devices or systems.
Of course, it should be noted that the structure shown in fig. 8 does not constitute a limitation on the memory allocation control device in the embodiment of the present application, and in practical applications, the memory allocation control device may include more or less components than those shown in fig. 8, or some components in combination.
Corresponding to the above method embodiments, this application embodiment further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the memory allocation control method 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.
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 application.
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 principle and the implementation of the present application are explained in the present application by using specific examples, and the above description of the embodiments is only used to help understanding the technical solution and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.

Claims (10)

1. A memory allocation control method, comprising:
receiving a memory application sent by an application party, wherein the memory application carries information of the size of the applied memory;
traversing the free memory block list, and searching for a free memory block with the total memory size same as the size of the application memory;
and allocating the memory to the application party in the searched idle memory block.
2. The method according to claim 1, further comprising, after said traversing the free-memory-block list:
if the idle memory blocks with the total memory size same as the application memory size are not found, determining a set to be allocated according to the application memory size, wherein the ratio of the total memory size of each idle memory block in the set to be allocated to the application memory size is larger than a set proportion threshold;
and selecting an idle memory block in the set to be allocated, and allocating a memory to the applicant.
3. The method according to claim 2, wherein the selecting one free memory block in the set to be allocated and allocating memory to the requestor comprises:
and selecting the idle memory block with the maximum total memory size in the set to be allocated, and allocating the memory to the applicant.
4. The method of claim 1, further comprising:
obtaining a recovered memory block;
determining whether memory blocks with continuous addresses exist in the idle memory block list or not according to the addresses of the recovered memory blocks;
and if so, merging the memory blocks with continuous addresses.
5. The method according to claim 4, wherein the free memory blocks in the free memory block list are arranged in a front-to-back order of addresses.
6. The method according to any one of claims 1 to 5, wherein the requesting party is a structure object, and the memory request carries information of the memory size of each field included in the structure object;
the searching for the idle memory block with the total memory size same as the application memory size includes:
searching for an idle memory block with the total memory size same as the applied memory size of the current field aiming at each field contained in the structure object;
correspondingly, the allocating the found idle memory blocks to the applicant includes:
and aiming at each field contained in the structure body object, allocating the memory of the searched idle memory block with the total memory size being the same as the applied memory size of the current field to the current field.
7. A memory allocation control apparatus, comprising:
the memory application receiving module is used for receiving a memory application sent by an application party, wherein the memory application carries information of the size of the applied memory;
the idle memory block searching module is used for traversing the idle memory block list and searching the idle memory blocks with the total memory size same as the application memory size;
and the memory allocation module is used for allocating the memory to the applicant in the searched idle memory blocks.
8. The apparatus of claim 7, wherein the memory allocation module is further configured to:
after traversing the free memory block list, if no free memory block with the same total memory size as the application memory size is found, determining a set to be allocated according to the application memory size, wherein the ratio of the total memory size of each free memory block in the set to be allocated to the application memory size is larger than a set proportion threshold;
and selecting an idle memory block in the set to be allocated, and allocating a memory to the applicant.
9. A memory allocation control apparatus, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the memory allocation control method according to any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the memory allocation control method according to any one of claims 1 to 6.
CN202110069958.6A 2021-01-19 2021-01-19 Memory allocation control method, device, equipment and storage medium Pending CN112799832A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110069958.6A CN112799832A (en) 2021-01-19 2021-01-19 Memory allocation control method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110069958.6A CN112799832A (en) 2021-01-19 2021-01-19 Memory allocation control method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112799832A true CN112799832A (en) 2021-05-14

Family

ID=75810525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110069958.6A Pending CN112799832A (en) 2021-01-19 2021-01-19 Memory allocation control method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112799832A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791596A (en) * 2021-11-15 2021-12-14 西安热工研究院有限公司 Memory hour mean value calculation method, system, equipment and medium based on dynamic application
CN114296946A (en) * 2022-03-08 2022-04-08 北京蚂蚁云金融信息服务有限公司 Data processing method and device and server

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791596A (en) * 2021-11-15 2021-12-14 西安热工研究院有限公司 Memory hour mean value calculation method, system, equipment and medium based on dynamic application
CN113791596B (en) * 2021-11-15 2022-02-18 西安热工研究院有限公司 Memory hour mean value calculation method, system, equipment and medium based on dynamic application
CN114296946A (en) * 2022-03-08 2022-04-08 北京蚂蚁云金融信息服务有限公司 Data processing method and device and server
CN114296946B (en) * 2022-03-08 2022-07-05 北京蚂蚁云金融信息服务有限公司 Data processing method and device and server

Similar Documents

Publication Publication Date Title
CN109343963B (en) Application access method and device for container cluster and related equipment
CN115543696B (en) Disk array reconstruction task acceleration method, system, storage medium and equipment
CN110389905B (en) Resource release method, resource allocation method, device and computer program product
CN112799832A (en) Memory allocation control method, device, equipment and storage medium
TWI694700B (en) Data processing method and device, user terminal
CN111309644B (en) Memory allocation method and device and computer readable storage medium
CN111723057A (en) File pre-reading method, device, equipment and storage medium
CN111338779B (en) Resource allocation method, device, computer equipment and storage medium
CN112214313A (en) Memory allocation method and related equipment
CN109446202B (en) Identifier allocation method, device, server and storage medium
CN113419672B (en) Storage capacity management method, system and storage medium
CN112269661A (en) Partition migration method and device based on Kafka cluster
CN110336813B (en) Access control method, device, equipment and storage medium
CN110781137A (en) Directory reading method and device for distributed system, server and storage medium
CN106682494B (en) Information access method, device and equipment
CN113849311B (en) Memory space management method, device, computer equipment and storage medium
CN105490956A (en) Network request processing method and network request processing device
CN115658561A (en) Power distribution terminal memory management method and device, electronic equipment and storage medium
CN111858020A (en) User resource limiting method, device and computer storage medium
CN114721814A (en) Task allocation method and device based on shared stack and computer equipment
CN113553195A (en) Memory pool resource sharing method, device, equipment and readable medium
CN113051143A (en) Detection method, device, equipment and storage medium for service load balancing server
CN111679909A (en) Data processing method and device and terminal equipment
CN112817766B (en) Memory management method, electronic equipment and medium
CN110968370B (en) Data processing method and device

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