CN110162396A - Method for recovering internal storage, device, system and storage medium - Google Patents

Method for recovering internal storage, device, system and storage medium Download PDF

Info

Publication number
CN110162396A
CN110162396A CN201810151914.6A CN201810151914A CN110162396A CN 110162396 A CN110162396 A CN 110162396A CN 201810151914 A CN201810151914 A CN 201810151914A CN 110162396 A CN110162396 A CN 110162396A
Authority
CN
China
Prior art keywords
memory
group
control group
resources control
grade
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
CN201810151914.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.)
Banma Zhixing Network Hongkong Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201810151914.6A priority Critical patent/CN110162396A/en
Publication of CN110162396A publication Critical patent/CN110162396A/en
Pending legal-status Critical Current

Links

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

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 invention discloses a kind of method for recovering internal storage, device, system and storage mediums.The method for recovering internal storage includes: the Memory Allocation request for receiving application, includes the required memory size of application in Memory Allocation request;The size of amount of free memory and required memory size in comparison system;When amount of free memory is less than required memory size, based on the grade of the process in kernel resources control group, the corresponding memory of collection process.The method for recovering internal storage provided according to embodiments of the present invention can improve memory service efficiency during Memory recycle, guarantee the stable operation and smooth degree of system.

Description

Method for recovering internal storage, device, system and storage medium
Technical field
The present invention relates to field of computer technology more particularly to a kind of method for recovering internal storage, device, system and storage to be situated between Matter.
Background technique
In an operating system, in order to accelerate the speed for carrying out read or write to disk, operating system nucleus is to disk When carrying out read or write, in memory by a large amount of data buffer storage.This mode can correspond to a large amount of memory headroom, if operation The memory of system is largely used to file cache and cannot be discharged in time, can be because Memory Allocation deficiency leads to operating system There is exception, causes in application software operational process, memory service efficiency is low.
In order to avoid because Memory Allocation it is insufficient caused by system exception and appearance the problems such as low memory usage, operation system System can introduce distribution management and reclaim mechanism to memory.
In the prior art, if it find that low memory, generallys use direct way of recycling, disposable recycling fixed quantity Region of memory, this method for recovering internal storage would generally cause the unnecessary operation requests to operating system.For example, if recycling Region of memory, which is modified but modifies content, has not been written to disk, then can generate unnecessary input output request, cause system The unnecessary waste of resource causes system current operation program to be in blocked state, influences system stable operation and smooth degree.
Summary of the invention
The embodiment of the present invention provides a kind of method for recovering internal storage, device, system and storage medium, can be in Memory recycle mistake Cheng Zhong guarantees the stable operation and smooth degree of system.
One side according to an embodiment of the present invention provides a kind of method for recovering internal storage, comprising: receives the Memory Allocation of application It requests, includes the required memory size of application in Memory Allocation request;Amount of free memory and required memory in comparison system The size of capacity;When amount of free memory is less than required memory size, based on the grade of the process in kernel resources control group, The corresponding memory of collection process.
According to another aspect of an embodiment of the present invention, a kind of Memory recycle device is provided, comprising: memory request receives mould Block includes the required memory size of application for receiving the Memory Allocation request of application, in Memory Allocation request;Memory compares mould Block, the size for amount of free memory and required memory size in comparison system;Group recycling module, for working as free memory When capacity is less than required memory size, based on the grade of the process in kernel resources control group, the corresponding memory of collection process.
It is according to an embodiment of the present invention in another aspect, providing a kind of Memory recycle system, including memory and processor;It deposits Reservoir is for storing executable program code;Processor is for reading the executable program code stored in memory to execute Above-mentioned method for recovering internal storage.
Another aspect according to an embodiment of the present invention, provides a kind of computer readable storage medium, this is computer-readable Instruction is stored in storage medium, when instruction is run on computers, so that computer executes the interior of above-mentioned various aspects and is stored back to Receiving method.
Method for recovering internal storage, device and storage medium according to embodiments of the present invention, when amount of free memory is less than institute When needing memory size, can the corresponding memory of process in the grade recovery system based on the process in kernel resources control group, The unnecessary operation requests to operating system that the corresponding memory of process causes in direct recovery system are avoided, memory is improved and utilizes Rate guarantees that system stablizes smooth operation during Memory recycle.
Detailed description of the invention
In order to illustrate the technical solution of the embodiments of the present invention more clearly, will make below to required in the embodiment of the present invention Attached drawing is briefly described, for those of ordinary skill in the art, without creative efforts, also Other drawings may be obtained according to these drawings without any creative labor.
Fig. 1 is to show the applicable system architecture schematic diagram of method for recovering internal storage according to an embodiment of the present invention;
Fig. 2 is the flow chart for showing method for recovering internal storage according to an embodiment of the present invention;
Fig. 3 is the flow diagram for showing method for recovering internal storage according to another embodiment of the present invention;
Fig. 4 is the structural schematic diagram for showing Memory recycle device according to an embodiment of the present invention;
Fig. 5 is to show the calculating equipment that method for recovering internal storage and device according to an exemplary embodiment of the present invention may be implemented Exemplary hardware architecture structure chart.
Specific embodiment
The feature and exemplary embodiment of various aspects of the invention is described more fully below, in order to make mesh of the invention , technical solution and advantage be more clearly understood, with reference to the accompanying drawings and embodiments, the present invention is further retouched in detail It states.It should be understood that specific embodiment described herein is only configured to explain the present invention, it is not configured as limiting the present invention. To those skilled in the art, the present invention can be real in the case where not needing some details in these details It applies.Below the description of embodiment is used for the purpose of better understanding the present invention to provide by showing example of the invention.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence " including ... ", it is not excluded that including There is also other identical elements in the process, method, article or equipment of the element.
In order to better understand the present invention, it below in conjunction with attached drawing, is described in detail according to an embodiment of the present invention and is stored back to Receiving method and Memory recycle device, it should be noted that these embodiments are not for limiting the scope of the present disclosure.
Fig. 1 shows the applicable system architecture schematic diagram of method for recovering internal storage according to an embodiment of the present invention.Such as Fig. 1 institute Show, operating system may include two kinds of access modules: user mode and kernel mode in the embodiment of the present invention, and kernel mode can be with The kernel spacing of access operation system, the user's space of the accessible operating system of user mode.Kernel spacing Kernel Space is the running space of operating system nucleus, and kernel spacing can run core functions module, and storage kernel code and Kernel data;User's space User Space is the running space of user program, and user's space can store user's application with user Code and data.
For security consideration, in the operating system for providing user mode and kernel mode, the program of user's space cannot be with The data that meaning operation kernel spacing saves, even if the application crash of user's space, kernel spacing are also unaffected.
In the embodiment of the present invention, the operating system OperatingSystem of terminal configuration includes at least master operating system (HostOperatingSystem).In one embodiment, terminal can configure multiple operating systems, such as master operating system One or more containers are created with using container Container virtualization technology, installs and is run from operating system in a reservoir. As an example, each container can be equivalent to a virtual machine.
Therefore, the user's space in the embodiment of the present invention may include user's space in master operating system and operate in appearance The user's space of slave operating system in device, the application run in slave operating system in a reservoir are known as container and answer With.
In the host or container of user's space, user program can at least correspond to a process in the process of running, into Journey can indicate primary operation activity of the application program about data acquisition system of terminal operating, be that system carries out resource allocation and tune The basic unit of degree.In order to make it easy to understand, process can be considered as to the implementation procedure of user program;And thread is operating system Basic scheduling unit, a process may include at least one thread, and thread, which is that one in process is relatively independent, can be performed Unit.If a process is known as a task task, thread then can be the subtask for including in the task.
Those skilled in the art are it will also be appreciated that the method for recovering internal storage of the embodiment of the present invention is applicable to a variety of offers The operating system of user mode and kernel mode, such as Unix operating system, (SuSE) Linux OS, Android Android operation System etc..For simplicity, this paper following multiple embodiments can illustrate that the present invention is real by taking (SuSE) Linux OS as an example Apply the method for recovering internal storage of example.But the description can not be read as the range or operational feasibility of limitation this programme, Linux behaviour Make in the operating system for providing user mode and kernel mode other than system, the method for recovering internal storage of the embodiment of the present invention is same Sample is applicable in.
As shown in Figure 1, kernel spacing may include group recycling thread and a Memory recycle thread, Memory recycle thread can be The method for recovering internal storage of the embodiment of the present invention is executed under the calling of group recycling thread.
As an example, in (SuSE) Linux OS, the group recycling thread of kernel spacing for example can be group_ Reclaim_thread, Memory recycle thread for example can be kswapd.
It continues to refer to figure 1, operating system can pass through kernel resources control group (Control Group, Cgroup) technology The resource used user's space intermediate range sort run controls.Kernel resources control group technology is that operating system nucleus provides A kind of mechanism of system resource used in limitation, isolation and record the process, system resource for example may include CPU, memory, defeated Enter output interface etc..
In kernel resources control group, a task can be considered as a process of system.Kernel resources control group into The function of Cheng Jinhang resource management can be realized by way of controller or subsystem.Kernel resources control group may include more Different resource management functions may be implemented in a scheduling of resource controller or subsystem, each subsystem.
As an example, in the resource control system of kernel resources control group, CPU control subsystem can be used for The control of time, i.e. the CPU control subsystem occupancy that can be used for control CPU are used using scheduler program control process CPU Rate;Memory subsystem can be used for setting process to memory using limitation, and can automatically generate these processes to memory source The report of service condition;Freeze subsystem, can be used for hanging up or restoring the process in kernel resources control group.
It as an example, include CPU control subsystem or cpu controller cpuctl, memory in kernel resources control group Subsystem or Memory Controller Hub memory and freeze subsystem freezer.
As an example, the CPU usage of thread can be recycled, by CPU control subsystem control group currently to answer With the influence reduced in terms of Memory recycle bring system fluency when carrying out Memory recycle.
In embodiments of the present invention, each process can create corresponding memory subsystem, and itself can be added to Corresponding memory subsystem, to call the corresponding memory subsystem of the process to realize, the corresponding memory of the process is recycled.
In embodiments of the present invention, kernel resources control group can manage being grouped of process, and operating system can be with Process is classified to obtain process grouping, each process can be added specified process according to the type of own services and be grouped.
In one embodiment, process can include but is not limited to according to the type of own services: foreground application process is delayed Deposit into journey, local basis service processes, the local service processes of starting on demand, binding service process, unbundlings service processes and container Application process.
As an example, foreground application process can indicate that foreground is currently running using corresponding process;Cache into Journey can indicate that resident process such as background application in memory corresponds to corresponding process;Container application process can indicate cloth Set in the operating system of container using corresponding process.
As an example, the Starting mode of the service in system may include automatic starting and starting on demand.This ground Plinth service usually indicates the service of load simultaneously automatically when system starting, to run other on the basis of local basis services Using;The local service of starting on demand can indicate the service started after system starting according to user demand.It in this example, can be with Local basis is serviced into corresponding process as local service process, will locally start the corresponding process of service on demand and be known as locally Starting service processes on demand.
As an example, binding service provides a kind of mechanism with binding mode starting service, can by binding service To start the service from other application component in a manner of binding, request is sent to the service of the other application component, is received Response, binding service can be in active state when providing service for other application component, will not indefinitely be transported on backstage Row;The service that unbundlings service starts for unbinding mode.In this example, can using the corresponding process of binding service as Binding service process will unbind the process of service processes as unbundlings service processes.
Description through the foregoing embodiment it is found that the process grouping in kernel resources control group can include but is not limited to as Lower process is grouped one or more: foreground application group, caching are using group, binding service group, unbundlings service group, local basis clothes Business group, local starting service group and container group on demand.
In one embodiment, corresponding process can be added in process and is grouped according to the type of process own services.Make For an example, foreground application process can be added to foreground application group, caching process is added caching and applies group, and local process adds Enter local basis service group, container group, binding service method binding service group is added in container application process, and unbundlings service is put into solution The service of tying up.
In embodiments of the present invention, the process of each classification can be set the value model of rank controlling value in system It encloses, passes through the grade of rank controlling value identification process.As an example, the rank controlling value of process is higher, indicates the process Lower grade, the lower grade of process grouping where the process.Lower grade process is more inessential, in operating system memory The memory source that the process group uses when insufficient more early can be also recovered.
In one embodiment, the rank controlling value of process can be importance value, and importance value is higher, and indicating should The significance level of process is lower, then the lower grade of process group where process;Importance value is lower, indicates the important of the process Degree is higher, then the higher grade of the process group where process.As an example, the importance value of process can the process Oom_adj value.
Therefore, in embodiments of the present invention, process can also be grouped according to the rank controlling value of process.Rank is controlled It is worth process identical or that rank controlling value is in same value range and identical process grouping is added.
As an example, the rank controlling value of foreground process for example can be set to 1;The rank controlling value of caching process Such as can be set to numerical value between 9-16, the rank controlling value example of the local basis service processes in local basis service group It such as can be set to negative value such as -17.
In one embodiment, the rank controlling value of process can be equal in the same process group, i.e., in the process group into The rank controlling value of journey is exactly the value range of the rank controlling value of process in the rank controlling value or process group of the process group It is exactly the value range of the rank controlling value of the process group.
In one embodiment, Process identifier (ProcessIdentifier, PID) can be used for unique identification one Process.Process is grouped in be created after may include corresponding process group file, corresponding process group is written into Process identifier The corresponding process grouping can be added in the process of the Process identifier unique identification by file.
In one embodiment, the rank controlling value of process can be according to the practical application field of target application in operating system Scape is adjusted, and the grouping where the process is accordingly made adjustment.As an example, in os starting Memory recycle When, in order to not influence the normal operation of current application, service relevant to current application can temporarily be added to foreground process group, It is not involved in current memory removal process;When current application is switched to backstage, service relevant to the current application then returns to original The process group at place.
It in embodiments of the present invention, is to guarantee that operating system operates normally, during Memory recycle, foreground application group can be with It is not involved in Memory recycle, i.e. foreground process in foreground application group, is had in the binding service group of binding relationship with foreground process Process is not involved in current memory removal process;If current reference is not container application, the process in container application group can be with It is preferential to participate in recycling.
Fig. 2 shows the flow charts of method for recovering internal storage according to an embodiment of the present invention.As shown in Fig. 2, implementing at one In example, method for recovering internal storage 10 may include:
Step S101, using switching, i.e. the current application of user's space switches, which enters weight It is new to return to state.
In this step, after current application enters the state of returning to, which can be added to foreground application group.
Step S102 obtains memory size needed for application is run according to applicating history operation information.
In this step, memory size needed for which runs can be preset in configuration file.
Front end applications group is added, to guarantee that this is applied in Memory recycle process in the association service of the application by step S103 In normal operation.
In this step, the association service of the application is referred to as being to have the service for relying on short breath with the application.
Step S104 notifies the group of kernel spacing to recycle thread and recycled.
The Memory recycle request of current application is transferred to kernel spacing by S101-S104 through the above steps, user's space Group recycle thread, the Memory recycle request in include current application needed for memory size.
With continued reference to Fig. 2, in kernel spacing, method for recovering internal storage 10 may include:
Step S201, group recycling thread are waken up.
Memory size to be recycled is arranged equal to memory size needed for current application in step S202.
It is big to check whether the free memory size free_mem for working as system is greater than memory needed for current application by step S203 It is small, if free memory size selects in the maximum process grouping of rank controlling value less than memory size needed for current application Memory is maximum and not yet recycles the process of memory headroom.
In this step, rank controlling value is bigger, and the process important level in corresponding process grouping is lower, process recycling When the process grouping in process be recovered at first.
Specifically, the maximum process grouping of current level controlling value can be obtained, such as according to rank controlling value from big to small Process that is maximum there are memory and not discharging memory headroom, then return the corresponding memory of the process in the grouping of the fruit process It receives.
Step S204, if there are the maximum process for not discharging memory headroom of memory, recycling in current process grouping File Mapping memory in the process.
In this step, the corresponding File Mapping memory of the file that can be accessed process recycles.The text of process Part mapping refers to that the position of file on disk is closed with corresponding between the identical region of memory of size in process logic address space System.During memory maps, this document is not loaded into memory headroom actually, but process pair is mapped to from Documents Logical In the memory answered.
In embodiments of the present invention, the purpose of shared drive can be realized between process by mapping same file, Improve file access efficiency.
Step S205 after recycling the File Mapping memory in the process, is checked when whether the free memory size of system is big The memory size needed for current application, if free memory recycles hideing in the process less than memory size needed for current application Name mapping memory.
In this step, anonymous mapping belongs to one of File Mapping mode.As an example, there is kinship Process such as parent process and subprocess between when realizing shared drive, can be using anonymous map by the way of.Anonymity mapping can Not to be related to specific filename, so as to avoid the frequent creation of file and opening, improve between parent process and subprocess The communication efficiency of file-sharing.
It, can should after carrying out File Mapping Memory recycle and anonymous Memory recycle to current process in step S205 Current process packet marking is scanning mode.
Repeat the above steps S203 to S205, from big to small according to rank controlling value, successively most to memory in process grouping The big process for not discharging memory headroom carries out Memory recycle.
As shown in step S206, if free memory is less than required memory, and there is no do not swept in the grouping of all processes The process retouched then directly selects rank and controls the maximum process of memory in maximum process grouping.
Step S207 judges the rank controlling value of the maximum process of the memory and the rank controlling value of caching application group, such as The rank controlling value of the maximum process of the fruit memory is greater than the rank controlling value of caching application group, then can disconnect memory maximum Process all memory headrooms, recycle all memory headrooms of the maximum process of the memory.
Step S208 after all memory headrooms for recycling the maximum process of the memory, terminates the maximum process of the memory.
In this step, journey signal terminating Memory recycle thread can be entered by sending.As an example, journey is entered Signal can be kill-9 signal.
Step S209, group recycling thread enter suspend mode Sleep state.
In one embodiment, if in above-mentioned steps S203, free memory is obtained greater than current application institute if checked When free memory being needed in memory size or step S206 to be greater than required memory, illustrate that free memory has met current application Memory requirements, then can by group recycling a thread be set as dormant state.
In another embodiment, if in step S207, free memory is unsatisfactory for the memory requirements of current application, owns Process grouping to execute the operation of recycling memory, and in the maximum process grouping of adj value the maximum process of memory rank When controlling value is less than or equal to the rank controlling value of caching application group, step S209 can be executed, stops recycling memory to guarantee to work as Preceding to cache the operation applied, the group recycling thread waiting in kernel is triggered next time.
It in embodiments of the present invention, can be in conjunction with the concrete application field of user's application for the ease of the management of Installed System Memory Scape and rank controlling value are grouped application layer process process, each process can add according to the type of own services as foundation Enter into the grouping of a certain process, and a process can correspond to a Memory recycle subsystem, and the process is added to pair The Memory recycle subsystem answered facilitates group recycling thread dispatching Memory recycle subsystem to recycle the corresponding memory of the process.
Method for recovering internal storage according to an embodiment of the present invention, kernel resources control group can recycle thread by limitation group CPU usage reduces the influence in terms of Memory recycle process is current application bring fluency.
Fig. 3 shows the flow diagram of method for recovering internal storage according to another embodiment of the present invention.As shown in figure 3, In the embodiment, method for recovering internal storage 300 may include:
Step S310, receives the Memory Allocation request of application, includes the required memory size of application in Memory Allocation request.
In this step, the required memory size of user's space application can be obtained from preset configuration file.
Step S320 compares the size of amount of free memory and required memory size.
Step S330, when amount of free memory is less than required memory size, based on the process in kernel resources control group Grade, recycle kernel resources control group in the corresponding memory of process.
In this step, the process in kernel resources control group is configured as adding according to the type of the corresponding service of process Enter the corresponding process grouping of rank controlling value.As an example, kernel resources control group may include multiple process groupings, more A process grouping includes one or more in following item: foreground application group, caching apply group, local service group, container service Group, binding service group and unbundlings service group.
In one embodiment, the process in each process grouping includes corresponding rank controlling value, and rank controlling value is used In the grade for identifying corresponding process, rank controlling value is bigger, and the lower grade of the corresponding process of rank controlling value;Kernel resources control Process in processed group is additionally configured to the rank controlling value according to process, and the corresponding process grouping of rank controlling value is added
In one embodiment, the process grouping where the related service of available user's application, by related service pair The process answered is promoted to foreground application group, and the corresponding process of service in foreground application group is arranged to without Memory recycle.
In this step, in specific application scenarios, due to the corresponding memory money of the related service of active user's application Source will not be usually recovered, therefore initial processes belonging to the corresponding process of related service of available current application are grouped, Before carrying out Memory recycle, foreground application group, active user are set by the affiliated process grouping of the corresponding process of related service Application switching be background application after, can by process belonging to the corresponding process of related service be grouped be re-set as this initially into Journey grouping.
In one embodiment, the corresponding memory of process in foreground application group is configured as without Memory recycle;When When using corresponding process not being container using corresponding process, the corresponding memory of process in container group be configured as preferentially into Row Memory recycle.
As an example, when user's space application is not container in application, can be by the process in container service group Rank controlling value is set as highest, indicates that the progress levels in container service group are minimum.The important level of container service group is set When being set to minimum, preferentially the proceeding internal memory in the container service group can be recycled.
In one embodiment, the grade based on the process in kernel resources control group in step S330, collection process pair It the step of memory answered, can specifically include:
According to the grade sequence from low to high of the process in kernel resources control group, Memory recycle is executed to process, directly Memory size to recycling has been more than or equal to the corresponding memory of process in required memory size or kernel resources control group It is recovered.
In one embodiment, the step of executing Memory recycle to process in step S330 can specifically include:
Step S330-01, selection target process, target process corresponding memory in the process in kernel resources control group Capacity is maximum and corresponding memory is not recovered, and corresponding memory includes File Mapping memory and anonymous mapping memory.
Step S330-02, the corresponding File Mapping memory of recycling target process.
Step S330-03, if the amount of free memory obtained after File Mapping Memory recycle is less than required memory size, Recycle the corresponding anonymous mapping memory of target process.
In embodiments of the present invention, the purpose of Memory recycle is not configured to destruction process, but in order to not influence currently In the case where using normal operation, recycling memory size as much as possible, therefore, the method for recovering internal storage of the embodiment of the present invention, When amount of free memory is less than required memory size, the grade of the process in the kernel resources control group based on pre-configuration is from low To height, the corresponding memory of process in kernel resources control group is recycled, improves the service efficiency that user applies run-time memory, is guaranteed The system normally operation with smoothness.
Fig. 4 shows the structural schematic diagram of Memory recycle device according to an embodiment of the present invention.As shown in figure 4, at one In embodiment, Memory recycle device 400 may include:
Memory request receiving module 410 is requested for the Memory Allocation for receiving application, includes in Memory Allocation request The required memory size of application;
Memory comparison module 420, the size for amount of free memory and required memory size in comparison system;
Group recycling module 430, for being based on kernel resources control group when amount of free memory is less than required memory size In process grade, the corresponding memory of collection process.
In embodiments of the present invention, kernel resources control group includes multiple process groupings, and multiple process groupings include as follows One or more in: foreground application group, caching apply group, local basis service group, container group, binding service group and unbundlings Service group;Process in kernel resources control group is configured as the type according to the corresponding service of process, and multiple processes point are added At least one of group.
In one embodiment, the process in each process grouping includes corresponding rank controlling value, and rank controlling value is used In the grade for identifying corresponding process, rank controlling value is bigger, and the lower grade of the corresponding process of rank controlling value;Kernel resources control Process in processed group is additionally configured to the rank controlling value according to process, and the corresponding process grouping of rank controlling value is added.
Specifically, the process in each process grouping includes corresponding rank controlling value, and rank controlling value is for mark pair The important level for the process answered, rank controlling value is bigger, and the important level of the corresponding process of rank controlling value is lower.
In one embodiment, the corresponding memory of process in foreground application group is configured as without Memory recycle;When When using corresponding process not being container using corresponding process, the corresponding memory of process in container group be configured as preferentially into Row Memory recycle.
In one embodiment, group recycling module 430 specifically can be used for:
The related service for obtaining application sets the process other than the corresponding process of related service to participate in Memory recycle Process;Based on the grade of the process in kernel resources control group, the corresponding memory of process for participating in Memory recycle is recycled.
In one embodiment, group recycling module 430 specifically can be used for:
According to the grade sequence from low to high of the process in kernel resources control group, Memory recycle is executed to process, directly Memory size to recycling has been more than or equal to the corresponding memory of process in required memory size or kernel resources control group It is recovered.
In one embodiment, group recycling module 430 can specifically include:
Target process selecting unit is used for selection target process, and target process is in the process in kernel resources control group Corresponding memory size is maximum and corresponding memory is not recovered, and corresponding memory includes in File Mapping memory and anonymous mapping It deposits;
File Mapping Memory recycle unit, for recycling the corresponding File Mapping memory of target process;
Anonymity mapping Memory recycle unit, if the amount of free memory for obtaining after File Mapping Memory recycle is less than Required memory size, the corresponding anonymous mapping memory of recycling target process.
In another embodiment, group recycling module 430 may include:
Process is grouped determining module, for being recovered when the corresponding memory of process in kernel resources control group, and When amount of free memory in system is less than required memory size, the minimum process place of kernel resources control group middle grade is determined Process grouping;
Target process selecting module is used for selection target process, and target process is in the process where elementary process Corresponding memory size is maximum in grouping;
When group recycling module is specifically also used to apply the grade of the process in group lower than caching when the grade of target process, return Receive the corresponding full memory of target process.
Memory recycle device through the embodiment of the present invention is based on when amount of free memory is less than required memory size The important level of the kernel resources control group of pre-configuration from low to high, recycles the corresponding memory of process in kernel resources control group, The service efficiency that user applies run-time memory is improved, guarantees the normal and smooth operation of system.
The basis that the other details of Memory recycle device according to an embodiment of the present invention combine Fig. 1 to Fig. 3 to describe with more than The method for recovering internal storage of the embodiment of the present invention is similar, and details are not described herein.
Fig. 5 is to show the calculating equipment that method for recovering internal storage and device according to an exemplary embodiment of the present invention may be implemented Exemplary hardware architecture structure chart.
As shown in figure 5, Memory recycle system 500 includes input equipment 501, input interface 502, central processing unit 503, deposits Reservoir 504, output interface 505 and output equipment 506.Wherein, input interface 502, central processing unit 503, memory 504, And output interface 505 is connected with each other by bus 510, input equipment 501 and output equipment 506 pass through input interface respectively 502 and output interface 505 connect with bus 510, and then connect with the other assemblies of Memory recycle system 500.
That is, calculating equipment shown in fig. 5 also may be implemented as a kind of Memory recycle system, the Memory recycle system System may include: the memory for being stored with computer executable instructions;And processor, the processor is for reading in memory The executable program code of storage is to execute the method for recovering internal storage and device that above-mentioned combination Fig. 1 to Fig. 4 describes.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or any combination thereof real It is existing.It when implemented in software, can be entirely or partly with the shape of computer program product or computer readable storage medium Formula is realized.The computer program product or computer readable storage medium include one or more computer instructions.It is calculating When being loaded on machine and executing the computer program instructions, entirely or partly generate according to process described in the embodiment of the present invention Or function.The computer can be general purpose computer, special purpose computer, computer network or other programmable devices.Institute Stating computer instruction may be stored in a computer readable storage medium, or from a computer readable storage medium to another A computer readable storage medium transmission, for example, the computer instruction can be from web-site, computer, a server Or data center is (such as infrared, wireless, micro- by wired (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless Wave etc.) mode transmitted to another web-site, computer, server or data center.The computer-readable storage Medium can be any usable medium that computer can access or include the integrated service of one or more usable mediums The data storage devices such as device, data center.The usable medium can be magnetic medium, (for example, floppy disk, hard disk, tape), light Medium (for example, DVD) or semiconductor medium (such as solid state hard disk Solid State Disk (SSD)) etc..
It should be clear that the invention is not limited to specific configuration described above and shown in figure and processing. For brevity, it is omitted here the detailed description to known method.In the above-described embodiments, several tools have been described and illustrated The step of body, is as example.But method process of the invention is not limited to described and illustrated specific steps, this field Technical staff can be variously modified, modification and addition after understanding spirit of the invention, or suitable between changing the step Sequence.
The above description is merely a specific embodiment, it is apparent to those skilled in the art that, For convenience of description and succinctly, the system, module of foregoing description and the specific work process of unit can refer to preceding method Corresponding process in embodiment, details are not described herein.It should be understood that scope of protection of the present invention is not limited thereto, it is any to be familiar with Those skilled in the art in the technical scope disclosed by the present invention, can readily occur in various equivalent modifications or substitutions, These modifications or substitutions should be covered by the protection scope of the present invention.

Claims (18)

1. a kind of method for recovering internal storage, comprising:
The Memory Allocation request of application is received, includes the required memory size of the application in the Memory Allocation request;
The size of amount of free memory and the required memory size in comparison system;
When the amount of free memory is less than the required memory size, based on the process in kernel resources control group etc. Grade, recycles the corresponding memory of the process.
2. method for recovering internal storage according to claim 1, wherein the process based in kernel resources control group etc. Grade, recycles the corresponding memory of the process, comprising:
According to the grade sequence from low to high of the process in the kernel resources control group, to the process execute in be stored back to It receives, until the memory size of recycling is more than or equal to the process in the required memory size or the kernel resources control group Corresponding memory has been recovered.
3. method for recovering internal storage according to claim 1, wherein described to recycle the corresponding memory of the process, comprising:
Selection target process, the target process corresponding memory size in the process in the kernel resources control group are maximum And corresponding memory is not recovered, the corresponding memory includes File Mapping memory and anonymous mapping memory;
Recycle the corresponding File Mapping memory of the target process;
If the amount of free memory obtained after the File Mapping Memory recycle be less than it is described needed for memory size, described in recycling The corresponding anonymous mapping memory of target process.
4. method for recovering internal storage according to claim 1, wherein the kernel resources control group includes multiple processes point Group includes that caching applies group in process grouping;
Free memory when the corresponding memory of process in the kernel resources control group has been recovered, and in the system holds When amount is less than the required memory size, the method for recovering internal storage further include:
Determine the process grouping where the minimum process of the kernel resources control group middle grade;
Selection target process, the target process corresponding memory in the process grouping where the elementary process hold Amount is maximum;
When the grade of the target process is lower than the grade cached using the process in group, the target process pair is recycled The full memory answered.
5. method for recovering internal storage according to claim 1, wherein the process based in kernel resources control group etc. Grade, recycles the corresponding memory of the process, comprising:
Process other than the corresponding process of the related service is set as being stored back in participation by the related service for obtaining the application The process of receipts;
Based on the grade of the process in the kernel resources control group, it is corresponding to the process for participating in Memory recycle in deposit into Row recycling.
6. method for recovering internal storage according to claim 1, wherein
The kernel resources control group includes multiple process groupings, and the multiple process grouping includes one or more in following item : foreground application group, caching are using group, local basis service group, container group, binding service group and unbundlings service group;
Process in the kernel resources control group is configured as the type according to the corresponding service of the process, and the grade is added The corresponding process grouping of other controlling value.
7. method for recovering internal storage according to claim 6, wherein
The corresponding memory of process in the foreground application group is configured as without Memory recycle;
The corresponding memory of process when the corresponding process of the application is not that container applies corresponding process, in the container group It is configured as preferentially carrying out Memory recycle.
8. method for recovering internal storage according to claim 6, wherein
Process in each process grouping includes corresponding rank controlling value, and the rank controlling value is described right for identifying The grade of process is answered, the rank controlling value is bigger, and the lower grade of the corresponding process of the rank controlling value;
Process in the kernel resources control group is additionally configured to the rank controlling value according to the process, and the rank is added The corresponding process grouping of controlling value.
9. a kind of Memory recycle device, comprising:
Memory request receiving module includes described answer in the Memory Allocation request for receiving the Memory Allocation request of application Required memory size;
Memory comparison module, the size for amount of free memory and the required memory size in comparison system;
Group recycling module, for being controlled based on kernel resources when the amount of free memory is less than the required memory size The grade of process in group recycles the corresponding memory of the process.
10. Memory recycle device according to claim 9, wherein described group of recycling module is specifically used for:
According to the grade sequence from low to high of the process in the kernel resources control group, to the process execute in be stored back to It receives, until the memory size of recycling is more than or equal to the process in the required memory size or the kernel resources control group Corresponding memory has been recovered.
11. Memory recycle device according to claim 9, wherein described group of recycling module include:
Target process selecting unit, be used for selection target process, the target process in the kernel resources control group into Corresponding memory size is maximum in journey and corresponding memory is not recovered, and the corresponding memory includes File Mapping memory and hides Name mapping memory;
File Mapping Memory recycle unit, for recycling the corresponding File Mapping memory of the target process;
Anonymity mapping Memory recycle unit, if the amount of free memory for obtaining after the File Mapping Memory recycle is less than Memory size needed for described recycles the corresponding anonymous mapping memory of the target process.
12. Memory recycle device according to claim 9, wherein the kernel resources control group includes multiple processes point Group includes that caching applies group in process grouping;
The Memory recycle device further include:
Process is grouped determining module, for being recovered when the corresponding memory of process in the kernel resources control group, and When amount of free memory in the system is less than the required memory size, the kernel resources control group middle grade is determined most Process grouping where low process;
Target process selecting module is used for selection target process, and the target process is where the elementary process Corresponding memory size is maximum in process grouping;
Described group of recycling module is specifically also used to apply the process in group lower than the caching when the grade of the target process When grade, the corresponding full memory of the target process is recycled.
13. Memory recycle device according to claim 9, wherein described group of recycling module is specifically used for:
Process other than the corresponding process of the related service is set as being stored back in participation by the related service for obtaining the application The process of receipts;
Based on the grade of the process in the kernel resources control group, it is corresponding to the process for participating in Memory recycle in deposit into Row recycling.
14. Memory recycle device according to claim 9, wherein
The kernel resources control group includes multiple process groupings, and the multiple process grouping includes one or more in following item : foreground application group, caching are using group, local basis service group, container group, binding service group and unbundlings service group;
Process in the kernel resources control group is configured as the type according to the corresponding service of the process, is added described more At least one of a process grouping.
15. Memory recycle device according to claim 14, wherein
The corresponding memory of process in the foreground application group is configured as without Memory recycle;
The corresponding memory of process when the corresponding process of the application is not that container applies corresponding process, in the container group It is configured as preferentially carrying out Memory recycle.
16. Memory recycle device according to claim 14, wherein
Process in each process grouping includes corresponding rank controlling value, and the rank controlling value is described right for identifying The grade of process is answered, the rank controlling value is bigger, and the lower grade of the corresponding process of the rank controlling value;
Process in the kernel resources control group is additionally configured to the rank controlling value according to the process, and the rank is added The corresponding process grouping of controlling value.
17. a kind of Memory recycle system, which is characterized in that including memory and processor;
The memory is for storing executable program code;
The processor is used to read the executable program code stored in the memory and requires to appoint in 1 to 8 with perform claim Method for recovering internal storage described in one.
18. a kind of computer readable storage medium, which is characterized in that
The computer readable storage medium includes instruction, when described instruction is run on computers, so that computer executes Such as method for recovering internal storage of any of claims 1-8.
CN201810151914.6A 2018-02-14 2018-02-14 Method for recovering internal storage, device, system and storage medium Pending CN110162396A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810151914.6A CN110162396A (en) 2018-02-14 2018-02-14 Method for recovering internal storage, device, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810151914.6A CN110162396A (en) 2018-02-14 2018-02-14 Method for recovering internal storage, device, system and storage medium

Publications (1)

Publication Number Publication Date
CN110162396A true CN110162396A (en) 2019-08-23

Family

ID=67635527

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810151914.6A Pending CN110162396A (en) 2018-02-14 2018-02-14 Method for recovering internal storage, device, system and storage medium

Country Status (1)

Country Link
CN (1) CN110162396A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764906A (en) * 2019-09-27 2020-02-07 Oppo(重庆)智能科技有限公司 Memory recovery processing method and device, electronic equipment and storage medium
CN111488316A (en) * 2020-04-12 2020-08-04 杭州迪普科技股份有限公司 File cache recovery method and device
CN112269655A (en) * 2020-10-15 2021-01-26 北京百度网讯科技有限公司 Memory mapping file cleaning method and device, electronic equipment and storage medium
CN113051066A (en) * 2019-12-27 2021-06-29 阿里巴巴集团控股有限公司 Memory management method, device, equipment and storage medium
CN116185644A (en) * 2023-04-26 2023-05-30 阿里云计算有限公司 Memory recycling control method, storage medium, processor and terminal equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103544063A (en) * 2013-09-30 2014-01-29 三星电子(中国)研发中心 Method and device for removing processes applied to Android platform
US20150026429A1 (en) * 2013-07-18 2015-01-22 International Business Machines Corporation Optimizing memory usage across multiple garbage collected computer environments
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN105446814A (en) * 2014-09-30 2016-03-30 青岛海信移动通信技术股份有限公司 Cache recovery method and device
CN106354562A (en) * 2016-08-25 2017-01-25 上海传英信息技术有限公司 Memory cleaning system and memory cleaning method
CN106843756A (en) * 2017-01-13 2017-06-13 中国科学院信息工程研究所 Memory pages recovery method and system based on page classifications
CN107038074A (en) * 2017-04-14 2017-08-11 努比亚技术有限公司 Internal memory optimization device and method based on associating policy
CN107168791A (en) * 2017-04-13 2017-09-15 北京安云世纪科技有限公司 Terminal Memory Optimize Method, device and mobile terminal under bright screen state
CN107220076A (en) * 2016-09-27 2017-09-29 华为技术有限公司 A kind of method for recovering internal storage and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150026429A1 (en) * 2013-07-18 2015-01-22 International Business Machines Corporation Optimizing memory usage across multiple garbage collected computer environments
CN103544063A (en) * 2013-09-30 2014-01-29 三星电子(中国)研发中心 Method and device for removing processes applied to Android platform
CN105446814A (en) * 2014-09-30 2016-03-30 青岛海信移动通信技术股份有限公司 Cache recovery method and device
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN106354562A (en) * 2016-08-25 2017-01-25 上海传英信息技术有限公司 Memory cleaning system and memory cleaning method
CN107220076A (en) * 2016-09-27 2017-09-29 华为技术有限公司 A kind of method for recovering internal storage and device
CN106843756A (en) * 2017-01-13 2017-06-13 中国科学院信息工程研究所 Memory pages recovery method and system based on page classifications
CN107168791A (en) * 2017-04-13 2017-09-15 北京安云世纪科技有限公司 Terminal Memory Optimize Method, device and mobile terminal under bright screen state
CN107038074A (en) * 2017-04-14 2017-08-11 努比亚技术有限公司 Internal memory optimization device and method based on associating policy

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764906A (en) * 2019-09-27 2020-02-07 Oppo(重庆)智能科技有限公司 Memory recovery processing method and device, electronic equipment and storage medium
CN110764906B (en) * 2019-09-27 2022-06-17 Oppo(重庆)智能科技有限公司 Memory recovery processing method and device, electronic equipment and storage medium
CN113051066A (en) * 2019-12-27 2021-06-29 阿里巴巴集团控股有限公司 Memory management method, device, equipment and storage medium
CN113051066B (en) * 2019-12-27 2024-05-28 阿里巴巴集团控股有限公司 Memory management method, device, equipment and storage medium
CN111488316A (en) * 2020-04-12 2020-08-04 杭州迪普科技股份有限公司 File cache recovery method and device
CN111488316B (en) * 2020-04-12 2023-09-22 杭州迪普科技股份有限公司 File cache recovery method and device
CN112269655A (en) * 2020-10-15 2021-01-26 北京百度网讯科技有限公司 Memory mapping file cleaning method and device, electronic equipment and storage medium
CN116185644A (en) * 2023-04-26 2023-05-30 阿里云计算有限公司 Memory recycling control method, storage medium, processor and terminal equipment

Similar Documents

Publication Publication Date Title
CN110162396A (en) Method for recovering internal storage, device, system and storage medium
US20190220418A1 (en) Memory Management Method and Apparatus
JP5510556B2 (en) Method and system for managing virtual machine storage space and physical hosts
US9229751B2 (en) Apparatus and method for managing virtual memory
US8775755B2 (en) Peer-to-peer transcendent memory
JP6658882B2 (en) Control device, VNF placement destination selection method and program
CN104461744A (en) Resource allocation method and device
CN102946413B (en) Method and system for resource preprocessing in dispatching and deployment performing process of virtual machine
CN103176845A (en) Method, system and device for virtual machine arrangement
CN111381928B (en) Virtual machine migration method, cloud computing management platform and storage medium
WO2008006674A1 (en) Reserve pool management in virtualized storage systems
CN103064797A (en) Data processing method and virtual machine management platform
US20190227918A1 (en) Method for allocating memory resources, chip and non-transitory readable medium
CN114860387A (en) I/O virtualization method of HBA controller for virtualized storage application
CN111562883B (en) Cache management system, method and device for solid state disk
US20220206836A1 (en) Method and Apparatus for Processing Virtual Machine Migration, Method and Apparatus for Generating Virtual Machine Migration Strategy, Device and Storage Medium
CN116089477B (en) Distributed training method and system
US20230273801A1 (en) Method for configuring compute mode, apparatus, and computing device
CN105900066A (en) Computer, and resource scheduling method using hypervisor
CN104281587A (en) Connection establishing method and device
CN114816665B (en) Hybrid arrangement system and virtual machine container resource hybrid arrangement method under super-fusion architecture
CN110447019B (en) Memory allocation manager and method for managing memory allocation performed thereby
CN116166413A (en) Lifecycle management for workloads on heterogeneous infrastructure
US20120124269A1 (en) Organizing Memory for Effective Memory Power Management
JPH04288638A (en) Computer system

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40012704

Country of ref document: HK

TA01 Transfer of patent application right

Effective date of registration: 20201211

Address after: Room 603, 6 / F, Roche Plaza, 788 Cheung Sha Wan Road, Kowloon, China

Applicant after: Zebra smart travel network (Hong Kong) Ltd.

Address before: Grand Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
RJ01 Rejection of invention patent application after publication

Application publication date: 20190823

RJ01 Rejection of invention patent application after publication