System memory recovery method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202280004217.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-18
- Publication Date
- 2024-11-26
AI Technical Summary
When the system memory is insufficient, the startup process of new services or new applications takes a long time, causing users to feel stuck and unresponsive. How to reduce the startup time of new services and new applications becomes a problem that needs to be solved.
By identifying abnormally occupied memory in the system, forced recycling is performed, predicting the memory required by the service, and allocating the required memory from the free memory of the system to ensure that the new service has enough free memory when it starts.
By predicting and forcibly recycling unreleased or infrequently used memory, we can reduce the startup time of new services, improve user experience, and avoid lags caused by insufficient memory.
Smart Images

Figure CN119032343A_ABST
Abstract
Description
System memory recovery method, device, electronic device and storage medium Technical Field
[0001] The present disclosure relates to the field of terminal technology, and in particular to a method, device, electronic device, and storage medium for reclaiming system memory. Background Art
[0002] In related technologies, when users need to run new services and applications, if there is no free space in the system memory, a recycling operation will be triggered, which will make the startup process of the new service or new application longer, causing users to feel lag and unresponsive. Therefore, how to reduce the startup time of new services and new applications has become a problem that needs to be solved.
[0003] Summary of the Invention
[0004] The present disclosure provides a system memory recovery method, device, electronic device and storage medium.
[0005] In a first aspect, the present disclosure provides a method for reclaiming system memory, comprising:
[0006] Identify the first memory in the system that is abnormally occupied;
[0007] Forcibly reclaiming the first memory to obtain free memory of the system;
[0008] In response to a first service being executed in the system, predicting a second memory required by the first service;
[0009] Allocate the required second memory for the first service from the free memory of the system.
[0010] In the embodiment of the present disclosure, unreleased or infrequently used memory in the system can be forcibly reclaimed by prediction before the first service runs, thereby providing sufficient free memory for the first service, reducing the startup time of the new service, and improving the user experience.
[0011] In a second aspect, the present disclosure provides a system memory recovery device, comprising:
[0012] An identification module, configured to identify a first memory in the system that is abnormally occupied;
[0013] A recycling module, configured to forcibly recycle the first memory to obtain free memory of the system;
[0014] a prediction module, configured to predict a second memory required by the first service in response to the first service being run in the system;
[0015] The allocation module is used to allocate the required second memory to the first service from the free memory of the system.
[0016] In a third aspect, the present disclosure provides an electronic device, including a memory and a processor;
[0017] The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the system memory recovery method of the embodiment of the first aspect of the present disclosure.
[0018] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the system memory recycling method of the embodiment of the first aspect of the present disclosure.
[0019] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which implements the system memory recycling method of the embodiment of the first aspect of the present disclosure when executed by a processor.
[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the background technology, the drawings required for use in the embodiments of the present disclosure or the background technology will be described below.
[0022] FIG1 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure;
[0023] FIG2 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure;
[0024] FIG3 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure;
[0025] FIG4 is a flowchart of a method for reclaiming system memory according to an embodiment of the present disclosure;
[0026] FIG5 is a structural diagram of a system memory recycling device according to an embodiment of the present disclosure;
[0027] FIG6 is a block diagram of an electronic device for implementing the system memory recycling method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] The following describes in detail embodiments of the present disclosure, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0029] The following describes the system memory recovery method, device, electronic device, and storage medium disclosed in the present disclosure with reference to the accompanying drawings. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0030] FIG1 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure. As shown in FIG1 , the method includes the following steps:
[0031] S101, identifying a first memory in the system that is abnormally occupied.
[0032] When using a terminal device, each time a new service or application is launched, a portion of the terminal device's running memory is occupied. Accordingly, when the service or application ends, the terminal device can actively or passively release the corresponding running memory to reserve sufficient memory space for subsequent services or applications. For example, the user can free up memory by clearing background applications, or the terminal device can actively free up memory based on memory usage.
[0033] The system can identify the usage of running memory. If there is memory in the system that has not been released after being used by certain third-party applications, and associated memory that is not frequently used, it can be regarded as the first memory that is abnormally occupied.
[0034] It should be noted that it is necessary to periodically identify the abnormally occupied first memory in the system to ensure that there is always free memory in the system. The identification period of the first memory can be manually controlled based on experience.
[0035] S102: Forcefully reclaim the first memory to obtain free memory of the system.
[0036] For the first memory that is abnormally occupied, it can be forcibly reclaimed without the user issuing an instruction, so that the system always maintains free memory and avoids lag caused by insufficient memory when the user opens a new application.
[0037] Optionally, artificial intelligence may be used to predict the weight coefficient of the first memory, and when forced recycling is performed, memory spaces with lower weight coefficients are cleared first.
[0038] S103 : In response to the first service being run in the system, predict a second memory required by the first service.
[0039] Alternatively, artificial intelligence or deep learning can be used to predict the services or applications that will be used later and the memory required while the first service is running, thereby obtaining the second memory required by the first service. Alternatively, the first service that the user is about to run can be predicted and the second memory required by the first service can be determined.
[0040] S104: Allocate the required second memory for the first service from the free memory of the system.
[0041] Optionally, the system's free memory can be determined based on the second memory required by the first service. If the system's free memory is greater than the second memory required by the first service, a memory region of the free memory is obtained, and the second memory required by the first service is allocated based on the memory region. If the system's free memory is less than the second memory required by the first service, it is necessary to continue to forcibly reclaim the abnormally occupied first memory before running subsequent services until the system's free memory is greater than the second memory required by the first service.
[0042] In an embodiment of the present disclosure, abnormally occupied first memory in the system is identified and forcibly reclaimed to obtain the system's free memory. In response to a first service in the system being run, the second memory required by the first service is predicted, and the second memory required is allocated to the first service from the system's free memory. Through prediction, the present disclosure allows for forcible reclaiming of unreleased or infrequently used memory in the system before the first service runs, thereby providing sufficient free memory for the first service, reducing the startup time of the new service, and improving the user experience.
[0043] FIG2 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure. As shown in FIG2 , identifying a first memory in the system that is abnormally occupied further includes the following steps:
[0044] S201, obtaining candidate memory in an occupied state in the system and the running state of the candidate service occupying the candidate memory.
[0045] Optionally, association is performed with a file device node in the system, candidate memory in an occupied state in the system is monitored, candidate services corresponding to the candidate memory are identified, and the operating state of the candidate services is determined using the monitoring system.
[0046] S202: Determine, based on the operating status, a first memory in the system that is abnormally occupied.
[0047] In some implementations, based on the running state, a second service that is not in the running state is obtained from the candidate services, and the candidate memory occupied by the second service is determined to be the first memory.
[0048] In some other implementations, a third service associated with the second service is obtained, and a third memory associated with the second service is occupied by the third service. An operating status of the third service is obtained, and in response to the operating status indicating that the third service is still operating, an occupancy frequency of the third memory is obtained, and in response to the occupancy frequency of the third memory being less than a set occupancy frequency, the third memory is determined to be the first memory.
[0049] In some further implementations, a third service in running state is obtained from the candidate services, and a third memory occupied by the third service is obtained. In response to the occupancy frequency of the third memory being less than a set occupancy frequency, the third memory is determined to be the first memory.
[0050] Optionally, the abnormally occupied first memory in the system can also be determined based on artificial intelligence prediction. In some implementations, if a candidate service occupying the candidate memory is determined to have an abnormality, such as residual memory, the artificial intelligence can obtain the residual memory and determine it as the abnormally occupied first memory.
[0051] In an embodiment of the present disclosure, candidate memory in an occupied state in the system and the operating state of the candidate service occupying the candidate memory are obtained, and based on the operating state, the first memory in the system that is abnormally occupied is determined. In an embodiment of the present disclosure, the first memory in the system that is abnormally occupied is determined based on the operating state of the candidate service and / or the occupancy frequency of the candidate memory, and then the first memory can be forcibly reclaimed to provide sufficient free memory for a new service that is subsequently started.
[0052] FIG3 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure. As shown in FIG3 , predicting the second memory required by the first service further includes the following steps:
[0053] S301, obtaining historical behavior data of a first service, and performing artificial intelligence prediction on the first service based on the historical behavior data to obtain a second memory required by the first service.
[0054] Alternatively, AI predictions can be performed based on the historical behavior data of a specific user, or based on the historical behavior data of a large number of users. For example, one can obtain the application services that any user is likely to use, and the services that any user subsequently uses after activating a particular service; or one can obtain the application services that a large number of users are likely to use, and the services that a large number of users subsequently use after activating a particular service.
[0055] As a possible implementation method, for any historical behavior data, the memory required to run the historical behavior data is obtained, and the historical behavior data is annotated based on the required memory to obtain sample behavior data. The sample behavior data is input into the constructed AI model, and the constructed AI model is trained and adjusted during the training process until the target AI model is generated after training.
[0056] The target AI model can make predictions based on the first service, obtain services that may be used subsequently, and determine the secondary memory required for the subsequent services. For example, when a shopping app is running, the target AI model predicts that a payment app may be used later and obtains the memory required for the payment app as the secondary memory. Alternatively, the target AI model can predict the first application that the user is about to run and determine the secondary memory required for the first service. For example, when lunchtime is approaching, the target AI model predicts that the user may use a food delivery app and obtains the memory required for the food delivery app as the secondary memory.
[0057] Optionally, when training a model based on historical behavior data, the weight of the user's individual historical behavior data can be controlled to be greater than the weight of the user's overall historical behavior data, so that the results of artificial intelligence predictions are more in line with the user's individual behavior habits.
[0058] In the disclosed embodiment, historical behavior data of a first service is obtained, and based on the historical behavior data, an artificial intelligence prediction is performed on the first service to obtain the second memory required by the first service. The method of the disclosed embodiment can predict the memory space required by the first service, and then forcibly reclaim the occupied memory based on the required memory space, providing sufficient free memory for the first service.
[0059] FIG4 is a flow chart of a method for reclaiming system memory according to an embodiment of the present disclosure. As shown in FIG4 , allocating the second memory required for the first service from the free memory of the system further includes the following steps:
[0060] S401, obtaining a memory area with continuous addresses in a free memory, and obtaining a first capacity of the memory area.
[0061] Identify free memory in the running memory, obtain memory regions with consecutive addresses in the free memory, and determine first capacities of the plurality of memory regions. For example, the system may have three free memory regions with first capacities of 50MB, 200MB, and 1GB, respectively.
[0062] S402: Allocate a target memory area for the first service based on the first capacity of the memory area and the second capacity of the second memory.
[0063] Compare the first capacity of the memory area with the second capacity of the second memory. If the first capacity is greater than the second capacity, preferentially allocate memory areas with continuous addresses to the first service. If the first capacity is not greater than the second capacity, select multiple memory areas for allocation to the first service.
[0064] For example, when the first capacity is greater than the second capacity, a first memory area having a greater capacity than the second capacity and a minimum difference between the first capacity and the second capacity is obtained, and the first memory area is allocated to the first service as a target memory area.
[0065] For another example, when there is no first capacity greater than the second capacity, multiple second memory areas are selected from the memory area, wherein the sum of the capacities of the second memory areas is greater than the second capacity, and the second memory areas are allocated to the first service as target memory areas.
[0066] In the disclosed embodiment, a memory region with consecutive addresses in the free memory is obtained, and a first capacity of the memory region is obtained. Based on the first capacity of the memory region and the second capacity of the second memory, a target memory region is allocated to the first service. In the disclosed embodiment, memory is allocated to the running first service based on the second memory so that the first service has sufficient free memory when it is started, thereby reducing the startup time of the first service and improving the user experience.
[0067] FIG5 is a structural diagram of a system memory recycling device according to an embodiment of the present disclosure. As shown in FIG5 , the system memory recycling device 500 includes:
[0068] An identification module 510 is configured to identify a first memory in the system that is abnormally occupied;
[0069] The recycling module 520 is used to forcibly recycle the first memory to obtain free memory of the system;
[0070] A prediction module 530, configured to predict a second memory required by the first service in response to the first service being run in the system;
[0071] The allocation module 540 is configured to allocate the required second memory to the first service from the free memory of the system.
[0072] In the embodiment of the present disclosure, unreleased or infrequently used memory in the system can be forcibly reclaimed by prediction before the first service runs, thereby providing sufficient free memory for the first service, reducing the startup time of the new service, and improving the user experience.
[0073] It should be noted that the above explanation of the embodiment of the system memory recycling method is also applicable to the system memory recycling device of this embodiment, and will not be repeated here.
[0074] Furthermore, in a possible implementation of the embodiment of the present disclosure, the identification module 510 is also used to: obtain the candidate memory in the system that is in an occupied state, and the running state of the candidate service that occupies the candidate memory; based on the running state, obtain a second service that is not in a running state from the candidate service; and determine that the candidate memory occupied by the second service is the first memory.
[0075] Furthermore, in a possible implementation of the embodiment of the present disclosure, the identification module 510 is also used to: obtain a third service associated with the second service, and the third service occupies a third memory associated with the second service; obtain the running status of the third service, and in response to the running status indicating that the third service is still in the running state, obtain the occupancy frequency of the third memory; in response to the occupancy frequency of the third memory being less than the set occupancy frequency, determine that the third memory is the first memory.
[0076] Furthermore, in a possible implementation of the embodiment of the present disclosure, the prediction module 530 is also used to: obtain historical behavior data of the first service, and perform artificial intelligence prediction on the first service based on the historical behavior data to obtain the second memory required by the first service.
[0077] Furthermore, in a possible implementation of the embodiment of the present disclosure, the allocation module 540 is also used to: obtain a memory area with continuous addresses in the free memory, and obtain the first capacity of the memory area; and allocate a target memory area to the first service based on the first capacity of the memory area and the second capacity of the second memory.
[0078] Furthermore, in a possible implementation of the embodiment of the present disclosure, the allocation module 540 is also used to: obtain a first memory area whose first capacity is greater than the second capacity and the difference between the first capacity and the second capacity is minimal; and allocate the first memory area as the target memory area to the first service.
[0079] Furthermore, in a possible implementation of the embodiment of the present disclosure, the allocation module 540 is also used to: select multiple second memory areas from the memory area, wherein the sum of the capacities of the second memory areas is greater than the second capacity; and allocate the second memory areas as target memory areas to the first service.
[0080] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0081] FIG6 shows a schematic block diagram of an example electronic device 60 that can be used to implement an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0082] As shown in FIG6 , the system includes a memory 61 , a processor 62 , and a computer program stored in the memory 61 and executable on the processor 62 . When the processor 62 executes the program, the aforementioned system memory recycling method is implemented.
[0083] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0084] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0085] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0086] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0087] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature identified as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, "plurality" means two or more, unless otherwise specifically defined.
[0088] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.
[0089] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A method for recovering system memory, characterized in that: include: Identify the first memory in the system that is abnormally occupied; Forcibly reclaiming the first memory to obtain free memory of the system; In response to a first service in the system being executed, predicting a second memory required by the first service; Allocate the second memory required by the first service from the free memory of the system.
2. The method according to claim 1, characterized in that The identifying system includes: Obtaining candidate memories in an occupied state in the system and the running states of candidate services occupying the candidate memories; Based on the running state, obtaining a second service that is not in the running state from the candidate services; Determine that the candidate memory occupied by the second service is the first memory.
3. The method according to claim 2, characterized in that The identifying system includes: Acquire a third service associated with the second service, and a third memory associated with the second service occupied by the third service; acquiring a running status of the third service, and in response to the running status indicating that the third service is still in a running state, acquiring an occupation frequency of the third memory; In response to the occupancy frequency of the third memory being less than the set occupancy frequency, the third memory is determined to be the first memory.
4. The method according to any one of claims 1 to 3, characterized in that The predicting the second memory required by the first service includes: Obtain historical behavior data of the first service, and perform artificial intelligence prediction on the first service based on the historical behavior data to obtain a second memory required by the first service.
5. The method according to claim 4, characterized in that The allocating the second memory required for the first service from the free memory of the system includes: Obtaining a memory area with continuous addresses in the free memory, and obtaining a first capacity of the memory area; A target memory area is allocated for the first service based on the first capacity of the memory area and the second capacity of the second memory.
6. The method according to claim 4, characterized in that The allocating a target memory area for the first service based on the first capacity of the memory area and the second capacity of the second memory includes: Acquire a first memory region in which the first capacity is greater than the second capacity and the difference between the first capacity and the second capacity is minimal; The first memory area is allocated to the first service as the target memory area.
7. The method according to claim 4, characterized in that The allocating a target memory area for the first service based on the first capacity of the memory area and the second capacity of the second memory includes: Selecting a plurality of second memory areas from the memory area, wherein the sum of the capacities of the second memory areas is greater than the second capacity; Allocate the second memory area as the target memory area to the first service.
8. A system memory recovery device, characterized in that: include: An identification module, configured to identify a first memory in the system that is abnormally occupied; a recycling module, configured to forcibly recycle the first memory to obtain free memory of the system; a prediction module, configured to predict a second memory required by a first service in response to the first service being run in the system; An allocation module is used to allocate the second memory required for the first service from the free memory of the system.
9. The device according to claim 8, characterized in that The identification module is further used to: Obtaining candidate memories in an occupied state in the system and the running states of candidate services occupying the candidate memories; Based on the running state, obtaining a second service that is not in the running state from the candidate services; Determine that the candidate memory occupied by the second service is the first memory.
10. The device according to claim 9, characterized in that The identification module is further used to: Acquire a third service associated with the second service, and a third memory associated with the second service occupied by the third service; acquiring a running status of the third service, and in response to the running status indicating that the third service is still in a running state, acquiring an occupation frequency of the third memory; In response to the occupancy frequency of the third memory being less than the set occupancy frequency, the third memory is determined to be the first memory.
11. The device according to any one of claims 8 to 10, characterized in that The prediction module is further configured to: Obtain historical behavior data of the first service, and perform artificial intelligence prediction on the first service based on the historical behavior data to obtain a second memory required by the first service.
12. The device according to claim 11, characterized in that The allocation module is further configured to: Obtaining a memory area with continuous addresses in the free memory, and obtaining a first capacity of the memory area; A target memory area is allocated for the first service based on the first capacity of the memory area and the second capacity of the second memory.
13. The device according to claim 11, characterized in that The allocation module is further configured to: Acquire a first memory region in which the first capacity is greater than the second capacity and the difference between the first capacity and the second capacity is minimal; The first memory area is allocated to the first service as the target memory area.
14. The device according to claim 11, characterized in that The allocation module is further configured to: Selecting a plurality of second memory areas from the memory area, wherein the sum of the capacities of the second memory areas is greater than the second capacity; Allocate the second memory area as the target memory area to the first service.
15. An electronic device, characterized in that: Including memory and processor; The processor reads the executable program code stored in the memory to run a program corresponding to the executable program code, so as to implement the method according to any one of claims 1 to 7.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
17. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 7.
