WO2021057623A1 - 内存回收方法、装置、电子设备及存储介质 - Google Patents

内存回收方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2021057623A1
WO2021057623A1 PCT/CN2020/116248 CN2020116248W WO2021057623A1 WO 2021057623 A1 WO2021057623 A1 WO 2021057623A1 CN 2020116248 W CN2020116248 W CN 2020116248W WO 2021057623 A1 WO2021057623 A1 WO 2021057623A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
memory recovery
recycling
cpu usage
ratio
Prior art date
Application number
PCT/CN2020/116248
Other languages
English (en)
French (fr)
Inventor
周华材
张诗明
Original Assignee
Oppo广东移动通信有限公司
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 Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2021057623A1 publication Critical patent/WO2021057623A1/zh

Links

Images

Classifications

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

Definitions

  • This application relates to the field of computer technology, and more specifically, to a memory recovery method, device, electronic equipment, and storage medium.
  • Memory also known as main memory, is a storage space that can be directly addressed by the CPU and is made of semiconductor devices.
  • the space of the memory in the electronic device is limited.
  • the system of the electronic device usually recycles the memory under certain circumstances.
  • this application proposes a memory recovery method, device, electronic equipment, and storage medium to improve the above-mentioned problems.
  • the present application provides a memory recycling method, the method includes: when entering a memory recycling scene, obtaining a CPU usage rate; obtaining a memory recycling ratio corresponding to the CPU usage rate, the memory recycling ratio characterizing The ratio between various memory recycling objects, wherein the higher the CPU usage rate corresponds to the memory recycling ratio, the lower the proportion of the memory recycling objects that need to consume CPU resources during recycling; the memory recycling is performed based on the memory recycling ratio .
  • the present application provides a memory recovery device.
  • the device includes: a processing information acquisition unit, configured to acquire a CPU usage rate when entering a memory recovery scenario; and a memory information acquiring unit, configured to acquire a connection with the CPU
  • the memory recycling ratio corresponding to the usage rate, the memory recycling ratio characterizing the ratio between various memory recycling objects, where the higher the CPU usage rate corresponds to the memory recycling ratio, among the memory recycling objects that need to consume CPU resources when recycling
  • the lower the proportion of, the memory recycling unit is used to perform memory recycling based on the memory recycling ratio.
  • the present application provides an electronic device including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors To achieve the above method.
  • the present application provides a computer-readable storage medium in which program code is stored, wherein the above-mentioned method is executed when the program code is run by a processor.
  • Fig. 1 shows a flow chart of a method for reclaiming memory provided by an embodiment of the present application.
  • FIG. 2 shows a schematic diagram of multiple periodic time periods in a memory recycling method proposed by an embodiment of the present application.
  • Fig. 3 shows a flow chart of a method for reclaiming memory provided by another embodiment of the present application.
  • FIG. 4 shows a schematic diagram of an application program running in multiple periodic time periods in a memory recycling method proposed in an embodiment of the present application.
  • Fig. 5 shows a flow chart of a method for reclaiming memory proposed in another embodiment of the present application.
  • Fig. 6 shows a structural block diagram of a memory recovery device proposed in an embodiment of the present application.
  • FIG. 7 shows a structural block diagram of a memory recovery device proposed by another embodiment of the present application.
  • FIG. 8 shows a structural block diagram of a memory recovery device proposed by another embodiment of the present application.
  • FIG. 9 shows a structural block diagram of an electronic device for executing the memory recycling method according to an embodiment of the present application in real time of the present application.
  • FIG. 10 shows a storage unit used to store or carry the program code for implementing the memory recovery method according to the embodiment of the present application in real time of the present application.
  • memory reclamation is a relatively common mechanism.
  • the system needs to provide enough memory for memory applications that come in bursts at any time, so that the use of cache and other related memory will not keep the remaining memory of the system in a very long time. Less state. Also, when an application that is larger than the free memory arrives, it will also trigger memory reclamation.
  • take the Android operating system as an example.
  • the Android operating system there are mainly two memory recovery mechanisms.
  • One is a recycling mechanism based on the kswapd process.
  • the kswapd process runs in the background periodically.
  • the other is a recycling mechanism based on the direct reclaim process.
  • the direct reclaim process starts memory recycling when it receives a memory allocation request. Therefore, it can be found that the memory recovery parameters of the related memory mode are relatively fixed.
  • the inventor proposes that in this application, when the memory recovery ratios corresponding to different CPU usage rates are different, the CPU usage rate can be obtained at the beginning of the memory recovery, and then the current CPU usage rate determines the recovery of multiple types of memory How much each object should be recycled, thereby increasing the flexibility of the memory recycling process.
  • Memory recycling methods, devices, electronic equipment, and storage media and because the higher the CPU usage rate corresponds to the memory recycling ratio, the recycling requires CPU resources. The lower the proportion of the memory recycling objects, the more memory recycling objects that do not consume CPU resources or a small amount of CPU resources can be recycled when the CPU usage rate is high, thereby improving the fluency of electronic devices.
  • FIG. 1 shows a memory recovery method provided by an embodiment of the present application, and the method includes:
  • Step S110 Obtain the CPU usage rate when entering the memory recycling scene.
  • the current memory recovery scenario is entered.
  • the running environment of this embodiment is the Android operating system
  • the method of obtaining the CPU usage rate in this embodiment includes: obtaining the CPU usage rate corresponding to the one historical time period closest to the current moment in the periodic multiple historical time periods as the obtained CPU usage rate. In this way, for each time period, the CPU usage rate can be calculated based on the CPU idle time in each time period and the total CPU usage time.
  • 0 to t1 is a periodic time period
  • t1 to t2 is a periodic time period
  • t2 to t3 is a periodic time period
  • t3 to t4 is a periodic time period. segment.
  • the position pointed by the arrow is the current time
  • the corresponding historical time period closest to the current time among the periodic multiple historical time periods is the time period from t3 to t4.
  • the CPU time accumulated in the user mode from the start of the system to the current moment excluding processes with a negative value of nice.
  • nice represents the CPU time occupied by processes with a negative nice value from the start of the system to the current moment.
  • the system characterizes the core time accumulated from the start of the system to the current moment.
  • Idle represents the waiting time other than the IO waiting time accumulated from the start of the system to the current moment.
  • Iowait characterizes the IO wait time accumulated from the start of the system to the current moment.
  • irq characterizes the hard interruption time accumulated from the start of the system to the current moment.
  • softirq characterizes the soft interruption time accumulated from the start of the system to the current moment.
  • the CPU occupancy rate is the ratio between the currently used CPU processing resources and the total CPU processing resources.
  • Step S120 Obtain a memory recycling ratio corresponding to the CPU usage rate, where the memory recycling ratio represents the ratio between a variety of memory recycling objects, where the higher the CPU usage rate corresponds to the memory recycling ratio in the case of recycling The lower the proportion of memory recycling objects that need to consume CPU resources.
  • a plurality of mapping relationships between CPU usage rates and corresponding memory recycling ratios are pre-stored in the electronic device. Then after the electronic device obtains the CPU usage rate, it can match the obtained CPU usage rate with the aforementioned multiple CPU usage rates, and then match the CPU usage rate among the multiple CPU usage rates with the obtained CPU usage rate
  • the corresponding memory recovery ratio is used as the memory recovery ratio corresponding to the CPU usage rate. For example, suppose that the multiple CPU usage rates stored in the electronic device include a CPU usage rate A, a CPU usage rate B, a CPU usage rate C, and a CPU usage rate D.
  • CPU usage rate A corresponds to a memory recycling ratio of 0:200
  • CPU usage rate B corresponds to a memory recycling ratio of 40:160
  • CPU usage rate C corresponds to a memory recycling ratio of 80:120
  • CPU usage rate D corresponds to a memory recycling ratio. 200:0. Then, after obtaining the CPU usage rate X, match the CPU usage rate X with the aforementioned CPU usage rate A, CPU usage rate B, CPU usage rate C, and CPU usage rate D. If the CPU usage rate X matches the CPU usage If the rate C matches, the corresponding memory recovery ratio is 80:120.
  • Step S130 Perform memory recovery based on the memory recovery ratio.
  • the CPU usage rate when entering the memory recycling scene, the CPU usage rate is obtained, and then the memory recycling ratio corresponding to the CPU usage rate representing the ratio between various memory recycling objects is obtained, based on the The memory recycling ratio performs memory recycling. Therefore, when the memory recycling ratios corresponding to different memory recycling scenarios are different, the current memory recycling scene can be obtained at the beginning of the memory recycling, and then the current memory recycling scene can be used to determine how much of each memory recycling object should be recycled. , Thereby improving the flexibility of the memory recovery process, and because the higher the CPU usage rate corresponds to the memory recovery ratio, the lower the proportion of memory recovery objects that need to consume CPU resources during recovery, and thus the higher the CPU usage rate. At the same time, more recycling does not consume CPU resources or a small amount of memory recycling objects that consume CPU resources, improving the fluency of electronic devices.
  • a memory recovery method provided by an embodiment of the present application, the method includes:
  • Step S210 When entering the memory recycling scene, obtain the CPU usage rate in a specified time period.
  • the step of obtaining the CPU usage rate in a specified time period includes: taking a historical time period closest to the current time among the multiple periodic historical time periods as the specified time period; obtaining the stored information based on the The CPU usage rate calculated from the CPU idle time in the specified time period and the total CPU usage time.
  • the start time is 0 and the end time is t1.
  • the start time is t2
  • the end time is t3.
  • the CPU usage rate corresponding to each time period reflects the CPU usage in each time period, and in some cases, the CPU usage rate changes more frequently. If the CPU usage rate of the previous time period is used to calculate the memory allocation ratio in this time period, it can reflect the actual CPU usage to a certain extent, but it cannot reflect the current real-time situation very well.
  • the CPU usage in some time periods is very similar.
  • the similar CPU usage may be because the running applications are similar or the same.
  • there are application A, application B, and application C running and correspondingly, there are also application A, application B, and application A during the time period t4 to t5.
  • Application C is running, then it can be understood that the time period from t4 to t5 is the same or similar to the time period from t1 to t2.
  • the step of obtaining the CPU usage rate within a specified time period includes: obtaining current application program characteristic parameters, the application program characteristic parameters representing the degree of occupancy of CPU processing resources by the application program;
  • the target historical time period corresponding to the time period at the current moment calculated by the application feature parameter is used as the designated time period; and the stored CPU usage rate in the designated time period is obtained.
  • the electronic device may calculate the application feature parameters corresponding to the time period at the start time and the end time of each time period.
  • the application detected at the beginning of the time period can be an estimate of which applications will run in this time period, so that the same target time period can be calculated more quickly, and when The applications detected at the end of the time period can clearly confirm which applications are actually running in this time period. Therefore, the application feature parameters corresponding to this time period calculated in this time period can be used to compare the same target time period in subsequent time periods, and the current application feature parameters can be calculated at the beginning of each time period. It is possible to estimate the same target time period as the current time period before the current time period ends, so that the corresponding memory recovery ratio can be obtained more quickly and timely.
  • the current application program characteristic parameters it may be the ratio of the number of threads currently started by the application program to the total number of threads that can be processed in parallel by the CPU.
  • application A, application B, application C, and application D are currently running, and application A corresponds to a thread running, application B corresponds to b threads running, and application C corresponds to There are c threads running, and application D corresponds to d threads running.
  • the corresponding current application characteristic parameter is (a+b+c+d)/m.
  • the calculation of the application program characteristic parameters at the end of each time period is the ratio of the average number of threads of all applications in the current time period to the total number of threads that can be processed in parallel by the CPU.
  • application B, application C, and application D are running, and application B has run t threads, application C has run k threads, and application D has run l Thread.
  • the characteristic parameter of the application program in this time period is (t+k+l)/3/m.
  • the step of setting the target historical time period corresponding to the time period at the current moment calculated based on the application feature parameter as the designated time period includes: combining the current application feature parameter with the multiple Compare the application feature parameters of each historical time period; take the historical time period in which the corresponding application feature parameter is the same as the current application feature parameter as the corresponding target historical time period; take the target historical time period as Specify the time period.
  • the method further includes: obtaining the number and priority of applications running in each time period, wherein the higher the priority, the higher the memory occupied during the historical operation; A first score corresponding to the number; obtaining a second score corresponding to the priority; calculated based on the first score and the corresponding first preset weight, and the second score and the corresponding second preset weight The characteristic parameters of the application corresponding to each time period.
  • the same CPU usage rate may also correspond to different memory recycling ratios.
  • the current memory reclamation scenario can be confirmed based on multiple methods.
  • the identifier of the process currently performing memory recycling can be identified; and the current memory recycling scene can be determined according to the identifier. It is understandable that memory recycling in an electronic device is performed by a specific process. For example, the aforementioned kswapd process or direct reclaim process. Then in this way, it is possible to periodically detect which processes are currently running. When it is detected that the identifier of a specific process for memory recovery is the running process identifier, it is determined to be in the memory recovery corresponding to the identifier. Scenes. For example, if the identification of the process currently performing memory recovery is "kswapd", then the corresponding identification is currently the kswapd memory recovery scenario. If the identification of the process that is currently performing memory reclamation is "direct reclaim", then the corresponding identification is currently a direct reclaim memory reclamation scenario.
  • the current memory recovery scenario can also be determined according to the currently running application.
  • the memory recycling objects mentioned in the embodiment may include anonymous pages (Anonymous pages) and file pages (File pages).
  • anonymous pages can be understood as pages without a file background, such as heaps, stacks, data segments, etc., which do not exist in the form of files.
  • a file page can be understood as a page with a file background. For example, for the data stored in the file page, the corresponding data can be found in the disk.
  • this embodiment mainly focuses on detecting applications running in the foreground.
  • the name of the application currently running in the foreground can be obtained by executing the getRunningTasks method of the ActivityManager.
  • the electronic device can also obtain a list of programs used by the user through the UsageStatsManager, and identify the most recently used application recorded in the list as the current foreground application.
  • Step S220 Obtain a memory recycling ratio corresponding to the CPU usage rate, where the memory recycling ratio represents the ratio between a variety of memory recycling objects, where the higher the CPU usage rate corresponds to the memory recycling ratio in the case of recycling The lower the proportion of memory recycling objects that need to consume CPU resources.
  • each memory recovery scenario may correspond to a memory recovery ratio, which is used as the memory recovery ratio corresponding to the CPU usage rate obtained in the memory recovery scenario. Then in this way, after entering the memory reclamation scene, the type of the memory reclamation scene can be obtained first, and then the mapping relationship between the CPU usage rate and the memory reclamation ratio corresponding to the type of the memory reclamation scene can be obtained, as the preceding step ( For example, the memory recovery ratio corresponding to the CPU usage rate obtained in step S210 or step S110).
  • the ratio in this embodiment can be understood as the ratio between anonymous pages and document pages.
  • the ratio corresponding to the label "direct reclaim” is "0:200", which means that only document pages are reclaimed, but anonymous pages are not reclaimed.
  • the ratio corresponding to the mark “kswapd” is "200:0”, which means that only anonymous pages are reclaimed, not document pages.
  • the ratio can also be changed as needed.
  • the ratio corresponding to the process marked as "direct reclaim” can also be 50:150 to indicate that file pages are recycled as much as possible, and anonymous pages are recycled in a small amount.
  • the corresponding relationship between the application program and the memory recovery ratio can be established in advance. Then, after detecting that the memory recycling process starts running, obtain the currently running application, and then query the ratio corresponding to the running application as the memory recycling ratio corresponding to the CPU usage of the current memory recycling scenario.
  • Application ID proportion Application A 10 190 Application B 20: 180 Application C 30: 170
  • each application identifier has a corresponding memory recovery ratio. Among them, the higher the proportion of file pages, the more quickly the performance of memory recovery is required. Then after it is detected that a process that performs memory recycling starts running, if it is detected that application A is currently running, then correspondingly, the ratio "10:190" corresponding to application A is used as the memory recycling ratio. If it is detected that application B is currently running, then correspondingly, the ratio "20:180" corresponding to application B is used as the memory recovery ratio.
  • the proportion corresponding to the current scene can be determined by combining the proportion corresponding to the process itself and the proportion of the currently running application program.
  • the ratio corresponding to the process identifier "direct reclaim” is "0:200”
  • the ratio corresponding to application A is "10:190”
  • the proportion corresponding to the running application can be compared with the proportion corresponding to the identification of the process of load memory reclaiming currently in the running state
  • the average value is taken as the memory recycling ratio of the current memory recycling scenario, so that the memory recycling ratio corresponding to the process can be met to a certain extent, and the application's demand for the memory recycling ratio can also be met to a certain extent.
  • the ratio corresponding to the process identifier “direct reclaim” is “0:200”
  • the ratio corresponding to application A is "10:190”
  • the proportion corresponding to the running application can be compared with the proportion corresponding to the identification of the process of load memory reclaiming currently in the running state
  • the average value is taken as the memory recycling ratio
  • a specific application can be marked by creating a list. Then, in this way, in order to quickly determine whether the current application is the aforementioned specific application (application configured with a memory recovery ratio), optionally, when a specific application is started, generate An accompanying file in which the identification of the specific application currently running is written.
  • the memory recovery ratio corresponding to the application recorded in the accompanying file is compared with the currently started responsible memory
  • the memory recycling ratios corresponding to the recycled processes are combined (for example, the aforementioned averaging) to obtain the memory recycling ratio corresponding to the current memory recycling scenario. If it is detected that no accompanying file exists, the memory recovery ratio corresponding to the process responsible for memory recovery is directly used as the memory recovery ratio corresponding to the current memory recovery scenario.
  • the current memory recovery scenario by detecting the application program. It is also possible to determine the current memory reclamation scenario by predicting which applications will be launched soon. For example, in one manner, some application programs of the electronic device are started regularly, for example, an alarm clock program. Or some applications will be launched routinely during a certain time period of the day due to the user's usage habits. For example, take-out applications may be routinely launched every day when they are close to the meal, or video applications may be routinely launched by users when they take the subway every day.
  • Step S230 Perform memory recovery based on the memory recovery ratio.
  • a memory recycling method provided by this application when entering a memory recycling scene, obtains the CPU usage rate in a specified time period, and then obtains the memory recycling corresponding to the CPU usage rate, which characterizes the ratio between various memory recycling objects Ratio, memory recycling is performed based on the memory recycling ratio. Therefore, when the memory recycling ratios corresponding to different memory recycling scenarios are different, the current memory recycling scene can be obtained at the beginning of the memory recycling, and then the current memory recycling scene can be used to determine how much of each memory recycling object should be recycled.
  • a memory recovery method provided by an embodiment of the present application, the method includes:
  • Step S310 Obtain the CPU usage rate when entering the memory recycling scene.
  • Step S320 Obtain a memory recycling ratio corresponding to the CPU usage rate, where the memory recycling ratio represents the ratio between a variety of memory recycling objects, where the higher the CPU usage rate corresponds to the memory recycling ratio when reclaiming The lower the proportion of memory recycling objects that need to consume CPU resources.
  • Step S330 Perform memory recovery based on the memory recovery ratio.
  • Step S340 Obtain the memory recovery target corresponding to the current memory recovery scenario.
  • Step S350 Determine the memory recovery target corresponding to each of the various memory recovery objects based on the memory recovery ratio.
  • Step S360 If there is a memory recovery target corresponding to a single memory recovery object, which is greater than the current reclaimable memory amount of the single memory recovery object, obtain a memory difference value, where the memory difference value is the memory recovery corresponding to the single memory recovery object The difference between the target and the current amount of reclaimable memory.
  • the memory recovery target corresponding to the current memory recovery scenario is obtained, and the object that has not completed the memory recovery target is the pending memory recovery Object. Then calculate the difference between the memory recovery target corresponding to the to-be-processed memory recovery object and the current reclaimable memory amount as the aforementioned memory difference, and then further recover the memory corresponding to the memory difference from other memory recovery objects. In order to not only perform memory recovery according to the established memory recovery ratio, but also complete the established memory recovery goal.
  • Step S370 Add a memory recovery target corresponding to a memory recovery object other than the single memory recovery object to meet the memory recovery target corresponding to the current memory recovery scenario.
  • the configuration of multiple memory recycling methods is mainly to improve the efficiency of memory recycling.
  • the recovery costs of different memory recovery objects are different.
  • the increase is the amount of recycling of memory recycling objects with lower memory recycling efficiency, it may not be conducive to improving the overall recycling efficiency.
  • the multiple memory recovery objects include anonymous pages and file pages
  • the method further includes: if a memory recovery target is added The memory reclamation object of is the file page; the memory reclamation target corresponding to the memory reclamation object other than the single memory reclamation object is added; if the memory reclamation object of the memory reclamation target is increased, the anonymous page; the single memory reclamation object is not added The memory recovery target corresponding to the memory recovery object other than that.
  • the overall memory recovery efficiency can be improved.
  • step S330 and step S370 can be performed in parallel by multiple processes, so as to improve the recovery efficiency.
  • the CPU usage rate when entering the memory recycling scene, the CPU usage rate is obtained, and then the memory recycling ratio corresponding to the CPU usage rate representing the ratio between various memory recycling objects is obtained, based on the The memory recycling ratio performs memory recycling. Therefore, when the memory recycling ratios corresponding to different memory recycling scenarios are different, the current memory recycling scene can be obtained at the beginning of the memory recycling, and then the current memory recycling scene can be used to determine how much of each memory recycling object should be recycled. , Thereby improving the flexibility of the memory recovery process, and because the higher the CPU usage rate corresponds to the memory recovery ratio, the lower the proportion of memory recovery objects that need to consume CPU resources during recovery, and thus the higher the CPU usage rate. At the same time, more recycling does not consume CPU resources or a small amount of memory recycling objects that consume CPU resources, improving the fluency of electronic devices.
  • the device 400 includes:
  • the processing information acquiring unit 410 is configured to acquire the CPU usage rate when entering the memory recycling scene.
  • the processing information acquiring unit 410 is specifically configured to acquire the CPU usage rate when entering the memory recycling scene.
  • the processing information acquiring unit 410 is specifically configured to set the period of the periodic historical time period closest to the current time as the designated time period; acquire the stored CPU idle time based on the designated time period and The CPU usage rate calculated by the total CPU usage time.
  • the processing information acquiring unit 410 is specifically configured to acquire current application program feature parameters, where the application program feature parameters represent the degree of CPU processing resource occupancy of the application program; and calculated based on the application program feature parameters and the current time
  • the target historical time period corresponding to the time period is the designated time period; the stored CPU usage rate in the historical designated time period is obtained.
  • the processing information acquisition unit 410 is specifically configured to compare the current application feature parameters with the application feature parameters of multiple historical time periods; compare the corresponding application feature parameters with the The historical time period with the same characteristic parameter of the current application is taken as the corresponding target historical time period; the target historical time period is taken as the designated time period.
  • the device 410 further includes:
  • the characteristic parameter calculation unit 411 is used to obtain the number and priority of applications running in each time period, wherein the higher the priority, the higher the memory occupied during the historical running process; the obtaining corresponds to the number Obtain the second score corresponding to the priority; calculate each of the first scores and the corresponding first preset weights, and the second scores and the corresponding second preset weights.
  • the characteristic parameter of the application corresponding to the time period.
  • the memory information acquiring unit 420 is configured to acquire a memory recycling ratio corresponding to the CPU usage rate, where the memory recycling ratio represents the ratio between various memory recycling objects, where the higher the CPU usage rate corresponds to the memory In the recycling ratio, the lower the proportion of memory recycling objects that need to consume CPU resources during recycling.
  • the memory recycling unit 430 is configured to perform memory recycling based on the memory recycling ratio.
  • the device 400 further includes:
  • the incremental memory recovery unit 440 is configured to obtain the memory recovery target corresponding to the current memory recovery scenario; determine the memory recovery target corresponding to each of the various memory recovery objects based on the memory recovery ratio; if there is a memory corresponding to a single memory recovery object The recovery target is greater than the current reclaimable memory amount of the single memory reclaimed object, and the memory difference is obtained, where the memory difference is the difference between the memory reclaim target corresponding to the single memory reclaimed object and the current reclaimable memory amount Value; increase the memory recovery target corresponding to the memory recovery object other than the single memory recovery object to meet the memory recovery target corresponding to the current memory recovery scenario.
  • the multiple types of memory recycling objects include anonymous pages and file pages.
  • the memory incremental recovery unit 440 is further configured to: if the memory recovery object of the increased memory recovery target is a file page; execute the increase of the memory recovery target corresponding to the memory recovery object other than the single memory recovery object; if the memory recovery target is increased The memory recovery object is an anonymous page; the memory recovery target corresponding to the memory recovery object other than the single memory recovery object is not increased.
  • an embodiment of the present application also provides another electronic device 100 that can execute the foregoing memory recovery method.
  • the electronic device 100 includes one or more (only one is shown in the figure) a processor 102, a memory 104, and a network module 106 coupled to each other.
  • the memory 104 stores a program that can execute the content in the foregoing embodiment, and the processor 102 can execute the program stored in the memory 104.
  • the processor 102 may include one or more processing cores.
  • the processor 102 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes by running or executing instructions, programs, code sets, or instruction sets stored in the memory 104, and calling data stored in the memory 104.
  • the processor 102 may use at least one of digital signal processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA).
  • DSP Digital Signal Processing
  • FPGA Field-Programmable Gate Array
  • PLA Programmable Logic Array
  • the processor 102 may be integrated with one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), a modem, and the like.
  • the CPU mainly processes the operating system, user interface, and application programs;
  • the GPU is used for rendering and drawing of display content;
  • the modem is used for processing wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 102, but may be implemented by a communication chip alone.
  • the memory 104 may include random access memory (RAM) or read-only memory (Read-Only Memory).
  • the memory 104 may be used to store instructions, programs, codes, code sets or instruction sets.
  • the memory 104 may include a program storage area and a data storage area.
  • a memory recovery device may be stored in the memory 104.
  • the memory recovery device may be the aforementioned device 400.
  • the storage program area can store instructions used to implement the operating system, instructions used to implement at least one function (such as touch function, sound playback function, image playback function, etc.), and instructions used to implement the following various method embodiments Wait.
  • the data storage area can also store data (such as phone book, audio and video data, chat record data) created by the terminal 100 during use.
  • the network module 106 is used to receive and send electromagnetic waves, and realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other equipment, such as communicating with an audio playback device.
  • the network module 106 may include various existing circuit elements for performing these functions, for example, an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a subscriber identity module (SIM) card, a memory, etc. .
  • SIM subscriber identity module
  • the network module 106 can communicate with various networks, such as the Internet, an intranet, and a wireless network, or communicate with other devices through a wireless network.
  • the aforementioned wireless network may include a cellular telephone network, a wireless local area network, or a metropolitan area network.
  • the network module 106 can exchange information with the base station.
  • FIG. 10 shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application.
  • the computer-readable medium 800 stores program code, and the program code can be invoked by a processor to execute the method described in the foregoing method embodiment.
  • the computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium.
  • the computer-readable storage medium 800 has storage space for the program code 810 for executing any method steps in the above-mentioned methods. These program codes can be read from or written into one or more computer program products.
  • the program code 810 may be compressed in a suitable form, for example.
  • the memory recycling method, device, electronic device, and storage medium when entering the memory recycling scene, obtain the CPU usage rate, and then obtain a variety of memory recycling characteristics corresponding to the CPU usage rate
  • the memory recycling ratio of the ratio between the objects, and the memory recycling is performed based on the memory recycling ratio. Therefore, when the memory recycling ratios corresponding to different memory recycling scenarios are different, the current memory recycling scene can be obtained at the beginning of the memory recycling, and then the current memory recycling scene can be used to determine how much of each memory recycling object should be recycled. , Thereby improving the flexibility of the memory recovery process, and because the higher the CPU usage rate corresponds to the memory recovery ratio, the lower the proportion of memory recovery objects that need to consume CPU resources during recovery, and thus the higher the CPU usage rate. At the same time, more recycling does not consume CPU resources or memory recycling objects that consume CPU resources, which improves the fluency of electronic devices.

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

本申请实施例公开了一种内存回收方法、装置、电子设备及存储介质。所述方法包括:当进入内存回收场景时,获取CPU使用率;获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低;基于所述内存回收比例进行内存回收。从而使得在不同内存回收场景对应的内存回收比例不同的情况下,可以在内存回收开始时先获取当前的内存回收场景的CPU使用率,然后根据当前的内存回收场景的CPU使用率来确定对于多种内存回收对象该各自回收多少,进而提升了内存回收过程的灵活性并且提升电子设备的流畅性。

Description

内存回收方法、装置、电子设备及存储介质
相关申请的交叉引用
本申请要求于2019年9月27日提交的申请号为201910925510.2的中国申请的优先权,其在此出于所有目的通过引用将其全部内容并入本文。
技术领域
本申请涉及计算机技术领域,更具体地,涉及一种内存回收方法、装置、电子设备及存储介质。
背景技术
内存又称主存,是CPU能直接寻址的存储空间,由半导体器件制成。电子设备中的内存的空间是有限的,为了保证***有足够的内存可以使用,电子设备的***通常会在一定的情况下进行内存回收。但是,在相关的内存回收方式中,还缺乏一定的灵活性。
发明内容
鉴于上述问题,本申请提出了一种内存回收方法、装置、电子设备及存储介质,以改善上述问题。
第一方面,本申请提供了一种内存回收方法,所述方法包括:当进入内存回收场景时,获取CPU使用率;获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低;基于所述内存回收比例进行内存回收。
第二方面,本申请提供了一种内存回收装置,所述装置包括:处理信息获取单元,用于当进入内存回收场景时,获取CPU使用率;内存信息获取单元,用于获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低;内存回收单元,用于基于所述内存回收比例进行内存回收。
第三方面,本申请提供了一种电子设备,包括一个或多个处理器以及存储器;一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行以实现上述的方法。
第四方面,本申请提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码被处理器运行时执行上述的方法。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请一实施例提出的一种内存回收方法的流程图。
图2示出了本申请一实施例提出的一种内存回收方法中周期性的多个时间段的示意图。
图3示出了本申请另一实施例提出的一种内存回收方法的流程图。
图4示出了本申请一实施例提出的一种内存回收方法中周期性的多个时间段中应用程序运行的示意图。
图5示出了本申请再一实施例提出的一种内存回收方法的流程图。
图6示出了本申请实施例提出的一种内存回收装置的结构框图。
图7示出了本申请再一实施例提出的一种内存回收装置的结构框图。
图8示出了本申请另一实施例提出的一种内存回收装置的结构框图。
图9示出了本申请实时中的用于执行根据本申请实施例的内存回收方法的电子设备的结构框图。
图10示出了本申请实时中的用于保存或者携带实现根据本申请实施例的内存回收方法的程序代码的存储单元。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
对于操作***而言,因为内存本身的大小是有限的,所以内存回收是一个较为普遍的机制。而之所以要进行内存回收,主要原因有两个:***需要为任何时刻突发到来的内存申请提供足够的内存,以便cache的使用和其他相关内存的使用不至于让***的剩余内存长期处于很少的状态。还有,当有大于空闲内存的申请到来的时候,也会触发内存回收。
而发明人在对相关的内存回收过程进行研究后发现,相关的内存回收方式中,还缺乏一定的灵活性。例如,以Android操作***为例。在Android操作***中,主要存在有两种内存回收机制。一种是基于kswapd进程的回收机制,在这种回收机制中,kswapd进程定期在后台运行。另一种是基于direct reclaim进程的回收机制,在这种回收机制中,direct reclaim进程在接收到内存分配需求时,开始进行内存回收。因此,可以发现相关的内存方式的内存回收参数较为固定。
因此,发明人提出了本申请中的在不同CPU使用率对应的内存回收比例不同的情况下,可以在内存回收开始时先获取CPU使用率,然后根据当前的CPU使用率确定对于多种内存回收对象该各自回收多少,进而提升了内存回收过程的灵活性的内存回收方法、装置、电子设备及存储介质,并且因为所 述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低,进而可以在CPU使用率较高时,更多的回收不消耗CPU资源或者少量消耗CPU资源的内存回收对象,提升电子设备的流畅性。
下面将结合附图具体描述本申请的各实施例。
请参阅图1,示出了本申请实施例提供的一种内存回收方法,所述方法包括:
步骤S110:当进入内存回收场景时,获取CPU使用率。
在本申请实施例中,可以有多种方式来检测当前是否处于内存回收场景。
其中,作为一种方式,可以在检测到有负责进行内存回收的进程开始运行时,判定当前进入内存回收场景。例如,若本实施例所运行的环境为Android操作***,那么可以在检测到有kswapd进程或者direct reclaim进程运行时,判定当前进入内存回收场景。
在本申请实施例中可以有多种方式来获取CPU使用率。
作为一种方式,在本实施例中获取CPU使用率的方式包括:获取在周期性的多个历史时间段中距离当前时刻最近的一个历史时间段对应的CPU使用率作为获取的CPU使用率。在这种方式下,对于每个时间段可以基于每个时间段内的CPU空闲时间以及CPU总使用时间计算得到CPU使用率。
例如,如图2所示,0到t1为一个周期性的时间段,t1到t2为一个周期性的时间段,t2到t3为一个周期性的时间段,t3到t4为一个周期性的时间段。而其中箭头所指的位置为当前时刻,那么对应的在周期性的多个历史时间段中距离当前时刻最近的一个历史时间段为t3到t4这个时间段。
示例性的,在t3到t4时间段CPU总使用时间=(user2+nice2+system2+idle2+iowait2+irq2+softirq2)-(user1+nice1+system1+idle1+iowait1+irq1+softirq1),在t3到t4时间段CPU空闲时间=(idle2-idle1),CPU在t3到t4时间段的使用率=1-CPU空闲使用时间/CPU总的使用时间。
其中,user:从***启动开始累计到当前时刻,用户态的CPU时间,不包含nice值为负进程。nice表征从***启动开始累计到当前时刻,nice值为负的进程所占用的CPU时间。system表征从***启动开始累计到当前时刻,核心时间。idle表征从***启动开始累计到当前时刻,除IO等待时间以外的其它等待时间。iowait表征从***启动开始累计到当前时刻,IO等待时间。irq表征从***启动开始累计到当前时刻,硬中断时间。softirq表征从***启动开始累计到当前时刻,软中断时间。
作为另外一种方式,可以直接将当前CPU的占用率直接作为CPU使用率。其中CPU占用率为当前已经使用的CPU处理资源与CPU总的处理资源之间的比值。
步骤S120:获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低。
可以理解的是,对于不同的内存回收对象因为其本身特性的不同,在被进行回收时所需要消耗的CPU资源是不同的。例如,对于匿名页这种内存回收对象,其在被回收时是需要进行压缩然后存放在RAM中的,所以是需要消耗一定 的CPU资源的。所以为了整体提升电子设备的流程性,在CPU使用率较高的状态下,就尽量降低再去对CPU资源的占用,进而就降低需要消耗CPU资源的内存回收对象的回收量,从而实现降低内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重。
作为一种方式,在电子设备中预先存储有多个CPU使用率与对应的内存回收比例之间的映射关系。那么在电子设备获取到CPU使用率后,可以将获取到的CPU使用率与前述的多个CPU使用率进行匹配,进而将多个CPU使用率中与获取到的CPU使用率匹配的CPU使用率所对应的内存回收比例作为与所述CPU使用率对应的内存回收比例。例如,假设在电子设备中存储的多个CPU使用率包括有CPU使用率A、CPU使用率B、CPU使用率C以及CPU使用率D。其中,CPU使用率A对应有内存回收比例0:200,CPU使用率B对应有内存回收比例40:160,CPU使用率C对应有内存回收比例80:120,CPU使用率D对应有内存回收比例200:0。那么在获取到CPU使用率X后,将CPU使用率X与前述的CPU使用率A、CPU使用率B、CPU使用率C以及CPU使用率D进行匹配,若CPU使用率X与其中的CPU使用率C匹配,那么对应的内存回收比例为80:120。
步骤S130:基于所述内存回收比例进行内存回收。
本申请提供的一种内存回收方法,当进入内存回收场景时,获取CPU使用率,然后获取与所述CPU使用率对应的表征多种内存回收对象之间的比例的内存回收比例,基于所述内存回收比例进行内存回收。从而使得在不同内存回收场景对应的内存回收比例不同的情况下,可以在内存回收开始时先获取当前的内存回收场景,然后根据当前的内存回收场景来确定对于多种内存回收对象该各自回收多少,进而提升了内存回收过程的灵活性,并且因为所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低,进而可以在CPU使用率较高时,更多的回收不消耗CPU资源或者少量消耗CPU资源的内存回收对象,提升电子设备的流畅性。
请参阅图3,本申请实施例提供的一种内存回收方法,所述方法包括:
步骤S210:当进入内存回收场景时,获取指定时间段内的CPU使用率。
作为一种方式,所述获取指定时间段内的CPU使用率的步骤包括:将周期性的多个历史时间段中距离当前时刻最近的一个历史时间段作为指定时间段;获取存储的基于所述指定时间段内的CPU空闲时间以及CPU总使用时间计算得到的CPU使用率。
再者,可以理解的是,周期性的时间段中对于每个时间段都会有开始时间以及结束时间。例如,前述的图2所示的多个时间段中,在0到t1时间段,开始时间为0而结束时间为t1,再者,在t2到t3这个时间段中,开始时间为t2,而结束时间为t3。并且,对于每个时间段对应的CPU使用率所反应的都是各个时间段内的CPU使用情况,而在一些情况下,CPU使用率变化是比较频繁的。如果用前一个时间段的CPU使用率来计算得到本时间段中的内存分配比例,可以在一定程度上反应实际的CPU使用情况,但是还不能很好的反应当前实时的情况。
针对上述内容,需要先说明的是,在一些时间段中CPU的使用情况是很相似的。而相似的CPU使用情况,可能是因为所运行的应用程序比较相似或者相同。例如,请参阅图4,在t1到t2这个时间段中有应用程序A、应用程序B以及应用程序C在运行,而对应的在t4到t5这个时间段中也有应用程序A、应用程序B以及应用程序C在运行,那么可以理解的是t4到t5这个时间段为与t1到t2这个时间段相同或者相似的时间段。
那么作为一种方式,所述获取指定时间段内的CPU使用率的步骤包括:获取当前的应用程序特征参数,所述应用程序特征参数表征应用程序对CPU处理资源的占用程度;将基于所述应用程序特征参数计算得到的与当前时刻所处的时间段对应的目标历史时间段作为指定时间段;获取存储的所述指定时间段内的CPU使用率。
在这种方式下,可选的,电子设备可以在每个时间段开始时刻以及结束时刻分别计算一次本时间段对应的应用程序特征参数。其中,可以理解的是,在时间段的开始时刻检测到的应用程序可以是对本时间段会有哪些应用程序进行运行的一个预估,以便可以更加快速的计算得到相同的目标时间段,而当在时间段的结束时刻检测到的应用程序是可以明确的确认本时间段实际有哪些应用程序在运行。所以在本时间段计算得到本时间段对应的应用程序特征参数可以用于后续的时间段比对相同的目标时间段,而在每个时间段的开始时刻计算当前的应用程序特征参数,可以用于在当前时间段还未结束之前就可以预估与当前时间段相同的目标时间段,以便可以更加快速及时的获取对应的内存回收比例。
其中,可选的,在计算当前的应用程序特征参数时可以为应用程序当前启动的线程数与CPU可以并行处理的线程的总数的比值,其中应用程序特征参数越高表征对CPU的占用程度越高。例如,当前有应用程序A、应用程序B、应用程序C以及应用程序D在运行,而其中应用程序A对应有a个线程在运行,应用程序B对应有b个线程在运行,应用程序C对应有c个线程在运行,应用程序D对应有d个线程在运行。在CPU可以并行处理的线程的总数为m的情况下,对应的当前的应用程序特征参数为(a+b+c+d)/m。
可选的,在每个时间段结束时刻计算应用程序特征参数时是将当前时间段所有应用程序的平均线程数与CPU可以并行处理的线程的总数的比值。例如,在某个时间段内有应用程序B、应用程序C以及应用程序D在运行,而其中应用程序B运行过t个线程,应用程序C运行过k个线程,应用程序D运行过l个线程。那么该时间段的应用程序特征参数为(t+k+l)/3/m。
可选的,所述将基于所述应用程序特征参数计算得到的与当前时刻所处的时间段对应的目标历史时间段作为指定时间段的步骤包括:将所述当前的应用程序特征参数与多个历史时间段的应用程序特征参数进行比对;将对应的应用程序特征参数与所述当前的应用程序特征参数相同的历史时间段作为对应的目标历史时间段;将所述目标历史时间段作为指定时间段。
可选的,所述方法还包括:获取每个时间段内运行的应用程序的数量以及优先级,其中,优先级越高所对应的历史运行过程中所占用的内存越高;获取 与所述数量对应的第一评分;获取与所述优先级对应的第二评分;基于所述第一评分以及对应的第一预设权重,以及所述第二评分以及对应的第二预设权重计算得到每个时间段对应的应用程序特征参数。
再者,在本申请实施例中的不同的内存回收场景中,对于同一个CPU使用率也可以对应不同的内存回收比例。
在本申请实施例中,可以基于多种方式来确认当前的内存回收场景。
作为一种方式,可以识别当前进行内存回收的进程的标识;根据所述标识确定当前的内存回收场景。可以理解的是,在电子设备中进行内存回收都是由特定的进程执行的。例如,前述的有kswapd进程或者direct reclaim进程。那么在这种方式下,可以周期性的检测当前有哪些进程处于运行状态,当检测到有特定的进行内存回收的进程的标识为正在运行的进程标识时,判定处于该标识所对应的内存回收场景。例如,若识别当前进行内存回收的进程的标识为“kswapd”,那么对应的识别当前为kswapd内存回收场景。若识别当前进行内存回收的进程的标识为“direct reclaim”,那么对应的识别当前为direct reclaim内存回收场景。
作为另外一种方式,也可以根据当前所运行的应用程序来确定当前的内存回收场景。
需要说明的是,对于一些应用程序在运行过程中,对于内存消耗是有一定的需求的,那么针对不同的应用程序来确定不同的内存回收场景,可以更好的对应用程序流畅运行带来有利的条件。例如,对于一些应用程序在运行的过程中可能频繁的需要申请内存。例如,对于短视频类的应用程序,可能会增量性的申请内存分配来缓存所请求的短视频。例如,对于即时通信类的应用程序,可能会在运行中检测到进行视频通话时申请分配内存来缓存视频图像数据。再例如,对于一些应用程序本身在启动的时候,就会申请较多的内存。
那么在这种方式下,可选的,当检测到有进行内存回收的进程启动后,会进一步的检测当前有哪些应用程序处于运行状态,然后根据当前处于运行状态的应用程序来确定当前的内存回收场景,以便进而确定内存回收比例。
此外,作为另外一种方式,还可以结合当前处于运行状态的进程标识以及当前处于运行状态的应用程序共同来确定当前的内存回收场景。
如前述内容所示,在本申请实施例中可以有多种方式来确定当前的内存回收场景,而确定的不同的内存回收场景各自对应的内存回收比例是会有所不同的,以便于可以适应不同的场景各自的内存回收需求。示例性的,在实施例中所提及的内存回收对象可以包括匿名页(Anonymous page)以及文件页(File page)。其中,匿名页可以理解为没有文件背景的页,如堆,栈,数据段等,不是以文件形式存在的。文件页可以理解为有文件背景的页,例如,对于文件页所存储的数据可以在磁盘中找到对应的数据。
而其中,对于回收匿名页以及回收文件页的代价是不同的。在回收匿名页的过程中,是将匿名页压缩后存放在RAM中,由于该过程需要使用CPU将匿名页压缩,使用时再解压缩,所以匿名页的回收过程需要消耗一定的CPU时间,相对较慢。对于文件页的回收分两种情况,如果文件页对应的文件内容没有被 修改过,则直接将文件页内容丢弃;而如果文件页对应的文件内容被修改了,则将文件内容写回磁盘再将文件页丢弃。对于被回收的文件页的文件内容再次使用时,需要时重新从磁盘读取。而一般而言,很多文件页是没有被修改的,所以回收过程相对较快。
其中,本实施例中主要以检测在前台运行的应用程序为主。以电子设备为Android操作***为例,可以通过执行ActivityManager的getRunningTasks方法来获取到当前在前台运行的应用程序的名称。此外,电子设备还可以通过UsageStatsManager来获取用户使用的程序的列表,将该列表中记录的最近使用的应用程序识别为当前的前台应用。再者,还可以通过Android自带无障碍功能,监控窗口焦点的变化,拿到焦点窗口对应包名作为当前在前台运行的应用程序。
步骤S220:获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低。
需要说明的是,在本实施例中,每个内存回收场景都可以对应一个内存回收比例,以作为在该内存回收场景下所获取的CPU使用率所对应的内存回收比例。那么在这种方式下,在进入内存回收场景后可以先获取内存回收场景的类型,进而获取该内存回收场景的类型所对应的CPU使用率与内存回收比例之间的映射关系,作为前述步骤(例如,步骤S210或者步骤S110)中所获取的CPU使用率对应的内存回收比例。
下面就主要以匿名页以及文件页作为内存回收对象对本实施例所提供的方法进行介绍。其中,本实施例中的比例可以理解为匿名页与文件页之间的比例。
1对于识别当前进行内存回收的进程的标识,然后根据所述标识确定当前的内存回收场景的这种方式中,可以预先配置每种内存回收进程进行内存回收时,对匿名页以及文件页的回收比例,以作为在每种内存回收场景下CPU使用率所对应的内存回收比例。进而,当检测到有内存回收进程开始运行时,对应的获取该内存回收进程的标识,然后按照该内存回收进程的标识查询对应的匿名页以及文件页的回收比例,以作为当前内存回收场景的CPU使用率所对应的内存回收比例。
标识 比例
direct reclaim 0:200
kswapd 200:0
如上表所示,标识“direct reclaim”对应的比例为“0:200”,表征仅回收文件页,而不回收匿名页。标识“kswapd”对应的比例为“200:0”,表征仅回收匿名页,而不回收文件页。当然,其中的比例还可以根据需要进行改变,例如,对于标识为“direct reclaim”的进程对应的比例还可以为50:150,以表征尽量回收文件页,且少量回收匿名页。
再者,在根据当前所运行的应用程序来确定当前的内存回收场景的这种方式中,可以预先建立应用程序与内存回收比例的对应关系。进而在检测到有内存回收进程开始运行后,获取当前正在运行的应用程序,然后查询该正在运行 的应用程序对应的比例作为当前内存回收场景的CPU使用率所对应的内存回收比例。
应用程序标识 比例
应用程序A 10:190
应用程序B 20:180
应用程序C 30:170
如上表所示,每个应用程序标识都各自对应有一个内存回收比例。其中文件页比重越高,表征越需要更快的内存回收效率。那么在检测到有进行内存回收的进程开始运行后,如果检测到当前有应用程序A在运行,那么就对应的,将应用程序A对应的比例“10:190”作为内存回收比例。如果检测到当前有应用程序B在运行,那么就对应的,将应用程序B对应的比例“20:180”作为内存回收比例。
需要说明的是,在一种方式中,可以结合进程本身对应的比例以及当前处于运行状态的应用程序的比例共同确定当前场景对应的比例。例如,在前述表中进程标识“direct reclaim”对应的比例为“0:200”,而若检测到应用程序A当前处于运行状态时,该应用程序A对应的比例为“10:190”,那么当同时检测到进程“direct reclaim”处于运行状态,且检测到应用程序A在运行时,可以将处于运行状态的应用程序对应的比例与当前处于运行状态的负载内存回收的进程的标识对应的比例取均值作为当前内存回收场景的内存回收比例,从而使得既可以在一定程度上满足进程对应的内存回收比例,也能够在一定程度上满足应用程序对于内存回收比例的需求。例如,在前述表中进程标识“direct reclaim”对应的比例为“0:200”,而该应用程序A对应的比例为“10:190”,那么取均值后得到的比例为5:195。
可以理解的是,并不一定是任一一个应用程序都会对应一个比例。而可以只是被特定标记的应用程序会对应有一个比例。可选的,在电子设备中,可以通过建立名单的方式来对特定的应用程序进行标记。那么在这种方式下,为了便于可以快速对当前的应用程序是否为前述特定的应用程序(配置有内存回收比例的应用程序)进行判断,可选的,当有特定的应用程序启动以后,生成一个伴随文件,在该伴随文件中写入当前正在运行的特定的应用程序的标识。那么在这种方式下,当检测到有负责内存回收的进程启动以后,可以查询是否有伴随文件生成,若有,则将伴随文件中记录的应用程序对应的内存回收比例与当前启动的负责内存回收的进程对应的内存回收比例进行结合(例如,前述的取平均)来得到当前内存回收场景对应的内存回收比例。而若检测到没有伴随文件存在,则直接按照负责内存回收的进程对应的内存回收比例作为当前内存回收场景对应的内存回收比例。
需要说明的是,对于通过检测应用程序来判定当前内存回收场景的方式中。还可以通过预判即将有哪些应用程序即将启动来确定当前的内存回收场景。例如,在一种方式中,电子设备的某些应用程序是定时启动的,例如,闹钟程序。或者有的应用程序会因为用户的使用习惯而在每天的某个时间段内惯例性的启 动。例如,外卖类的应用程序,可能会在每天接近饭点的时候惯例性启动,再或者视频类的应用程序可能会在用户每天坐地铁的时候惯例性的被用户启动。
步骤S230:基于所述内存回收比例进行内存回收。
本申请提供的一种内存回收方法,当进入内存回收场景时,获取指定时间段内的CPU使用率,然后获取与所述CPU使用率对应的表征多种内存回收对象之间的比例的内存回收比例,基于所述内存回收比例进行内存回收。从而使得在不同内存回收场景对应的内存回收比例不同的情况下,可以在内存回收开始时先获取当前的内存回收场景,然后根据当前的内存回收场景来确定对于多种内存回收对象该各自回收多少,进而提升了内存回收过程的灵活性,并且因为所述指定时间段内的CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低,进而可以在CPU使用率较高时,更多的回收不消耗CPU资源或者少量消耗CPU资源的内存回收对象,提升电子设备的流畅性。
请参阅图5,本申请实施例提供的一种内存回收方法,所述方法包括:
步骤S310:当进入内存回收场景时,获取CPU使用率。
步骤S320:获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低。
步骤S330:基于所述内存回收比例进行内存回收。
步骤S340:获取当前的内存回收场景所对应的内存回收目标。
步骤S350:基于所述内存回收比例确定多种内存回收对象各自对应的内存回收目标。
步骤S360:若存在单个内存回收对象对应的内存回收目标,大于所述单个内存回收对象当前可回收的内存量,获取内存差值,所述内存差值为所述单个内存回收对象对应的内存回收目标与所述当前可回收的内存量的差值。
可以理解的是,对于多种内存回收对象可以回收到的内存量是有一定限制的。例如,若当前内存中匿名页一共有200MB,那么最多回收到的匿名页的数据量也只有200MB。那么在这种情况下,若既配置有内存回收目标,且需要按照当前的内存回收场景进行内存回收,那么就可能会造成无法回收到预期的内存量。
那么在这种方式下,在以当前的内存回收场景对应的内存回收比例完成内存回收后,获取按照当前的内存回收场景所对应的内存回收目标,未完成内存回收目标的对象为待处理内存回收对象。进而计算该待处理内存回收对象对应的内存回收目标与所述当前可回收的内存量的差值,作为前述的内存差值,然后从其他内存回收对象中再进一步回收该内存差值对应的内存量,以便既可以按照既定的内存回收比例来执行内存回收,也可以完成既定的内存回收目标。
步骤S370:增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标,以满足所述当前的内存回收场景所对应的内存回收目标。
示例性的,以匿名页和文件页为例,内存回收比例为50:150,且内存回收目标为100MB。那么可以理解的是,匿名页需要回收25MB,而文件页需要回 收75MB。但是,匿名页当前可以回收的量只有15MB。因此,在按照比例进行回收之后实际只回收了75MB+15MB=90MB,那么可以理解的是,按照前述的内存差值计算规则,得到内存差值为25-15=10MB,那么对应的,会再回收10MB的文件页作为补充。
需要说明的是,根据前述的内存回收原则,配置多种内存回收方式主要是为了提升内存回收效率。而对于多个内存回收对象而言,不同的内存回收对象的回收代价是不同的。那么如果增加的反而是内存回收效率更低的内存回收对象的回收量,可能不利于整体提升回收效率。那么作为一种方式,所述多种内存回收对象包括匿名页以及文件页,所述增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标的步骤之前还包括:若增加内存回收目标的内存回收对象为文件页;执行所述增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标;若增加内存回收目标的内存回收对象为匿名页;不增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标。从而通过这种方式,可以在整体上提升内存回收效率。
需要说明的是,作为一种方式,步骤S330和步骤S370可以多进程并行进行,以便提升回收效率。
本申请提供的一种内存回收方法,当进入内存回收场景时,获取CPU使用率,然后获取与所述CPU使用率对应的表征多种内存回收对象之间的比例的内存回收比例,基于所述内存回收比例进行内存回收。从而使得在不同内存回收场景对应的内存回收比例不同的情况下,可以在内存回收开始时先获取当前的内存回收场景,然后根据当前的内存回收场景来确定对于多种内存回收对象该各自回收多少,进而提升了内存回收过程的灵活性,并且因为所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低,进而可以在CPU使用率较高时,更多的回收不消耗CPU资源或者少量消耗CPU资源的内存回收对象,提升电子设备的流畅性。
并且,在不同的内存回收对象之间具有比例关系的情况下,进一步的会在存在单个内存回收对象对应的内存回收目标,大于所述单个内存回收对象当前可回收的内存量的情况下,增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标,以满足所述当前的内存回收场景所对应的内存回收目标,以便保证既可以按照当前的场景对应的内存回收比例进行内存回收,也可以同时满足当前的内存回收目标。
请参阅图6,本申请实施例提供的一种内存回收装置400,所述装置400包括:
处理信息获取单元410,用于当进入内存回收场景时,获取CPU使用率。
作为一种方式,处理信息获取单元410,具体用于当进入内存回收场景时,获取CPU使用率。
可选的,处理信息获取单元410,具体用于将周期性的历史时间段距离当前时刻最近的一个的历史时间段作为指定时间段;获取存储的基于所述指定时间段内的CPU空闲时间以及CPU总使用时间计算得到的CPU使用率。
可选的,处理信息获取单元410,具体用于获取当前的应用程序特征参数, 所述应用程序特征参数表征应用程序对CPU处理资源的占用程度;基于所述应用程序特征参数计算得到与当前时刻所处的时间段对应的目标历史时间段作为指定时间段;获取存储的所述历史指定时间段内的CPU使用率。
其中,作为一种方式,处理信息获取单元410,具体用于将所述当前的应用程序特征参数与多个历史时间段的应用程序特征参数进行比对;将对应的应用程序特征参数与所述当前的应用程序特征参数相同的历史时间段作为对应的目标历史时间段;将所述目标历史时间段作为指定时间段。
作为一种方式,如图7所示,所述装置410,还包括:
特征参数计算单元411,用于获取每个时间段内运行的应用程序的数量以及优先级,其中,优先级越高所对应的历史运行过程中所占用的内存越高;获取与所述数量对应的第一评分;获取与所述优先级对应的第二评分;基于所述第一评分以及对应的第一预设权重,以及所述第二评分以及对应的第二预设权重计算得到每个时间段对应的应用程序特征参数。
内存信息获取单元420,用于获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低。
内存回收单元430,用于基于所述内存回收比例进行内存回收。
作为一种方式,如图8所示,所述装置400,还包括:
内存增量回收单元440,用于获取当前的内存回收场景所对应的内存回收目标;基于所述内存回收比例确定多种内存回收对象各自对应的内存回收目标;若存在单个内存回收对象对应的内存回收目标,大于所述单个内存回收对象当前可回收的内存量,获取内存差值,所述内存差值为所述单个内存回收对象对应的内存回收目标与所述当前可回收的内存量的差值;增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标,以满足所述当前的内存回收场景所对应的内存回收目标。
可选的,所述多种内存回收对象包括匿名页以及文件页。内存增量回收单元440,还用于若增加内存回收目标的内存回收对象为文件页;执行所述增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标;若增加内存回收目标的内存回收对象为匿名页;不增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标。
需要说明的是,本申请中装置实施例与前述方法实施例是相互对应的,装置实施例中具体的原理可以参见前述方法实施例中的内容,此处不再赘述。
下面将结合图9对本申请提供的一种电子设备进行说明。
请参阅图9,基于上述的内存回收方法、装置,本申请实施例还提供的另一种可以执行前述内存回收方法的电子设备100。电子设备100包括相互耦合的一个或多个(图中仅示出一个)处理器102、存储器104以及网络模块106。其中,该存储器104中存储有可以执行前述实施例中内容的程序,而处理器102可以执行该存储器104中存储的程序。
其中,处理器102可以包括一个或者多个处理核。处理器102利用各种接 口和线路连接整个电子设备100内的各个部分,通过运行或执行存储在存储器104内的指令、程序、代码集或指令集,以及调用存储在存储器104内的数据,执行电子设备100的各种功能和处理数据。可选地,处理器102可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器102可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作***、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器102中,单独通过一块通信芯片进行实现。
存储器104可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。存储器104可用于存储指令、程序、代码、代码集或指令集。存储器104可包括存储程序区和存储数据区,例如,存储器104中可以存储有内存回收装置。该内存回收装置可以为前述的装置400。其中,存储程序区可存储用于实现操作***的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等。存储数据区还可以存储终端100在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。
所述网络模块106用于接收以及发送电磁波,实现电磁波与电信号的相互转换,从而与通讯网络或者其他设备进行通讯,例如和音频播放设备进行通讯。所述网络模块106可包括各种现有的用于执行这些功能的电路元件,例如,天线、射频收发器、数字信号处理器、加密/解密芯片、用户身份模块(SIM)卡、存储器等等。所述网络模块106可与各种网络如互联网、企业内部网、无线网络进行通讯或者通过无线网络与其他设备进行通讯。上述的无线网络可包括蜂窝式电话网、无线局域网或者城域网。例如,网络模块106可以与基站进行信息交互。
请参考图10,其示出了本申请实施例提供的一种计算机可读存储介质的结构框图。该计算机可读介质800中存储有程序代码,所述程序代码可被处理器调用执行上述方法实施例中所描述的方法。
计算机可读存储介质800可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。可选地,计算机可读存储介质800包括非易失性计算机可读介质(non-transitory computer-readable storage medium)。计算机可读存储介质800具有执行上述方法中的任何方法步骤的程序代码810的存储空间。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。程序代码810可以例如以适当形式进行压缩。
综上所述,本申请提供的一种内存回收方法、装置、电子设备及存储介质,当进入内存回收场景时,获取CPU使用率,然后获取与所述CPU使用率对应的表征多种内存回收对象之间的比例的内存回收比例,基于所述内存回收比例进 行内存回收。从而使得在不同内存回收场景对应的内存回收比例不同的情况下,可以在内存回收开始时先获取当前的内存回收场景,然后根据当前的内存回收场景来确定对于多种内存回收对象该各自回收多少,进而提升了内存回收过程的灵活性,并且因为所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低,进而可以在CPU使用率较高时,更多的回收不消耗CPU资源或者消耗CPU资源的内存回收对象,提升电子设备的流畅性。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不驱使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种内存回收方法,其特征在于,所述方法包括:
    当进入内存回收场景时,获取CPU使用率;
    获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低;
    基于所述内存回收比例进行内存回收。
  2. 根据权利要求1所述的方法,其特征在于,获取CPU使用率,包括:
    获取指定时间段内的CPU使用率。
  3. 根据权利要求2所述的方法,其特征在于,所述获取指定时间段内的CPU使用率,包括:
    将周期性的多个历史时间段中距离当前时刻最近的一个历史时间段作为指定时间段;
    获取存储的基于所述指定时间段内的CPU空闲时间以及CPU总使用时间计算得到的CPU使用率。
  4. 根据权利要求2所述的方法,其特征在于,所述获取指定时间段内的CPU使用率,包括:
    获取当前的应用程序特征参数,所述应用程序特征参数表征应用程序对CPU处理资源的占用程度;
    将基于所述应用程序特征参数计算得到的与当前时刻所处的时间段对应的目标历史时间段作为指定时间段;
    获取存储的所述指定时间段内的CPU使用率。
  5. 根据权利要求4所述的方法,其特征在于,所述获取当前的应用程序特征参数,包括:
    获取应用程序当前启动的线程数与CPU并行处理的线程的总数的比值;
    将所述比值作为当前的应用程序特征参数,所述应用程序特征参数越高表征对CPU的占用程度越高。
  6. 根据权利要求4所述的方法,其特征在于,所述获取当前的应用程序特征参数,包括:
    在每个时间段结束时刻获取当前时间段所有应用程序的平均线程数与CPU并行处理的线程的总数的比值;
    将所述比值作为当前的应用程序特征参数。
  7. 根据权利要求4所述的方法,其特征在于,所述将基于所述应用程序特征参数计算得到的与当前时刻所处的时间段对应的目标历史时间段作为指定时间段,包括:
    将所述当前的应用程序特征参数与多个历史时间段的应用程序特征参数进行比对;
    将对应的应用程序特征参数与所述当前的应用程序特征参数相同的历史 时间段作为对应的目标历史时间段;
    将所述目标历史时间段作为指定时间段。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述方法还包括:
    获取每个时间段内运行的应用程序的数量以及优先级,其中,优先级越高所对应的历史运行过程中所占用的内存越高;
    获取与所述数量对应的第一评分;
    获取与所述优先级对应的第二评分;
    基于所述第一评分以及对应的第一预设权重,以及所述第二评分以及对应的第二预设权重计算得到每个时间段对应的应用程序特征参数。
  9. 根据权利要求1所述的方法,其特征在于,所述获取CPU使用率,包括:
    将当前CPU的占用率作为CPU使用率,所述CPU占用率为当前已经使用的CPU处理资源与CPU总的处理资源之间的比值。
  10. 根据权利要求1所述的方法,其特征在于,所述获取与所述CPU使用率对应的内存回收比例,包括:
    获取预先存储的多个CPU使用率与各自对应的内存回收比例之间的映射关系;
    将获取到的CPU使用率与所述多个CPU使用率进行匹配;
    将所述多个CPU使用率中与获取到的CPU使用率匹配的CPU使用率所对应的内存回收比例作为与所述CPU使用率对应的内存回收比例。
  11. 根据权利要求1所述的方法,其特征在于,所述获取与所述CPU使用率对应的内存回收比例之前,所述方法还包括:
    识别当前进行内存回收的进程的标识;
    根据所述标识确定当前的内存回收场景,不同的内存回收场景所需要回收的内存不同。
  12. 根据权利要求11所述的方法,其特征在于,所述获取与所述CPU使用率对应的内存回收比例,包括:
    获取预先配置的每种内存回收进程进行内存回收时,对匿名页以及文件页的回收比例;
    当检测到有内存回收进程开始运行时,获取所述内存回收进程的标识;
    按照所述标识查询对应的匿名页以及文件页的回收比例,作为当前内存回收场景的CPU使用率所对应的内存回收比例。
  13. 根据权利要求1所述的方法,其特征在于,所述获取与所述CPU使用率对应的内存回收比例之前,所述方法还包括:
    根据当前所运行的应用程序来确定当前的内存回收场景,不同的内存回收场景所需要回收的内存不同。
  14. 根据权利要求13所述的方法,其特征在于,所述获取与所述CPU使用率对应的内存回收比例,包括:
    获取预先建立的应用程序与内存回收比例的对应关系;
    在检测到有内存回收进程开始运行后,获取当前正在运行的应用程序;
    查询所述正在运行的应用程序对应的比例,作为当前内存回收场景的CPU使用率所对应的内存回收比例。
  15. 根据权利要求1所述的方法,其特征在于,所述基于所述内存回收比例进行内存回收之后,还包括:
    获取当前的内存回收场景所对应的内存回收目标;
    基于所述内存回收比例确定多种内存回收对象各自对应的内存回收目标;
    若存在单个内存回收对象对应的内存回收目标,大于所述单个内存回收对象当前可回收的内存量,获取内存差值,所述内存差值为所述单个内存回收对象对应的内存回收目标与所述当前可回收的内存量的差值;
    增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标,以满足所述当前的内存回收场景所对应的内存回收目标。
  16. 根据权利要求15所述的方法,其特征在于,所述多种内存回收对象包括匿名页以及文件页,所述增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标之前,还包括:
    若增加内存回收目标的内存回收对象为文件页;
    执行所述增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标;
    若增加内存回收目标的内存回收对象为匿名页;
    不增加所述单个内存回收对象以外的内存回收对象对应的内存回收目标。
  17. 根据权利要求1所述的方法,其特征在于,所述当进入内存回收场景时,获取CPU使用率之前,所述方法还包括:
    在检测到有负责进行内存回收的进程开始运行时,判定进入内存回收场景。
  18. 一种内存回收装置,其特征在于,所述装置包括:
    处理信息获取单元,用于当进入内存回收场景时,获取CPU使用率;
    内存信息获取单元,用于获取与所述CPU使用率对应的内存回收比例,所述内存回收比例表征多种内存回收对象之间的比例,其中,所述CPU使用率越高所对应的内存回收比例中回收时需要消耗CPU资源的内存回收对象的比重越低;
    内存回收单元,用于基于所述内存回收比例进行内存回收。
  19. 一种电子设备,其特征在于,包括一个或多个处理器以及存储器;一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行权利要求1-17任一所述的方法。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码被处理器运行时执行权利要求1-17任一所述的方法。
PCT/CN2020/116248 2019-09-27 2020-09-18 内存回收方法、装置、电子设备及存储介质 WO2021057623A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910925510.2A CN110704189A (zh) 2019-09-27 2019-09-27 内存回收方法、装置以及电子设备
CN201910925510.2 2019-09-27

Publications (1)

Publication Number Publication Date
WO2021057623A1 true WO2021057623A1 (zh) 2021-04-01

Family

ID=69198201

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/116248 WO2021057623A1 (zh) 2019-09-27 2020-09-18 内存回收方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN110704189A (zh)
WO (1) WO2021057623A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110704189A (zh) * 2019-09-27 2020-01-17 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN110727606A (zh) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN111930739A (zh) * 2020-06-22 2020-11-13 中国建设银行股份有限公司 表空间碎片化的自动处理方法、***、设备和存储介质
CN114168065B (zh) 2020-09-10 2024-05-31 荣耀终端有限公司 调整内存配置参数的方法和装置

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060074872A1 (en) * 2004-09-30 2006-04-06 International Business Machines Corporation Adaptive database buffer memory management using dynamic SQL statement cache statistics
CN108228449A (zh) * 2017-08-15 2018-06-29 珠海市魅族科技有限公司 终端设备控制方法及装置、终端设备及计算机可读存储介质
CN109697119A (zh) * 2017-10-20 2019-04-30 中兴通讯股份有限公司 终端内存回收处理方法及装置
CN109857555A (zh) * 2019-01-15 2019-06-07 Oppo广东移动通信有限公司 内存回收方法及装置、存储介质和电子设备
CN109992523A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110704189A (zh) * 2019-09-27 2020-01-17 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN110727606A (zh) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104778086A (zh) * 2015-04-15 2015-07-15 天脉聚源(北京)教育科技有限公司 一种释放资源的方法及装置

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060074872A1 (en) * 2004-09-30 2006-04-06 International Business Machines Corporation Adaptive database buffer memory management using dynamic SQL statement cache statistics
CN108228449A (zh) * 2017-08-15 2018-06-29 珠海市魅族科技有限公司 终端设备控制方法及装置、终端设备及计算机可读存储介质
CN109697119A (zh) * 2017-10-20 2019-04-30 中兴通讯股份有限公司 终端内存回收处理方法及装置
CN109992523A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN109857555A (zh) * 2019-01-15 2019-06-07 Oppo广东移动通信有限公司 内存回收方法及装置、存储介质和电子设备
CN110704189A (zh) * 2019-09-27 2020-01-17 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN110727606A (zh) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备

Also Published As

Publication number Publication date
CN110704189A (zh) 2020-01-17

Similar Documents

Publication Publication Date Title
WO2021057619A1 (zh) 内存回收方法、装置、电子设备及存储介质
WO2021057623A1 (zh) 内存回收方法、装置、电子设备及存储介质
WO2021057622A1 (zh) 内存回收方法、装置、电子设备及存储介质
US10895987B2 (en) Memory compression method of electronic device and apparatus thereof
CN110764906B (zh) 内存回收处理方法、装置、电子设备以及存储介质
CN111158910B (zh) 内存管理方法、装置、存储介质及电子设备
WO2019205371A1 (zh) 服务器、消息分配的方法及存储介质
CN110765031B (zh) 数据存储方法、装置、移动终端及存储介质
CN109213596B (zh) 一种分配终端内存的方法和设备
US11010094B2 (en) Task management method and host for electronic storage device
CN110727605B (zh) 内存回收方法、装置以及电子设备
CN111177025B (zh) 数据存储方法、装置及终端设备
CN103874987B (zh) 嵌入式多媒体卡分区存储空间调整方法和终端
US9335946B2 (en) Method and apparatus for managing memory
CN110737606B (zh) 内存回收处理方法、装置、电子设备以及存储介质
CN115421907A (zh) 内存回收方法、装置、电子设备及存储介质
WO2020118601A1 (zh) 视频编码方法、装置、电子设备及存储介质
WO2021179170A1 (zh) 数据推送方法、装置、服务器及存储介质
CN111078587B (zh) 内存分配方法、装置、存储介质及电子设备
CN115587049A (zh) 内存回收方法、装置、电子设备及存储介质
WO2021129489A1 (zh) 应用程序预编译的方法、装置、电子设备及存储介质
CN111090627B (zh) 基于池化的日志存储方法、装置、计算机设备及存储介质
CN111078405B (zh) 内存分配方法、装置、存储介质及电子设备
CN114546171A (zh) 数据分发方法、装置、存储介质及电子设备
CN112070144A (zh) 图像聚类方法、装置、电子设备以及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20868118

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20868118

Country of ref document: EP

Kind code of ref document: A1