WO2022242683A1 - 内存回收方法、装置和电子设备 - Google Patents

内存回收方法、装置和电子设备 Download PDF

Info

Publication number
WO2022242683A1
WO2022242683A1 PCT/CN2022/093573 CN2022093573W WO2022242683A1 WO 2022242683 A1 WO2022242683 A1 WO 2022242683A1 CN 2022093573 W CN2022093573 W CN 2022093573W WO 2022242683 A1 WO2022242683 A1 WO 2022242683A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
memory
processor
agent process
background
Prior art date
Application number
PCT/CN2022/093573
Other languages
English (en)
French (fr)
Inventor
吴德安
Original Assignee
维沃移动通信有限公司
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 维沃移动通信有限公司 filed Critical 维沃移动通信有限公司
Publication of WO2022242683A1 publication Critical patent/WO2022242683A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application belongs to the technical field of communication, and in particular relates to a memory recovery method, device and electronic equipment.
  • the memory of electronic devices is usually not high.
  • the memory of mobile phones is generally only a few gigabytes to a dozen gigabytes. use case.
  • the system will take some measures to free up the memory, for example, the foreground application process reclaims the memory of other background running applications by swapping or clearing, and Traverse all modules of the system to register callback (shrinker) functions to reclaim the memory of each module.
  • the foreground application process reclaims the memory of other background running applications by swapping or clearing, and Traverse all modules of the system to register callback (shrinker) functions to reclaim the memory of each module.
  • the purpose of the embodiment of the present application is to provide a memory recovery method, device and electronic device, which can solve the problem in the related art that the memory recovery method easily causes a delay in the response of the foreground application.
  • the embodiment of the present application provides a memory recovery method, the method includes:
  • the background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device is run on the second processor among the multi-core processors of the electronic device
  • the processing capability of the first processor is lower than that of the second processor.
  • the embodiment of the present application provides a memory recycling device, including:
  • the wake-up module is used to wake up the pre-created background agent process when the available memory of the electronic device is insufficient;
  • An execution module configured to traverse and execute the memory recovery process of the system module of the electronic device through the background agent process
  • the background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device is run on the second processor among the multi-core processors of the electronic device
  • the processing capability of the first processor is lower than that of the second processor.
  • an embodiment of the present application provides an electronic device, the electronic device includes a processor, a memory, and a program or instruction stored in the memory and operable on the processor, and the program or instruction is The processor realizes the steps of the memory recovery method described in the first aspect when executing.
  • an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the memory recovery method as described in the first aspect is implemented A step of.
  • the embodiment of the present application provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run programs or instructions, so as to implement the first aspect The memory recovery method described above.
  • a computer program product is provided, wherein the computer program product is stored in a non-transitory storage medium, and the computer program product is executed by at least one processor to implement the memory as described in the first aspect Recycling method.
  • a communication device configured to execute the memory recovery method as described in the first aspect.
  • the pre-created background agent process is awakened; the memory recovery process of the system module of the electronic device is traversed through the background agent process; wherein, the background The agent process is bound to run on the first processor among the multi-core processors of the electronic device, the foreground application process of the electronic device runs on the second processor among the multi-core processors of the electronic device, the The processing capability of the first processor is inferior to that of the second processor.
  • the memory recovery process of the system module of the electronic device is traversed and executed through the pre-created background agent process, without the need for the foreground application process to participate in the memory recovery process of the system module, and because the background agent process is bound to a device with poor processing capability It runs on the processor, so as to avoid the response delay caused by the foreground application waiting for the system memory to be reclaimed or being preempted by the processor resource.
  • FIG. 1 is a flowchart of a memory recovery method provided in an embodiment of the present application
  • Fig. 2a is one of the example flowcharts of the memory recovery method provided by the embodiment of the present application.
  • Fig. 2b is the second example flowchart of the memory recovery method provided by the embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of a memory recovery device provided in an embodiment of the present application.
  • Fig. 4 is one of the structural schematic diagrams of the electronic equipment provided by the embodiment of the present application.
  • FIG. 5 is a second schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Fig. 1 is a flow chart of the memory recovery method provided by the embodiment of the present application, as shown in Fig. 1, the method includes the following steps:
  • Step 101 wake up the pre-created background agent process when the available memory of the electronic device is insufficient.
  • a background proxy process in order to reduce the response delay caused by the foreground application participating in the memory recovery process of the system module, a background proxy process (shrinker proxy) can be created in advance, and in the normal case where memory recovery is not required, the background proxy process The process is sleeping, waiting to be woken up.
  • memory recovery can be started to free up a certain amount of memory for use by the current application process.
  • the pre-created background agent process can be awakened immediately, so as to complete the recycling work of the system module memory of the electronic device through the background agent process.
  • the background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device is run on the second processor among the multi-core processors of the electronic device
  • the processing capability of the first processor is lower than that of the second processor.
  • the background agent process can be bound to run on a small core with poor processing capability, and the foreground application process of the electronic device can be run on a small core with relatively strong processing capability. In this way, by handing over the system memory recovery work to the small core, it is possible to prevent the background agent process and the foreground application process from preempting the large core and causing the foreground application process to be stuck, and it also helps to reduce power consumption.
  • the method before waking up the pre-created background agent process, the method further includes:
  • the memory occupied by the background application process of the electronic device can be recovered first, for example, the memory occupied by other background running applications can be recovered by swapping or cleaning.
  • memory occupied by the foreground application process as soon as possible, and after reclaiming the memory occupied by the background application process of the electronic device, wake up the background agent process to continue the memory recovery process of the system module.
  • the foreground application process only needs to perform the process of recovering the memory occupied by the background application process and wake up the background agent process, without participating in the time-consuming system module memory recovery process, thereby improving the quality of recovery and accelerating the response of the foreground application process time.
  • Step 102 traversing and executing the memory recovery process of the system modules of the electronic device through the background agent process.
  • the memory recovery process of the system module of the electronic device can be traversed through the background proxy process, specifically, the electronic device can be traversed through the background proxy process each system module, so that each system module registers the shrinker callback function in turn, and then reclaims the memory occupied by each system module in turn, until the memory of the last system module is reclaimed, and the task execution of the background agent process is terminated.
  • the system module may refer to various system drive modules such as Bluetooth, wireless network communication technology (Wireless Fidelity, WiFi), display screen, etc. of the electronic device.
  • the foreground application does not need to wait for the memory recovery time of the system module, and the user is almost unaware of the background process, thereby speeding up the response speed of the foreground application and avoiding random cards pause.
  • waking up a pre-created background agent process includes:
  • a certain waking interval can be set to avoid repeated waking up.
  • the first preset duration is a preset wake-up interval, for example, it can be set to 10ms, 15ms and so on.
  • the method further includes:
  • the step 102 includes:
  • the memory recovery process of the system module of the electronic device is traversed and executed through the background agent process .
  • the background proxy process can be detected immediately after waking up the background proxy process. Whether the last wake-up time of the background agent process is more than the second preset duration from the current moment, if so, the memory recovery process of the system module of the electronic device can be traversed and executed through the background agent process, otherwise the background can be closed Agent process, so that it can re-enter the dormant state, and can turn to the process of reclaiming the memory of the background application process, so as to focus on reclaiming the memory of the background application process.
  • the second preset duration is also a preset wake-up interval, which may be the same as or different from the first preset duration, for example, may be set to 10 ms, 15 ms, etc.
  • the method further includes:
  • the background agent process After traversing and executing the memory recovery process of the system modules of the electronic device, the background agent process is controlled to enter a dormant state.
  • the background proxy process can be controlled to re-enter the dormant state and wait for the next wake-up, so as to avoid unnecessary resource overhead of the background process.
  • FIG. 2a The embodiment of the present application will be illustrated below with reference to FIG. 2a and FIG. 2b.
  • the general flow of the memory recovery method for electronic equipment in the embodiment of the present application can be shown in FIG. 2a, and the specific steps are shown in FIG. 2b.
  • a background proxy process (shrinker proxy) is created, and considering that the revenue ratio of system module recycling is not high, the background proxy process can be bound to run on a small core, so as to avoid preempting the large core with the foreground application process, and make the The background agent process goes to sleep and waits to wake up.
  • step 202 when the available memory of the system is insufficient, the foreground application process cannot apply for memory, and thus enters the memory recovery process of other background application processes.
  • step 203 prepare to wake up the background agent process. Considering that frequent wakeups are meaningless, a 10ms wakeup interval is added to avoid repeated wakeups. Once it is found that the background agent process wakes up frequently within 10ms, ignore this wake-up and go to the memory process of reclaiming other background application processes, so that the memory of other processes can be reclaimed.
  • step 204 wake up the background agent process.
  • steps 202 to 204 are the logic of the foreground application process.
  • step 205 the background agent process has been in a dormant state after booting, waiting to be woken up, and enters the next step after being woken up.
  • step 206 the background agent process is responsible for traversing and executing the shrinker callback functions registered by all system modules to reclaim system module memory. After recycling, return to the previous step, that is, enter the dormant state, waiting for the next wake-up.
  • steps 205 to 206 are background agent process logic.
  • the shrinker callback function is implemented by the system module, and each system module has different implementations. Some system modules execute shrinker quickly, while others execute slowly, which will affect the determinism of the entire recovery time and easily cause random freezes in the foreground application.
  • the embodiment of the present application can realize accelerated system memory recovery, transfer inefficient work through the background proxy method, and increase the speed of system available memory recovery. Compared with the existing solution, it has the following advantages:
  • the background proxy process runs on the small core, which can avoid the risk of preempting the large core with the foreground application process, and indirectly improve the response speed of the foreground.
  • the memory recovery method in the embodiment of the present application wakes up the pre-created background agent process when the available memory of the electronic device is insufficient; traverses and executes the memory recovery process of the system module of the electronic device through the background agent process; wherein, The background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device runs on the second processor among the multi-core processors of the electronic device , the processing capability of the first processor is worse than that of the second processor.
  • the memory recovery process of the system module of the electronic device is traversed and executed through the pre-created background agent process, without the need for the foreground application process to participate in the memory recovery process of the system module, and because the background agent process is bound to a device with poor processing capability It runs on the processor, so as to avoid the response delay caused by the foreground application waiting for the system memory to be reclaimed or being preempted by the processor resource.
  • the memory reclamation method provided in the embodiment of the present application may be executed by a memory reclamation device, or a control module in the memory reclamation device for executing the memory reclamation method.
  • the method for memory recovery performed by the memory recovery device is taken as an example to illustrate the memory recovery device provided in the embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of a memory recycling device provided in an embodiment of the present application.
  • the memory recycling device 300 includes:
  • a wake-up module 301 configured to wake up a pre-created background agent process when the available memory of the electronic device is insufficient;
  • An execution module 302, configured to traverse and execute the memory recovery process of the system modules of the electronic device through the background agent process
  • the background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device is run on the second processor among the multi-core processors of the electronic device
  • the processing capability of the first processor is lower than that of the second processor.
  • the wake-up module 301 is configured to wake up the background proxy process when the time interval between the last wake-up time of the background proxy process and the current time is greater than or equal to a first preset duration.
  • the memory recovery device 300 also includes:
  • An acquisition module configured to acquire the time interval between the last wake-up time of the background agent process and the current time
  • a first processing module configured to control the background agent process to enter a dormant state when the time interval between the last wake-up time of the background agent process and the current moment is less than a second preset duration
  • the execution module 302 is configured to traverse and execute the system of the electronic device through the background agent process when the time interval between the last wake-up time of the background agent process and the current time is greater than or equal to the second preset duration.
  • the module's memory recovery process is configured to traverse and execute the system of the electronic device through the background agent process when the time interval between the last wake-up time of the background agent process and the current time is greater than or equal to the second preset duration.
  • the memory recovery device 300 also includes:
  • the second processing module is configured to control the background agent process to enter a dormant state after traversing and executing the memory recovery process of the system modules of the electronic device.
  • the memory recovery device 300 also includes:
  • the recycling module is configured to reclaim the memory occupied by the background application process of the electronic device when the available memory of the electronic device is insufficient.
  • the memory recovery device in the embodiment of the present application wakes up the pre-created background proxy process when the available memory of the electronic device is insufficient; traverses and executes the memory recovery process of the system module of the electronic device through the background proxy process; wherein, The background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device runs on the second processor among the multi-core processors of the electronic device , the processing capability of the first processor is worse than that of the second processor.
  • the memory recovery process of the system module of the electronic device is traversed and executed through the pre-created background agent process, without the need for the foreground application process to participate in the memory recovery process of the system module, and because the background agent process is bound to a device with poor processing capability It runs on the processor, so as to avoid the response delay caused by the foreground application waiting for the system memory to be reclaimed or being preempted by the processor resource.
  • the memory reclamation device in the embodiment of the present application may be a device, or may be a component, an integrated circuit, or a chip in a terminal.
  • the device may be a mobile electronic device or a non-mobile electronic device.
  • the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a handheld computer, a vehicle electronic device, a wearable device, an ultra-mobile personal computer (Ultra-Mobile Personal Computer, UMPC), a netbook or a personal digital assistant (Personal Digital Assistant).
  • non-mobile electronic devices can be servers, network attached storage (Network Attached Storage, NAS), personal computer (Personal Computer, PC), television (Television, TV), teller machine or self-service machine, etc., this application Examples are not specifically limited.
  • Network Attached Storage NAS
  • PC Personal Computer
  • TV Television, TV
  • teller machine or self-service machine etc.
  • the memory reclamation device in the embodiment of the present application may be a device with an operating system.
  • the operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, which are not specifically limited in this embodiment of the present application.
  • the memory reclamation device provided by the embodiment of the present application can realize various processes realized by the method embodiments in FIG. N to FIG. 2 , and details are not repeated here to avoid repetition.
  • the embodiment of the present application further provides an electronic device 400, including a processor 401, a memory 402, and programs or instructions stored in the memory 402 and operable on the processor 401,
  • an electronic device 400 including a processor 401, a memory 402, and programs or instructions stored in the memory 402 and operable on the processor 401,
  • the program or instruction is executed by the processor 401, each process of the above memory recovery method embodiment can be realized, and the same technical effect can be achieved. To avoid repetition, details are not repeated here.
  • the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
  • FIG. 5 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.
  • the electronic device 500 includes, but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, and a processor 510, etc. part.
  • the electronic device 500 can also include a power supply (such as a battery) for supplying power to various components, and the power supply can be logically connected to the processor 510 through the power management system, so that the management of charging, discharging, and function can be realized through the power management system. Consumption management and other functions.
  • a power supply such as a battery
  • the structure of the electronic device shown in FIG. 5 does not constitute a limitation to the electronic device.
  • the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange different components, and details will not be repeated here. .
  • the processor 510 is configured to wake up a pre-created background agent process when the available memory of the electronic device 500 is insufficient;
  • the background agent process is bound to run on the first processor among the multi-core processors of the electronic device, and the foreground application process of the electronic device is run on the second processor among the multi-core processors of the electronic device
  • the processing capability of the first processor is lower than that of the second processor.
  • the processor 510 is further configured to wake up the background agent process when the time interval between the last wake-up time of the background agent process and the current time is greater than or equal to a first preset duration.
  • the processor 510 is further configured to acquire the time interval between the last wake-up time of the background agent process and the current time;
  • the memory recovery process of the system module of the electronic device is traversed and executed through the background agent process .
  • the processor 510 is further configured to control the background agent process to enter a sleep state after traversing and executing the memory reclamation process of the system modules of the electronic device.
  • the processor 510 is further configured to reclaim the memory occupied by the background application process of the electronic device when the available memory of the electronic device is insufficient.
  • the pre-created background agent process is awakened; the memory recovery process of the system module of the electronic device is traversed through the background agent process; wherein, the background The agent process is bound to run on the first processor among the multi-core processors of the electronic device, the foreground application process of the electronic device runs on the second processor among the multi-core processors of the electronic device, the The processing capability of the first processor is inferior to that of the second processor.
  • the memory recovery process of the system module of the electronic device is traversed and executed through the pre-created background agent process, without the need for the foreground application process to participate in the memory recovery process of the system module, and because the background agent process is bound to a device with poor processing capability It runs on the processor, so as to avoid the response delay caused by the foreground application waiting for the system memory to be reclaimed or being preempted by the processor resource.
  • the input unit 504 may include a graphics processor (Graphics Processing Unit, GPU) 5041 and a microphone 5042, and the graphics processor 5041 is used for the image capture device (such as the image data of the still picture or video obtained by the camera) for processing.
  • the display unit 506 may include a display panel 5061, and the display panel 5061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like.
  • the user input unit 507 includes a touch panel 5071 and other input devices 5072 .
  • the touch panel 5071 is also called a touch screen.
  • the touch panel 5071 may include two parts, a touch detection device and a touch controller.
  • Other input devices 5072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.
  • Memory 509 may be used to store software programs as well as various data, including but not limited to application programs and operating systems.
  • the processor 510 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, user interface, application program, etc., and the modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor may not be integrated into the processor 510 .
  • the embodiment of the present application also provides a readable storage medium, the readable storage medium may be nonvolatile or volatile, the readable storage medium stores programs or instructions, and the programs or instructions are stored in When the processor executes, each process of the above-mentioned embodiment of the memory recovery method can be realized, and the same technical effect can be achieved. To avoid repetition, details are not repeated here.
  • the processor is the processor in the electronic device described in the above embodiments.
  • the readable storage medium includes computer readable storage medium, such as computer read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk, etc.
  • the embodiment of the present application further provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the above memory recovery method embodiment
  • the chip includes a processor and a communication interface
  • the communication interface is coupled to the processor
  • the processor is used to run programs or instructions to implement the above memory recovery method embodiment
  • chips mentioned in the embodiments of the present application may also be called system-on-chip, system-on-chip, system-on-a-chip, or system-on-a-chip.
  • An embodiment of the present application further provides a computer program product, wherein the computer program product is stored in a non-transitory readable storage medium, and the computer program product is executed by at least one processor to implement the above memory recovery method
  • the computer program product is stored in a non-transitory readable storage medium, and the computer program product is executed by at least one processor to implement the above memory recovery method
  • the term “comprising”, “comprising” or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or device. Without further limitations, an element defined by the phrase “comprising a " does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising that element.
  • the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved. Functions are performed, for example, the described methods may be performed in an order different from that described, and various steps may also be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)
  • Power Sources (AREA)

Abstract

本申请公开了一种内存回收方法、装置和电子设备,属于通信技术领域。该方法包括:在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;通过后台代理进程遍历执行电子设备的系统模块的内存回收流程;后台代理进程在电子设备的多核处理器中的第一处理器上运行,电子设备的前台应用进程在电子设备的多核处理器中的第二处理器上运行,第一处理器的处理能力差于第二处理器。

Description

内存回收方法、装置和电子设备
相关申请的交叉引用
本申请主张在2021年05月19日在中国提交的中国专利申请No.202110547218.9的优先权,其全部内容通过引用包含于此。
技术领域
本申请属于通信技术领域,具体涉及一种内存回收方法、装置和电子设备。
背景技术
随着电子设备的普及和各类应用的不断开发,人们经常使用手机等电子设备运行各类应用以进行各种事务。电子设备每启动一个应用,都需要占用一定大小的内存,而目前电子设备的内存通常都不高,例如,手机内存一般只有几G到十几G,在运行应用较多时,就会出现内存不够用的情况。
相关技术中,在用户切换应用的过程中,电子设备当前剩余内存不足时,系统会采取一些措施来腾出内存,例如,前台应用进程通过交换或清除的方式回收其他后台运行应用的内存,以及遍历系统所有模块使其注册回调(shrinker)函数来回收各模块的内存。
然而,由于每次遍历的耗时与注册回调函数数量成线性关系,系统模块数量越多,注册回调函数越多,延迟就越大,从而易造成前台应用响应延迟。
发明内容
本申请实施例的目的是提供一种内存回收方法、装置和电子设备,能够解决相关技术中的内存回收方式易造成前台应用响应延迟的问题。
第一方面,本申请实施例提供了一种内存回收方法,该方法包括:
在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;
通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流 程;
其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
第二方面,本申请实施例提供了一种内存回收装置,包括:
唤醒模块,用于在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;
执行模块,用于通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;
其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如第一方面所述的内存回收方法的步骤。
第四方面,本申请实施例提供了一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如第一方面所述的内存回收方法的步骤。
第五方面,本申请实施例提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现如第一方面所述的内存回收方法。
第六方面,提供了一种计算机程序产品,其中,所述计算机程序产品存储在非瞬态的存储介质中,所述计算机程序产品被至少一个处理器执行以实现如第一方面所述的内存回收方法。
第七方面,提供了一种通信设备,其中,被配置为执行如第一方面所述的内存回收方法。
在本申请实施例中,在电子设备可用内存不足的情况下,唤醒预先创建 的后台代理进程;通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。这样,通过预先创建的后台代理进程来遍历执行对电子设备的系统模块的内存回收流程,而无需前台应用进程参与系统模块的内存回收流程,且由于该后台代理进程绑定在处理能力较差的处理器上运行,从而可避免前台应用因等待系统内存回收或被抢占处理器资源所造成的响应延迟。
附图说明
图1是本申请实施例提供的内存回收方法的流程图;
图2a是本申请实施例提供的内存回收方法的举例流程图之一;
图2b是本申请实施例提供的内存回收方法的举例流程图之二;
图3是本申请实施例提供的内存回收装置的结构示意图;
图4是本申请实施例提供的电子设备的结构示意图之一;
图5是本申请实施例提供的电子设备的结构示意图之二。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员获得的所有其他实施例,都属于本申请保护的范围。
本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说 明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。
下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的内存回收方法进行详细地说明。
请参见图1,图1为本申请实施例提供的内存回收方法的流程图,如图1所示,该方法包括以下步骤:
步骤101、在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程。
本申请实施例中,为了减少前台应用参与系统模块内存的回收流程所带来的响应延迟,可以预先创建后台代理进程(shrinker proxy),并且在正常的不需要回收内存的情况下,该后台代理进程处于休眠状态,等待唤醒。
在电子设备启动大量应用程序,以致当前运行应用进程过多,导致内存不够用时,可以启动内存回收工作,以腾出一定内存供当前应用进程使用。具体地,可以在检测到电子设备可用内存不足的情况下,立即唤醒预先创建的所述后台代理进程,以通过所述后台代理进程来完成所述电子设备的系统模块内存的回收工作。
其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
即在所述电子设备包括多核处理器如双核处理器时,可以将所述后台代理进程绑定在处理能力较差的小核运行,所述电子设备的前台应用进程则在处理能力较强的大核上运行,这样,通过将系统内存回收工作交给小核处理,可以避免所述后台代理进程与前台应用进程抢占大核而造成前台应用进程卡顿,还有助于降低功耗。
可选地,所述唤醒预先创建的后台代理进程之前,所述方法还包括:
在所述电子设备可用内存不足的情况下,回收所述电子设备的后台应用进程占用的内存。
即在检测到所述电子设备可用内存不足的情况下,可以先回收所述电子设备的后台应用进程占用的内存,例如,通过交换(swap)或者清除(clean)的方式回收其他后台运行应用所占用的内存,以尽快给前台应用进程腾出内存,在回收完所述电子设备的后台应用进程占用的内存后,再唤醒所述后台代理进程,以继续进行系统模块的内存回收流程。
这样,前台应用进程只需要执行回收后台应用进程占用的内存流程和唤醒后台代理进程即可,而不需要参与耗时较长的系统模块内存回收流程,从而可提高回收质量,加速前台应用进程响应时间。
步骤102、通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程。
该步骤中,在唤醒所述后台代理进程后,便可以通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程,具体地,可以通过所述后台代理进程遍历所述电子设备的每个系统模块,使每个系统模块依次注册shrinker回调函数,进而依次回收各系统模块占用的内存,直至最后一个系统模块的内存回收完毕,所述后台代理进程的任务执行终止。其中,所述系统模块可以是指所述电子设备的蓝牙、无线网络通信技术(Wireless Fidelity,WiFi)、显示屏等各类系统驱动模块。
这样,通过将系统模块的内存回收流程转移至后台代理进程,使得前台应用无需等待系统模块的内存回收时间,且用户对后台进程几乎无感知,从而可以加快前台应用的响应速度,避免出现随机卡顿。
可选地,所述唤醒预先创建的后台代理进程,包括:
在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于第一预设时长的情况下,唤醒所述后台代理进程。
即一种实施方中,考虑到频率唤醒所述后台代理进程对系统内存回收效益并无太大帮助,反而会徒增系统开销,因此,可以设置一定的唤醒间隔,以避免重复唤醒。具体地,可以先获取所述后台代理进程上次唤醒的时刻,判断该时刻是否距离当前时刻第一预设时长以上,若是,则可以唤醒所述后 台代理进程,否则可以忽略本次唤醒,使所述后台代理进程保持休眠状态,转到回收后台应用进程的内存流程,以侧重回收后台应用进程内存。其中,所述第一预设时长即为预设的唤醒间隔,例如,可以设置为10ms、15ms等。
可选地,所述步骤101之后,所述方法还包括:
获取所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔;
在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔小于第二预设时长的情况下,控制所述后台代理进程进入休眠状态;
所述步骤102包括:
在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于所述第二预设时长的情况下,通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程。
即另一种实施方式中,同样地,考虑到频繁开启所述后台代理进程对系统内存回收效益无太大帮助,反而会徒增系统开销,可以在唤醒所述后台代理进程后,立即检测所述后台代理进程上次唤醒的时刻是否距离当前时刻第二预设时长以上,若是,则可以通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程,否则可以关闭所述后台代理进程,使其重新进入休眠状态,并可以转到回收后台应用进程的内存流程,以侧重回收后台应用进程内存。其中,所述第二预设时长也是预设的唤醒间隔,可以与上述第一预设时长相同,也可以不同,例如,可以设置为10ms、15ms等。
这样,通过预设的唤醒间隔,来控制所述后台应用进程是否唤醒或是否进入工作状态,可以避免重复唤醒所述后台应用进程,带来不必要的系统开销。
可选地,所述步骤102之后,所述方法还包括:
在遍历执行完所述电子设备的系统模块的内存回收流程之后,控制所述后台代理进程进入休眠状态。
即在所述后台代理进程遍历执行完所述电子设备的系统模块的内存回收流程之后,可以控制所述后台代理进程重新进入休眠状态,等待下次唤醒, 以避免不必要的后台进程资源开销。
下面结合图2a和图2b对本申请实施例进行举例说明,本申请实施例中电子设备的内存回收方法的大致流程可如图2a所示,具体步骤如图2b所示。
步骤201中,创建后台代理进程(shrinker proxy),并考虑到系统模块回收工作的收益比不高,可以将该后台代理进程绑定在小核运行,避免和前台应用进程抢占大核,并使该后台代理进程进入休眠状态,等待唤醒。
步骤202中,当系统可用内存不足时,前台应用进程会申请不到内存,从而进入其他后台应用进程内存回收流程。
步骤203中,准备唤醒后台代理进程,其中考虑到频繁唤醒意义不大,因此增加一个10ms唤醒间隔,避免重复唤醒。一旦发现该后台代理进程10ms内频繁唤醒,则忽略此次唤醒,转到回收其他后台应用进程的内存流程,这样可以侧重回收其他进程内存。
步骤204中,唤醒后台代理进程。
其中,上述步骤202至步骤204为前台应用进程逻辑。
步骤205中,后台代理进程在开机后一直处于休眠状态,等待唤醒,直到唤醒后进入下一步骤。
步骤206中,后台代理进程负责遍历执行所有系统模块注册的shrinker回调函数进行系统模块内存回收。回收结束后再回到上一步,即进入休眠状态,等待下次唤醒。
其中,上述步骤205至步骤206为后台代理进程逻辑。
现有技术中,通过前台应用进程进行系统模块内存回收方法存在以下不足之处:
1)由于所有系统模块都可以注册shrinker回调函数,并且系统模块是通过链表来管理和遍历,这样每次遍历的耗时与shrinker函数数量成O(n)线性关系,影响回收速度,容易造成前台应用延迟。系统模块数量越多,注册越多,延迟越大。
2)shrinker回调函数是系统模块实现的,每个系统模块实现不一,有些 系统模块执行shrinker快,有些执行慢,从而会影响整个回收时间的可确定性,容易造成前台应用随机性卡顿。
3)由于系统后台也会周期性遍历所有系统模块,因此各个系统模块中可回收内存大概率是很少的。最坏的情况下前台应用进程可能遍历了所有的系统模块都不一定有可回收内存,收益低甚至徒劳无功,浪费资源。因此对于前台应用进程而言,应该侧重回收其他后台应用进程占用的内存。
而本申请实施例在对现有方案进行改进后,能够实现加速系统内存回收,通过后台代理方法转移低效工作,提升系统可用内存回收速度,相比现有方案具有以下优点:
1)提升回收效率,前台应用进程不需要再遍历系统模块注册shrinker,不管系统模块注册量多少,都只有唤醒代理的开销,基本可以达到O(1)的开销,从而可增加回收时间可确定性,整体加速系统内存回收速度。
2)提高回收质量,侧重回收进程级的内存,回收收益更可观,可以快速提高系统可用内存。
3)降低随机性卡顿,遍历过程所需等待资源的开销转移到后台代理上,前台应用进程无感知,因此可大大降低由于系统内存回收压力引入的随机性卡顿。
4)降低功耗,重复的系统内存回收工作,交给小核上运行的后台代理执行,有助于降低处理器资源开销。
5)提高前台应用响应速度,后台代理进程运行在小核,可避免和前台应用进程抢占大核风险,间接提高前台响应速度。
本申请实施例中的内存回收方法,在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。这样,通过预先创建的后台代理进程来遍历执行对 电子设备的系统模块的内存回收流程,而无需前台应用进程参与系统模块的内存回收流程,且由于该后台代理进程绑定在处理能力较差的处理器上运行,从而可避免前台应用因等待系统内存回收或被抢占处理器资源所造成的响应延迟。
需要说明的是,本申请实施例提供的内存回收方法,执行主体可以为内存回收装置,或者该内存回收装置中的用于执行内存回收方法的控制模块。本申请实施例中以内存回收装置执行内存回收方法为例,说明本申请实施例提供的内存回收装置。
请参见图3,图3为本申请实施例提供的内存回收装置的结构示意图,如图3所示,内存回收装置300包括:
唤醒模块301,用于在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;
执行模块302,用于通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;
其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
可选地,唤醒模块301用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于第一预设时长的情况下,唤醒所述后台代理进程。
可选地,内存回收装置300还包括:
获取模块,用于获取所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔;
第一处理模块,用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔小于第二预设时长的情况下,控制所述后台代理进程进入休眠状态;
执行模块302用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于所述第二预设时长的情况下,通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程。
可选地,内存回收装置300还包括:
第二处理模块,用于在遍历执行完所述电子设备的系统模块的内存回收流程之后,控制所述后台代理进程进入休眠状态。
可选地,内存回收装置300还包括:
回收模块,用于在所述电子设备可用内存不足的情况下,回收所述电子设备的后台应用进程占用的内存。
本申请实施例中的内存回收装置,在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。这样,通过预先创建的后台代理进程来遍历执行对电子设备的系统模块的内存回收流程,而无需前台应用进程参与系统模块的内存回收流程,且由于该后台代理进程绑定在处理能力较差的处理器上运行,从而可避免前台应用因等待系统内存回收或被抢占处理器资源所造成的响应延迟。
本申请实施例中的内存回收装置可以是装置,也可以是终端中的部件、集成电路、或芯片。该装置可以是移动电子设备,也可以为非移动电子设备。示例性的,移动电子设备可以为手机、平板电脑、笔记本电脑、掌上电脑、车载电子设备、可穿戴设备、超级移动个人计算机(Ultra-Mobile Personal Computer,UMPC)、上网本或者个人数字助理(Personal Digital Assistant,PDA)等,非移动电子设备可以为服务器、网络附属存储器(Network Attached Storage,NAS)、个人计算机(Personal Computer,PC)、电视机(Television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。
本申请实施例中的内存回收装置可以为具有操作系统的装置。该操作系统可以为安卓(Android)操作系统,可以为ios操作系统,还可以为其他可能的操作系统,本申请实施例不作具体限定。
本申请实施例提供的内存回收装置能够实现图N至图2的方法实施例实现的各个过程,为避免重复,这里不再赘述。
可选地,如图4所示,本申请实施例还提供一种电子设备400,包括处理器401,存储器402,存储在存储器402上并可在所述处理器401上运行的程序或指令,该程序或指令被处理器401执行时实现上述内存回收方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
需要说明的是,本申请实施例中的电子设备包括上述所述的移动电子设备和非移动电子设备。
图5为实现本申请实施例的一种电子设备的硬件结构示意图。
该电子设备500包括但不限于:射频单元501、网络模块502、音频输出单元503、输入单元504、传感器505、显示单元506、用户输入单元507、接口单元508、存储器509、以及处理器510等部件。
本领域技术人员可以理解,电子设备500还可以包括给各个部件供电的电源(比如电池),电源可以通过电源管理系统与处理器510逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。图5中示出的电子设备结构并不构成对电子设备的限定,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置,在此不再赘述。
其中,处理器510,用于在电子设备500可用内存不足的情况下,唤醒预先创建的后台代理进程;
通过所述后台代理进程遍历执行电子设备500的系统模块的内存回收流程;
其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
可选地,处理器510,还用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于第一预设时长的情况下,唤醒所述后台代理进程。
可选地,处理器510,还用于获取所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔;
在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔小于第二预设时长的情况下,控制所述后台代理进程进入休眠状态;
在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于所述第二预设时长的情况下,通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程。
可选地,处理器510,还用于在遍历执行完所述电子设备的系统模块的内存回收流程之后,控制所述后台代理进程进入休眠状态。
可选地,处理器510,还用于在所述电子设备可用内存不足的情况下,回收所述电子设备的后台应用进程占用的内存。
本申请实施例中的电子设备,在可用内存不足的情况下,唤醒预先创建的后台代理进程;通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。这样,通过预先创建的后台代理进程来遍历执行对电子设备的系统模块的内存回收流程,而无需前台应用进程参与系统模块的内存回收流程,且由于该后台代理进程绑定在处理能力较差的处理器上运行,从而可避免前台应用因等待系统内存回收或被抢占处理器资源所造成的响应延迟。
应理解的是,本申请实施例中,输入单元504可以包括图形处理器(Graphics Processing Unit,GPU)5041和麦克风5042,图形处理器5041对在视频捕获模式或图像捕获模式中由图像捕获装置(如摄像头)获得的静态图片或视频的图像数据进行处理。显示单元506可包括显示面板5061,可以采用液晶显示器、有机发光二极管等形式来配置显示面板5061。用户输入单元507包括触控面板5071以及其他输入设备5072。触控面板5071,也称为触摸屏。触控面板5071可包括触摸检测装置和触摸控制器两个部分。其他输 入设备5072可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆,在此不再赘述。存储器509可用于存储软件程序以及各种数据,包括但不限于应用程序和操作系统。处理器510可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器510中。
本申请实施例还提供一种可读存储介质,所述可读存储介质可以是非易失的,也可以是易失的,所述可读存储介质上存储有程序或指令,该程序或指令被处理器执行时实现上述内存回收方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
其中,所述处理器为上述实施例中所述的电子设备中的处理器。所述可读存储介质,包括计算机可读存储介质,如计算机只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等。
本申请实施例另提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现上述内存回收方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
应理解,本申请实施例提到的芯片还可以称为系统级芯片、系统芯片、芯片系统或片上系统芯片等。
本申请实施例另提供了一种计算机程序产品,其中,所述计算机程序产品被存储在非瞬态的可读存储介质中,所述计算机程序产品被至少一个处理器执行以实现上述内存回收方法实施例中的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还 包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。此外,需要指出的是,本申请实施方式中的方法和装置的范围不限按示出或讨论的顺序来执行功能,还可包括根据所涉及的功能按基本同时的方式或按相反的顺序来执行功能,例如,可以按不同于所描述的次序来执行所描述的方法,并且还可以添加、省去、或组合各种步骤。另外,参照某些示例所描述的特征可在其他示例中被组合。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以计算机软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。

Claims (15)

  1. 一种内存回收方法,包括:
    在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;
    通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;
    其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
  2. 根据权利要求1所述的方法,其中,所述唤醒预先创建的后台代理进程,包括:
    在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于第一预设时长的情况下,唤醒所述后台代理进程。
  3. 根据权利要求1所述的方法,其中,所述唤醒预先创建的后台代理进程之后,所述方法还包括:
    获取所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔;
    在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔小于第二预设时长的情况下,控制所述后台代理进程进入休眠状态;
    所述通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程,包括:
    在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于所述第二预设时长的情况下,通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程。
  4. 根据权利要求1所述的方法,其中,所述通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程之后,所述方法还包括:
    在遍历执行完所述电子设备的系统模块的内存回收流程之后,控制所述 后台代理进程进入休眠状态。
  5. 根据权利要求1所述的方法,其中,所述唤醒预先创建的后台代理进程之前,所述方法还包括:
    在所述电子设备可用内存不足的情况下,回收所述电子设备的后台应用进程占用的内存。
  6. 一种内存回收装置,包括:
    唤醒模块,用于在电子设备可用内存不足的情况下,唤醒预先创建的后台代理进程;
    执行模块,用于通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程;
    其中,所述后台代理进程绑定在所述电子设备的多核处理器中的第一处理器上运行,所述电子设备的前台应用进程在所述电子设备的多核处理器中的第二处理器上运行,所述第一处理器的处理能力差于所述第二处理器。
  7. 根据权利要求6所述的内存回收装置,其中,所述唤醒模块用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于第一预设时长的情况下,唤醒所述后台代理进程。
  8. 根据权利要求6所述的内存回收装置,其中,所述内存回收装置还包括:
    获取模块,用于获取所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔;
    第一处理模块,用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔小于第二预设时长的情况下,控制所述后台代理进程进入休眠状态;
    所述执行模块用于在所述后台代理进程上次唤醒的时刻与当前时刻的时间间隔大于或等于所述第二预设时长的情况下,通过所述后台代理进程遍历执行所述电子设备的系统模块的内存回收流程。
  9. 根据权利要求6所述的内存回收装置,其中,所述内存回收装置还包括:
    第二处理模块,用于在遍历执行完所述电子设备的系统模块的内存回收流程之后,控制所述后台代理进程进入休眠状态。
  10. 根据权利要求6所述的内存回收装置,其中,所述内存回收装置还包括:
    回收模块,用于在所述电子设备可用内存不足的情况下,回收所述电子设备的后台应用进程占用的内存。
  11. 一种电子设备,该电子设备包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的程序或指令,其中,所述程序或指令被所述处理器执行时实现如权利要求1至5中任一项所述的内存回收方法的步骤。
  12. 一种可读存储介质,所述可读存储介质上存储程序或指令,其中,所述程序或指令被处理器执行时实现如权利要求1至5中任一项所述的内存回收方法的步骤。
  13. 一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,其中,所述处理器用于运行程序或指令,实现如权利要求1至5中任一项所述的内存回收方法的步骤。
  14. 一种计算机程序产品,其中,所述计算机程序产品存储在非瞬态的存储介质中,所述计算机程序产品被至少一个处理器执行以实现如权利要求1至5中任一项所述的内存回收方法的步骤。
  15. 一种通信设备,被配置为执行如权利要求1至5中任一项所述的内存回收方法的步骤。
PCT/CN2022/093573 2021-05-19 2022-05-18 内存回收方法、装置和电子设备 WO2022242683A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110547218.9A CN113268438B (zh) 2021-05-19 2021-05-19 内存回收方法、装置和电子设备
CN202110547218.9 2021-05-19

Publications (1)

Publication Number Publication Date
WO2022242683A1 true WO2022242683A1 (zh) 2022-11-24

Family

ID=77231868

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/093573 WO2022242683A1 (zh) 2021-05-19 2022-05-18 内存回收方法、装置和电子设备

Country Status (2)

Country Link
CN (1) CN113268438B (zh)
WO (1) WO2022242683A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113268438B (zh) * 2021-05-19 2024-03-08 维沃移动通信有限公司 内存回收方法、装置和电子设备
CN115016885B (zh) * 2021-11-19 2023-11-24 荣耀终端有限公司 虚拟机垃圾回收运行方法及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109697119A (zh) * 2017-10-20 2019-04-30 中兴通讯股份有限公司 终端内存回收处理方法及装置
US20190220318A1 (en) * 2016-09-27 2019-07-18 Huawei Technologies Co., Ltd. Memory Reclamation Method and Apparatus
CN111966492A (zh) * 2020-08-05 2020-11-20 Oppo广东移动通信有限公司 内存回收方法、装置、电子设备及计算机可读存储介质
CN112817428A (zh) * 2021-01-25 2021-05-18 广州虎牙科技有限公司 任务运行方法、装置、移动终端和存储介质
CN113268438A (zh) * 2021-05-19 2021-08-17 维沃移动通信有限公司 内存回收方法、装置和电子设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110018902B (zh) * 2018-01-10 2023-01-31 Oppo广东移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110045809A (zh) * 2018-01-12 2019-07-23 广东欧珀移动通信有限公司 信息处理方法、装置、计算机设备和计算机可读存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190220318A1 (en) * 2016-09-27 2019-07-18 Huawei Technologies Co., Ltd. Memory Reclamation Method and Apparatus
CN109697119A (zh) * 2017-10-20 2019-04-30 中兴通讯股份有限公司 终端内存回收处理方法及装置
CN111966492A (zh) * 2020-08-05 2020-11-20 Oppo广东移动通信有限公司 内存回收方法、装置、电子设备及计算机可读存储介质
CN112817428A (zh) * 2021-01-25 2021-05-18 广州虎牙科技有限公司 任务运行方法、装置、移动终端和存储介质
CN113268438A (zh) * 2021-05-19 2021-08-17 维沃移动通信有限公司 内存回收方法、装置和电子设备

Also Published As

Publication number Publication date
CN113268438A (zh) 2021-08-17
CN113268438B (zh) 2024-03-08

Similar Documents

Publication Publication Date Title
WO2022242683A1 (zh) 内存回收方法、装置和电子设备
EP3087474B1 (en) Apparatus and method for managing graphics buffers for a processor in sleep mode
EP3276928B1 (en) Terminal control method, device and terminal
CN110018901B (zh) 内存回收方法、装置、计算机设备和计算机可读存储介质
CN107407956B (zh) 用于在计算设备内的多个soc之间协调操作状态的方法和系统
CN103425225B (zh) 便携数据设备操作系统中的应用程序装置及其运行方法
CN101539803B (zh) 待机管理方法及其相关待机管理模块
JP6446548B2 (ja) 主mcuウェイクアップ回路、方法、及び装置
CN109426525A (zh) 一种针对计算机的睡眠状态唤醒的方法及装置
WO2022206584A1 (zh) 电子设备、显示控制方法、显示控制装置和可读存储介质
CN104636169B (zh) 一种系统唤醒方法及装置
CN104571839A (zh) 一种终端及其处理方法、装置
WO2022111502A1 (zh) 应用缓存的清理方法、装置、电子设备及介质
CN104808767A (zh) 一种终端控制方法
WO2019128574A1 (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
CN104808766A (zh) 一种终端
CN103260224A (zh) 一种移动终端及其实现充电时刷新充电动画的方法
CN107231386B (zh) 应用状态转换方法、装置及移动终端
WO2024078494A1 (zh) 线程管理方法、装置、电子设备及存储介质
CN109992314A (zh) 数据上报方法、装置、终端和存储介质
JPWO2008084541A1 (ja) 受信装置及び受信装置の起動制御方法
US20140237475A1 (en) Sleep/wake with suppression and donated importance
JP7231535B2 (ja) スマートデバイスの制御方法、スマートデバイスの制御装置、電子機器及び記憶媒体
CN111897581B (zh) 息屏唤醒方法、装置、存储介质及一体机设备
WO2021115212A1 (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: 22804003

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: 22804003

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO 17/04/2024)