CN116820734A - A method and electronic device for controlling memory - Google Patents
A method and electronic device for controlling memory Download PDFInfo
- Publication number
- CN116820734A CN116820734A CN202210271760.0A CN202210271760A CN116820734A CN 116820734 A CN116820734 A CN 116820734A CN 202210271760 A CN202210271760 A CN 202210271760A CN 116820734 A CN116820734 A CN 116820734A
- Authority
- CN
- China
- Prior art keywords
- cold
- electronic device
- task
- cold object
- objects
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Stored Programmes (AREA)
Abstract
本申请提供了一种控制内存的方法和电子设备,该方法应用于电子设备,该方法包括:电子设备将任务的区分对象为冷对象和热对象;该冷对象为该任务的时间窗口内没有访问到的对象;该热对象为该任务的时间窗口内访问到的对象;电子设备将冷对象移入到交换空间,保存冷对象的引用信息;该冷对象的引用信息包括该冷对象的引用关系;根据冷对象的引用关系,移出或者保存该冷对象。本申请实施例中,电子设备将需要移入到交换空间的冷对象与其他对象区分,能够避免电子设备将其他对象移入交换空间,减少一定的开销;同时,电子设备在移出对象到内存之前判断该对象是否需要移出,能够避免系统内存占用过大而关闭进程。
The present application provides a method and electronic device for controlling memory. The method is applied to the electronic device. The method includes: the electronic device distinguishes the objects of the task into cold objects and hot objects; the cold object does not exist within the time window of the task. The accessed object; the hot object is the object accessed within the time window of the task; the electronic device moves the cold object into the swap space and saves the reference information of the cold object; the reference information of the cold object includes the reference relationship of the cold object ; According to the reference relationship of the cold object, remove or save the cold object. In the embodiment of the present application, the electronic device distinguishes the cold objects that need to be moved into the swap space from other objects, which can prevent the electronic device from moving other objects into the swap space and reduce a certain overhead; at the same time, the electronic device determines the object before moving it out to the memory. Whether the object needs to be moved out can prevent the system from taking up too much memory and shutting down the process.
Description
技术领域Technical field
本申请涉及电子设备领域,并且更加具体地,涉及一种控制内存的方法和电子设备。The present application relates to the field of electronic equipment, and more specifically, to a method of controlling a memory and an electronic equipment.
背景技术Background technique
安卓(Android)手机的运行时通常使用垃圾回收(garbage collection,GC)进行内存管理。但这种GC的过程会把操作系统虚拟内存换出到交换空间的数据重新换入内存。而数据在交换空间和内存之间频繁的换出换入会增大手机系统的开销。在内存压力大的情况下,手机系统为了保证用户操作的流畅性,会选择主动杀死一些进程,导致重新启动被杀死的进程时会有较高的延迟。The runtime of Android phones usually uses garbage collection (GC) for memory management. But this GC process will swap the data out of the operating system's virtual memory into the swap space back into the memory. Frequent swapping of data in and out of swap space and memory will increase the overhead of the mobile phone system. When the memory pressure is high, in order to ensure the smoothness of user operations, the mobile phone system will choose to actively kill some processes, resulting in a high delay when restarting the killed processes.
发明内容Contents of the invention
本申请实施例提供一种控制内存的方法和电子设备,有助于充分利用交换空间从而减少应用的内存占用,以确保系统的流畅性。Embodiments of the present application provide a method and electronic device for controlling memory, which helps to make full use of swap space to reduce the memory usage of applications and ensure system fluency.
第一方面,提供了一种控制内存的方法,该方法应用于电子设备,该方法包括:电子设备将第一任务的对象区分为第一冷对象和第一热对象;其中,该对象之间具有引用关系;该第一冷对象为该第一任务的时间窗口内没有访问到的对象;该第一热对象为该第一任务的时间窗口内访问到的对象;将该第一冷对象从内存移入到交换空间;保存该第一冷对象的引用信息,该第一冷对象的引用信息包括该第一冷对象的引用关系;根据该第一冷对象的引用信息,移出或者保存该第一冷对象。应理解,在当前任务(第一任务)中,电子设备将内存中的冷对象移入到交换空间中(该过程可称为“换出”),能够减少冷对象对内存的占用,有助于避免内存压力过大,进而避免系统主动杀死进程。本申请实施例中,电子设备利用GC拷贝过程,将第一任务的所有存活对象识别并区分为冷对象和热对象,避免还在经常使用的热对象也被换出到交换空间。同时,电子设备根据冷对象的引用信息确定对该冷对象的后续执行行为,可以是移出该交换空间或者保存在该交换空间内。该方法可以尽量避免不必要的对象移出该交换空间的过程,减少内存压力。In a first aspect, a method of controlling memory is provided. The method is applied to an electronic device. The method includes: the electronic device distinguishes the object of the first task into a first cold object and a first hot object; wherein, between the objects has a reference relationship; the first cold object is an object that is not accessed within the time window of the first task; the first hot object is an object that is accessed within the time window of the first task; the first cold object is moved from The memory is moved into the swap space; the reference information of the first cold object is saved, and the reference information of the first cold object includes the reference relationship of the first cold object; and the first cold object is removed or saved according to the reference information of the first cold object. Cold objects. It should be understood that in the current task (the first task), the electronic device moves the cold objects in the memory into the swap space (this process can be called "swapping out"), which can reduce the memory occupied by the cold objects and contribute to Avoid excessive memory pressure and prevent the system from actively killing processes. In the embodiment of the present application, the electronic device uses the GC copy process to identify and distinguish all surviving objects of the first task into cold objects and hot objects to prevent hot objects that are still in frequent use from being swapped out to the swap space. At the same time, the electronic device determines the subsequent execution behavior of the cold object based on the reference information of the cold object, which may be to move it out of the swap space or save it in the swap space. This method can try to avoid the process of moving unnecessary objects out of the swap space and reduce memory pressure.
结合第一方面,在第一方面的某些实现方式中,该方法还包括:该电子设备将该第一冷对象保存至第一目标空间。本申请实施例中,电子设备将第一冷对象保存在第一目标空间中,避免将所有的存活对象保存在空闲的目标空间中。也就是说,将第一冷对象与其他对象分别保存在不同的目标空间中,便于后续步骤对多个第一冷对象的操作。In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the electronic device saving the first cold object to the first target space. In the embodiment of the present application, the electronic device saves the first cold object in the first target space to avoid saving all surviving objects in the free target space. That is to say, the first cold object and other objects are stored in different target spaces respectively to facilitate operations on multiple first cold objects in subsequent steps.
结合第一方面,在第一方面的某些实现方式中,该方法还包括:当该第一冷对象包括多个冷对象时,该电子设备将该第一冷对象保存至第一目标空间;包括将该第一冷对象保存至该第一目标空间的第一内存页中。本申请实施例中,电子设备将第一冷对象聚集在第一内存页中,便于将所有的第一冷对象全部移入到交换空间中。该方法能够提高电子设备将对象移入到交换空间的效率,更加充分利用交换空间,并减少内存占用。In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: when the first cold object includes multiple cold objects, the electronic device saves the first cold object to the first target space; Including saving the first cold object into the first memory page of the first target space. In the embodiment of the present application, the electronic device gathers the first cold objects in the first memory page to facilitate moving all the first cold objects into the swap space. This method can improve the efficiency of electronic devices in moving objects into the swap space, make more full use of the swap space, and reduce memory usage.
结合第一方面,在第一方面的某些实现方式中,该方法还包括:该第一任务内,该电子设备将第二任务的对象区分为第二冷对象和第二热对象,其中,该对象之间具有引用关系;该第二冷对象为该第二任务的时间窗口内没有访问到的对象;该第二热对象为该第二任务的时间窗口内访问到的对象,该第二任务为该第一任务的下一个任务;将该第二冷对象从该内存移入到该交换空间;保存该第二冷对象的引用信息,该第二冷对象的引用信息包括该第二冷对象的引用关系;根据该第二冷对象的引用信息,移出或者保存该第二冷对象。应理解,对于任务估计的方法可以使用基于活动(Activity)的方法,也可以将服务(Service)也考虑进来,也可以是基于线程的方法,本申请对此不作限定。本申请实施例中,当用户多次访问相同的任务时,程序会访问类似的工作集。因此,在第一任务还未结束之前,可以根据预测的工作集预测下一任务(第二任务)的对象访问情况。并且,电子设备将第二任务的对象区分为的冷对象和热对象。在内存压力到来之前,电子设备提前将下一任务的冷对象(第二冷对象)移入到交换空间中,能够有效避免内存压力过大。In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: within the first task, the electronic device distinguishes the objects of the second task into second cold objects and second hot objects, wherein, There is a reference relationship between the objects; the second cold object is an object that is not accessed within the time window of the second task; the second hot object is an object that is accessed within the time window of the second task, and the second hot object is an object that is accessed within the time window of the second task. The task is the next task of the first task; move the second cold object from the memory to the swap space; save the reference information of the second cold object, and the reference information of the second cold object includes the second cold object The reference relationship of the second cold object; remove or save the second cold object according to the reference information of the second cold object. It should be understood that the task estimation method may use an activity-based method, may also take services (Service) into consideration, or may be a thread-based method, which is not limited in this application. In the embodiment of this application, when a user accesses the same task multiple times, the program will access similar working sets. Therefore, before the first task ends, the object access situation of the next task (the second task) can be predicted based on the predicted working set. Furthermore, the electronic device distinguishes the objects of the second task into cold objects and hot objects. Before memory pressure arrives, the electronic device moves the cold objects of the next task (second cold objects) into the swap space in advance, which can effectively avoid excessive memory pressure.
结合第一方面,在第一方面的某些实现方式中,该方法还包括:该电子设备将该第二冷对象保存至第二目标空间。本申请实施例中,电子设备将第二冷对象保存在第二冷空间中,避免将所有的存活对象保存在空闲的目标空间中。也就是说,将第二冷对象与其他对象分别保存在不同的空间中,便于后续步骤对多个第二冷对象的操作。In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the electronic device saving the second cold object to the second target space. In the embodiment of the present application, the electronic device stores the second cold object in the second cold space to avoid storing all surviving objects in the free target space. That is to say, the second cold object and other objects are stored in different spaces to facilitate operations on multiple second cold objects in subsequent steps.
结合第一方面,在第一方面的某些实现方式中,该方法还包括:当该第二冷对象包括多个冷对象时,该电子设备将该第二冷对象保存至第二目标空间,包括:将该第二冷对象保存至该第二目标空间的第二内存页中。本申请实施例中,电子设备将多个冷对象聚集在第二内存页中,便于将所有的第二冷对象全部移入到交换空间中。该方法能够提高电子设备将对象移入到交换空间的效率,更加充分利用交换空间,并减少内存占用。In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: when the second cold object includes multiple cold objects, the electronic device saves the second cold object to the second target space, It includes: saving the second cold object to the second memory page of the second target space. In the embodiment of the present application, the electronic device gathers multiple cold objects in the second memory page to facilitate moving all the second cold objects into the swap space. This method can improve the efficiency of electronic devices in moving objects into the swap space, make more full use of the swap space, and reduce memory usage.
结合第一方面,在第一方面的某些实现方式中,该移出或者保存该第一冷对象,包括:当根据该第一冷对象的引用信息确定该第一冷对象为该第二冷对象时,将该第一冷对象保存在该交换空间内;当根据该第一冷对象的引用信息确定该第一冷对象为该第二热对象时,将该第一冷对象从该交换空间移出到该内存。示例性地,在第一冷对象换出到交换空间时,将该第一冷对象的引用信息保存在第一集合中,第二集合包含该第一集合,第二集合为根集合,电子设备利用现有GC过程的开始阶段,在扫描第二集合(根集合)时,能够保证找到全部的存活对象。其中,可以用第一集合(例如:Remember Set)保存该第一冷对象的引用信息,也可以用表保存该第一冷对象的引用信息,本申请对此不作限定。利用现有GC过程的开始阶段,在扫描根集合时,能够保找出全部的存活对象,当确定第一冷对象在当前GC过程之后仍属于冷对象时,将该第一冷对象仍保存在该交换空间中。本申请实施例中,电子设备将第一冷对象换出到交换空间的同时创建第一集合,并将第一集合加入到第二集合内。这可以保证能够扫描到所有的存活对象。电子设备在GC扫描之前,首先判断该第一冷对象是否仍为冷对象;当电子设备确定该第一冷对象在垃圾回收之后仍为冷对象时,将该冷对象仍然保存在交换空间中。这可以避免冷对象被重新移出到内存中导致的内存占用大,以及频繁移入和移出导致的额外开销。In connection with the first aspect, in some implementations of the first aspect, removing or saving the first cold object includes: when the first cold object is determined to be the second cold object according to the reference information of the first cold object. when the first cold object is determined to be the second hot object according to the reference information of the first cold object, the first cold object is removed from the swap space to this memory. Exemplarily, when the first cold object is swapped out to the swap space, the reference information of the first cold object is saved in the first set, the second set contains the first set, and the second set is the root set, and the electronic device By utilizing the initial stage of the existing GC process, all surviving objects can be guaranteed to be found when scanning the second collection (root collection). The reference information of the first cold object may be stored in a first set (for example, Remember Set), or the reference information of the first cold object may be stored in a table, which is not limited in this application. Utilizing the initial stage of the existing GC process, when scanning the root collection, it is possible to ensure that all surviving objects are found. When it is determined that the first cold object still belongs to the cold object after the current GC process, the first cold object is still saved in in the swap space. In this embodiment of the present application, the electronic device creates a first set while swapping out the first cold object to the swap space, and adds the first set to the second set. This ensures that all live objects are scanned. Before the GC scan, the electronic device first determines whether the first cold object is still a cold object; when the electronic device determines that the first cold object is still a cold object after garbage collection, the cold object is still stored in the swap space. This avoids the large memory footprint caused by cold objects being moved back into memory, as well as the additional overhead caused by frequent moves in and out.
结合第一方面,在第一方面的某些实现方式中,该第一任务与该第二任务相同;该方法还包括:在该第一任务内,预测该第二任务的工作集;根据该第二任务的工作集,预测该第二任务的对象。本申请实施例中,电子设备通过预测下一次任务的对象访问情况,可以提前对第二任务的对象分别进行换入和换出。该方法中的电子设备能够在内存压力到来之前提前释放内存;或者提前确定需要移出到内存的对象,以便及时移出到内存中。In conjunction with the first aspect, in some implementations of the first aspect, the first task is the same as the second task; the method further includes: within the first task, predicting the working set of the second task; according to the The working set of the second task, predicting the objects of the second task. In the embodiment of the present application, by predicting the object access status of the next task, the electronic device can respectively swap in and swap out the objects of the second task in advance. The electronic device in this method can release the memory in advance before the memory pressure arrives; or determine the objects that need to be moved out of the memory in advance so that they can be moved out into the memory in time.
结合第一方面,在第一方面的某些实现方式中,该第一目标空间和该第二目标空间为新建的内存空间,或者,该第一目标空间和该第二目标空间属于区域空间中的空间。本申请实施例中,电子设备通过为冷对象创建或者划分空间,将冷对象保存在相应的空间中,以便将冷对象换出到交换空间中。In conjunction with the first aspect, in some implementations of the first aspect, the first target space and the second target space are newly created memory spaces, or the first target space and the second target space belong to a regional space. Space. In the embodiment of the present application, the electronic device creates or divides a space for the cold object, and saves the cold object in the corresponding space, so as to swap out the cold object to the swap space.
第二方面,提供了一种电子设备,该电子设备包括:一个或多个处理器;一个或多个存储器;该一个或多个存储器存储有一个或多个计算机程序,该一个或多个计算机程序包括指令,当该指令被该一个或多个处理器执行时,使得该电子设备执行以下步骤:电子设备将第一任务的对象区分为第一冷对象和第一热对象;其中,该对象之间具有引用关系;该第一冷对象为该第一任务的时间窗口内没有访问到的对象;该第一热对象为该第一任务的时间窗口内访问到的对象;将该第一冷对象从内存移入到交换空间;保存该第一冷对象的引用信息,该第一冷对象的引用信息包括该第一冷对象的引用关系;根据该第一冷对象的引用信息,移出或者保存该第一冷对象。In a second aspect, an electronic device is provided. The electronic device includes: one or more processors; one or more memories; the one or more memories store one or more computer programs, and the one or more computers The program includes instructions that, when executed by the one or more processors, cause the electronic device to perform the following steps: the electronic device distinguishes the objects of the first task into first cold objects and first hot objects; wherein, the object There is a reference relationship between them; the first cold object is an object that is not accessed within the time window of the first task; the first hot object is an object that is accessed within the time window of the first task; the first cold object is The object is moved from the memory to the swap space; the reference information of the first cold object is saved, and the reference information of the first cold object includes the reference relationship of the first cold object; and the reference information of the first cold object is moved out or saved according to the reference information of the first cold object. The first cold object.
结合第二方面,在第二方面的某些实现方式中,当该指令被该一个或多个处理器执行时,使得该电子设备执行以下步骤:该电子设备将该第一冷对象保存至第一目标空间。In conjunction with the second aspect, in some implementations of the second aspect, when the instruction is executed by the one or more processors, the electronic device is caused to perform the following steps: the electronic device saves the first cold object to the first cold object. a target space.
结合第二方面,在第二方面的某些实现方式中,当该第一冷对象包括多个冷对象时,该电子设备将该第一冷对象保存至第一目标空间,使得该电子设备执行以下步骤:将该第一冷对象保存至该第一目标空间的第一内存页中。In conjunction with the second aspect, in some implementations of the second aspect, when the first cold object includes multiple cold objects, the electronic device saves the first cold object to the first target space, so that the electronic device executes The following steps: save the first cold object to the first memory page of the first target space.
结合第二方面,在第二方面的某些实现方式中,当该指令被该一个或多个处理器执行时,使得该电子设备执行以下步骤:在该第一任务内,该电子设备将第二任务的对象区分为第二冷对象和第二热对象,其中,该对象之间具有引用关系;该第二冷对象为该第二任务的时间窗口内没有访问到的对象;该第二热对象为该第二任务的时间窗口内访问到的对象,该第二任务为该第一任务的下一个任务;将该第二冷对象从该内存移入到该交换空间;保存该第二冷对象的引用信息,该第二冷对象的引用信息包括该第二冷对象的引用关系;根据该第二冷对象的引用信息,移出或者保存该第二冷对象。In conjunction with the second aspect, in some implementations of the second aspect, when the instruction is executed by the one or more processors, the electronic device is caused to perform the following steps: within the first task, the electronic device will The objects of the second task are divided into a second cold object and a second hot object, where the objects have a reference relationship; the second cold object is an object that has not been accessed within the time window of the second task; the second hot object The object is accessed within the time window of the second task, and the second task is the next task of the first task; move the second cold object from the memory to the swap space; save the second cold object The reference information of the second cold object includes the reference relationship of the second cold object; according to the reference information of the second cold object, the second cold object is removed or saved.
结合第二方面,在第二方面的某些实现方式中,当该指令被该一个或多个处理器执行时,使得该电子设备执行以下步骤:该电子设备将所述第二冷对象保存至第二目标空间。In conjunction with the second aspect, in some implementations of the second aspect, when the instruction is executed by the one or more processors, the electronic device is caused to perform the following steps: the electronic device saves the second cold object to Second target space.
结合第二方面在,在第二方面的某些实现方式中,当该第二冷对象包括多个冷对象时,该电子设备将该第二冷对象保存至第二目标空间,使得该电子设备执行以下步骤:将该第二冷对象保存至该第二目标空间的第二内存页中。In conjunction with the second aspect, in some implementations of the second aspect, when the second cold object includes multiple cold objects, the electronic device saves the second cold object to the second target space, so that the electronic device Perform the following steps: save the second cold object to the second memory page of the second target space.
结合第二方面,在第二方面的某些实现方式中,该移出或者保存该第一冷对象,使得该电子设备执行以下步骤:当根据该第一冷对象的引用信息确定该第一冷对象为该第二冷对象时,将该第一冷对象保存在该交换空间内;当根据该第一冷对象的引用信息确定该第一冷对象为该第二热对象时,将该第一冷对象从该交换空间移出到该内存。In conjunction with the second aspect, in some implementations of the second aspect, removing or saving the first cold object causes the electronic device to perform the following steps: when determining the first cold object according to the reference information of the first cold object When it is the second cold object, the first cold object is saved in the swap space; when it is determined according to the reference information of the first cold object that the first cold object is the second hot object, the first cold object is stored in the swap space. Objects are moved out of the swap space into this memory.
结合第二方面,在第二方面的某些实现方式中,该第一任务与该第二任务相同,使得该电子设备执行以下步骤:在该第一任务内,预测该第二任务的工作集;根据该第二任务的工作集,预测该第二任务的对象。In conjunction with the second aspect, in some implementations of the second aspect, the first task is the same as the second task, so that the electronic device performs the following steps: within the first task, predict the working set of the second task ; Predict the object of the second task based on the working set of the second task.
结合第二方面,在第二方面的某些实现方式中,该第一目标空间和该第二目标空间为新建的内存空间,或者,该第一目标空间和该第二目标空间属于区域空间中的空间。Combined with the second aspect, in some implementations of the second aspect, the first target space and the second target space are newly created memory spaces, or the first target space and the second target space belong to a regional space. Space.
第三方面,提供了一种计算机可读存储介质,包括计算机指令,当该计算机指令在电子设备上运行时,使得该电子设备执行上述第一方面及第一方面任一可能实现的控制内存的方法。In a third aspect, a computer-readable storage medium is provided, including computer instructions. When the computer instructions are run on an electronic device, the electronic device causes the electronic device to execute the above-mentioned first aspect and any possible implementation of the first aspect to control the memory. method.
第四方面,提供了一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得该计算机执行上述第一方面及第一方面任一可能实现的的控制内存的方法。A fourth aspect provides a computer program product containing instructions, which when the computer program product is run on a computer, causes the computer to execute the above-mentioned first aspect and any method for controlling a memory that may be implemented in the first aspect.
附图说明Description of the drawings
图1是本实施例提供的一种电子设备的结构示意图。Figure 1 is a schematic structural diagram of an electronic device provided in this embodiment.
图2是传统并行复制垃圾回收过程示意图。Figure 2 is a schematic diagram of the traditional parallel copy garbage collection process.
图3是本申请实施例提供一种控制内存的方法所包含的模块示意图。FIG. 3 is a schematic diagram of modules included in a method for controlling memory provided by an embodiment of the present application.
图4是本申请实施例提供的一种第一模块的结构示意图。Figure 4 is a schematic structural diagram of a first module provided by an embodiment of the present application.
图5是本申请实施例提供的一种第二模块的结构示意图。Figure 5 is a schematic structural diagram of a second module provided by an embodiment of the present application.
图6是本申请实施例提供的一种第三模块的结构示意图。Figure 6 is a schematic structural diagram of a third module provided by an embodiment of the present application.
图7是本申请实施例提供的一种控制内存的方法的示意图。FIG. 7 is a schematic diagram of a method for controlling memory provided by an embodiment of the present application.
图8是本申请实施例提供的一种控制内存的方法的过程性示意图。FIG. 8 is a schematic process diagram of a method for controlling memory provided by an embodiment of the present application.
图9是本申请实施例提供的一种控制内存的方法的示意性流程图。Figure 9 is a schematic flow chart of a method for controlling memory provided by an embodiment of the present application.
具体实施方式Detailed ways
以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个、两个或两个以上。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。The terminology used in the following examples is for the purpose of describing specific embodiments only and is not intended to limit the application. As used in the specification and appended claims of this application, the singular expressions "a", "an", "said", "above", "the" and "the" are intended to also Expressions such as "one or more" are included unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, "at least one" and "one or more" refer to one, two or more than two. The term "and/or" is used to describe the relationship between associated objects, indicating that there can be three relationships; for example, A and/or B can mean: A exists alone, A and B exist simultaneously, and B exists alone, Where A and B can be singular or plural. The character "/" generally indicates that the related objects are in an "or" relationship.
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。Reference in this specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Therefore, the phrases "in one embodiment", "in some embodiments", "in other embodiments", "in other embodiments", etc. appearing in different places in this specification are not necessarily References are made to the same embodiment, but rather to "one or more but not all embodiments" unless specifically stated otherwise. The terms “including,” “includes,” “having,” and variations thereof all mean “including but not limited to,” unless otherwise specifically emphasized.
以下介绍电子设备、用于这样的电子设备的用户界面、和用于使用这样的电子设备的实施例。在一些实施例中,电子设备可以是还包含其它功能诸如个人数字助理和/或音乐播放器功能的便携式电子设备,诸如手机、平板电脑、具备无线通讯功能的可穿戴电子设备(如智能手表)等。便携式电子设备的示例性实施例包括但不限于搭载 或者其它操作系统的便携式电子设备。上述便携式电子设备也可以是其它便携式电子设备,诸如膝上型计算机(Laptop)等。还应当理解的是,在其他一些实施例中,上述电子设备也可以不是便携式电子设备,而是台式计算机。The following describes electronic devices, user interfaces for such electronic devices, and embodiments for using such electronic devices. In some embodiments, the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and/or a music player function, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch) wait. Exemplary embodiments of portable electronic devices include, but are not limited to, carrying Or portable electronic devices with other operating systems. The above-mentioned portable electronic device may also be other portable electronic devices, such as a laptop computer (Laptop). It should also be understood that in some other embodiments, the above-mentioned electronic device may not be a portable electronic device, but a desktop computer.
示例性的,图1示出了电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户身份识别(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。By way of example, FIG. 1 shows a schematic structural diagram of an electronic device 100 . The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently. The components illustrated may be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), an image signal processor ( image signal processor (ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc. . Among them, different processing units can be independent devices or integrated in one or more processors.
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller may be the nerve center and command center of the electronic device 100 . The controller can generate operation control signals based on the instruction operation code and timing signals to complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in processor 110 is cache memory. This memory may hold instructions or data that have been recently used or recycled by processor 110 . If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. Repeated access is avoided and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuitsound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purposeinput/output,GPIO)接口,用户身份识别(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuitsound, I2S) interface, a pulse code modulation (PCM) interface, and a universal asynchronous receiver (universal asynchronous receiver) /transmitter (UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and/or Universal serial bus (USB) interface, etc.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be reused as a diversity antenna for a wireless LAN. In other embodiments, antennas may be used in conjunction with tuning switches.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 can provide solutions for wireless communication including 2G/3G/4G/5G applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves through the antenna 1, perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least part of the functional modules of the mobile communication module 150 may be disposed in the processor 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。A modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be independent of the processor 110 and may be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wirelesslocal area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and global navigation satellite system. (global navigation satellite system, GNSS), frequency modulation (FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(codedivision multiple access,CDMA),宽带码分多址(wideband code division multipleaccess,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidounavigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellitesystem,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (codedivision multiple access, CDMA), broadband code Wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM , and/or IR technology, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou satellite navigation system (beidounavigation satellite system, BDS), quasi-zenith satellite system (quasi- zenith satellitesystem (QZSS) and/or satellite based augmentation systems (SBAS).
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is an image processing microprocessor and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emittingdiode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrixorganic light emitting diode的,AMOLED),柔性发光二极管(flex light-emittingdiode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot lightemitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos, etc. Display 194 includes a display panel. The display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode). (AMOLED), flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diodes (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera sensor through the lens, the optical signal is converted into an electrical signal, and the camera sensor passes the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193.
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object passes through the lens to produce an optical image that is projected onto the photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to convert it into a digital image signal. ISP outputs digital image signals to DSP for processing. DSP converts digital image signals into standard RGB, YUV and other format image signals. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as moving picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can continuously learn by itself. Intelligent cognitive applications of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, etc.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 . The external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function. Such as saving music, videos, etc. files in external memory card.
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行电子设备100的各种功能应用以及数据处理。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。Internal memory 121 may be used to store computer executable program code, which includes instructions. The processor 110 executes instructions stored in the internal memory 121 to execute various functional applications and data processing of the electronic device 100 . The internal memory 121 may include a program storage area and a data storage area. Among them, the stored program area can store an operating system, at least one application program required for a function (such as a sound playback function, an image playback function, etc.). The storage data area may store data created during use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), etc.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor. Such as music playback, recording, etc.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。Speaker 170A, also called "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music through the speaker 170A, or listen to hands-free calls.
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。Receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or a voice message, the voice can be heard by bringing the receiver 170B close to the human ear.
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak close to the microphone 170C with the human mouth and input the sound signal to the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which in addition to collecting sound signals, may also implement a noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions, etc.
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如,当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于闹钟应用图标时,执行新建闹钟的指令。The pressure sensor 180A is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, pressure sensor 180A may be disposed on display screen 194 . There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor may include at least two parallel plates of conductive material. When a force is applied to pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation is performed on the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 may also calculate the touched position based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch location but with different touch operation intensities may correspond to different operation instructions. For example, when a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the alarm clock application icon, an instruction to create an alarm clock is executed.
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。例如,当手机在锁屏界面检测到用户的触控操作时,手机可以通过指纹传感器180H采集用户的指纹信息,并通过采集的指纹信息与手机中预置的指纹信息进行匹配。若匹配成功,则手机可以从锁屏界面进入非锁屏界面。Fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access to application locks, fingerprint photography, fingerprint answering of incoming calls, etc. For example, when the mobile phone detects the user's touch operation on the lock screen interface, the mobile phone can collect the user's fingerprint information through the fingerprint sensor 180H, and match the collected fingerprint information with the fingerprint information preset in the mobile phone. If the match is successful, the phone can enter the non-lock screen interface from the lock screen interface.
触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。Touch sensor 180K, also called "touch panel". The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen". The touch sensor 180K is used to detect a touch operation on or near the touch sensor 180K. The touch sensor can pass the detected touch operation to the application processor to determine the touch event type. Visual output related to the touch operation may be provided through display screen 194 . In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100 at a location different from that of the display screen 194 .
在介绍本申请实施例的技术方案之前,先介绍本申请实施例中一些相关概念。Before introducing the technical solutions of the embodiments of the present application, some related concepts in the embodiments of the present application are first introduced.
任务:对于用户而言,任务可以是应用程序。对于应用程序开发者或者对于电子设备而言,任务可以是一个或多个用户在该任务中已经经历过且没有关闭的活动,或者可以是一个活动栈。Task: For a user, a task can be an application. For application developers or for electronic devices, a task can be one or more activities that the user has experienced in the task without closing it, or it can be a stack of activities.
冷/热对象:随着程序的运行,电子设备可以连续不断访问对象。在一个时间窗口内,热对象是在该时间窗口内访问到的对象,冷对象是在该时间窗口内程序没有访问到的对象。Cold/Hot Objects: Electronic devices have continuous access to objects as the program runs. Within a time window, hot objects are objects that are accessed within the time window, and cold objects are objects that are not accessed by the program within the time window.
应理解,对于不同的时间和地点、不同的使用场景,同一电子设备可以有不同的冷对象和热对象。It should be understood that the same electronic device may have different cold objects and hot objects for different times, locations, and different usage scenarios.
此外,在另一些实施例中,冷对象还可以指在一个时间窗口内,访问次数小于预设阈值的对象;热对象可以指在一个时间窗口内,访问次数等于或者大于预设阈值的对象。该预设阈值可以是一次、两次或者三次等,对此不作限定。In addition, in other embodiments, cold objects may also refer to objects whose access times are less than the preset threshold within a time window; hot objects may refer to objects whose access times are equal to or greater than the preset threshold within a time window. The preset threshold can be once, twice, or three times, etc., and is not limited to this.
安卓运行时(Android runtime,ART):是高级编程语言运行的宿主环境。安卓程序可以使用Java和Kotlin编程语言开发,而ART是这些高级语言的运行环境。在ART环境中,手机的应用程序(Application,APP)在第一次安装时,字节码会预先编译成机器码,使应用程序成为本地应用。ART可以用来管理手机应用程序的运行。Android runtime (ART): It is a host environment for high-level programming languages to run. Android programs can be developed using Java and Kotlin programming languages, and ART is the running environment for these high-level languages. In the ART environment, when a mobile phone application (Application, APP) is installed for the first time, the bytecode will be pre-compiled into machine code, making the application a local application. ART can be used to manage the running of mobile applications.
垃圾回收(garbage collection,GC):是安卓手机程序使用的一种动态内存管理方法。安卓系统可以在系统预留的堆内存不够时触发GC操作。一旦完成GC操作,可以将一些不再使用的对象进行回收。Garbage collection (GC): It is a dynamic memory management method used by Android mobile programs. The Android system can trigger GC operations when the heap memory reserved by the system is insufficient. Once the GC operation is completed, some objects that are no longer used can be recycled.
并行复制(concurrent copying):安卓手机使用的垃圾回收方法之一。当应用程序的堆内存快要满的时候,系统会从根集合引用开始,扫描所有可达的对象,并将所有可达的存活对象拷贝到内存中的空闲空间。在一些程序语言中,可以通过可达性分析判断对象是否存活。系统从根集合作为起始点扫描对象,当对象为不可达的对象时,该对象不可用;当对象为可达对象时,该对象可用。Concurrent copying: One of the garbage collection methods used by Android phones. When the application's heap memory is almost full, the system will start from the root collection reference, scan all reachable objects, and copy all reachable surviving objects to the free space in the memory. In some programming languages, reachability analysis can be used to determine whether an object is alive. The system scans objects from the root collection as the starting point. When the object is unreachable, the object is unavailable; when the object is reachable, the object is available.
活动(Activity):安卓系统的重要组件之一,可以作为用户界面的载体。活动属于应用层开发的四大组件之一,主要负责和用户交互部分。活动具有自己的生命周期,其上可以布置按钮,文本框等各种空间。在一些实施例中,该活动可以指安卓的用户界面(userinterface,UI)部分。Activity: One of the important components of the Android system, it can be used as the carrier of the user interface. Activities are one of the four major components of application layer development and are mainly responsible for interacting with users. An activity has its own life cycle, and various spaces such as buttons and text boxes can be arranged on it. In some embodiments, the activity may refer to the user interface (UI) portion of Android.
Root Set:进行动态内存垃圾回收时扫描工作的起点。Root Set: The starting point for scanning work when performing dynamic memory garbage collection.
Remember Set:为了减少GC的范围,系统会预设一些对象为默认存活的对象,并且将这些对象的引用保存在Remember Set中。系统可以通过Remember Set确定哪些对象引用了当前区域的对象。Remember Set: In order to reduce the scope of GC, the system will preset some objects as default surviving objects and save references to these objects in the Remember Set. The system can determine which objects refer to objects in the current area through Remember Set.
读取对象代码/写入对象代码:程序在读/写对象时,额外插入的运行代码。Read object code/write object code: additional running code inserted when the program reads/writes objects.
交换(swap)空间:交换空间可以在系统的物理内存不够用时,将硬盘内存中的一部分空间释放。并且把其中的数据保存在闪存或者压缩内存中,以供当前运行的程序使用。被释放的空间可能来自一段时间没有操作的程序。被释放的空间可以被临时保存在交换空间中。当上述程序需要运行时,可以从交换空间中移出到内存中。Swap space: Swap space can release part of the hard disk memory when the system's physical memory is not enough. And save the data in flash memory or compressed memory for use by the currently running program. The space being freed may come from a program that has been inactive for a period of time. The freed space can be temporarily saved in the swap space. When the above program needs to run, it can be moved out of the swap space and into memory.
区域空间(region space):安卓系统一般通过区域空间管理对象,而区域空间通常会被切分为固定大小(例如,256KB)的区域(region)。Region space: Android systems generally manage objects through region space, and region space is usually divided into regions of fixed size (for example, 256KB).
应理解,安卓系统在每次分配对象时,通常会先选取一个区域,并通过选取的区域进一步分配对象;而GC拷贝一般也是从一个区域拷贝到另外一个区域的过程。It should be understood that every time the Android system allocates an object, it usually selects an area first and further allocates objects through the selected area; GC copying is generally a process of copying from one area to another area.
图2示出了当前ART使用传统的并行复制垃圾回收过程示意图。如图2中的(a)所示,A、B、C、D、E、F、G分别表示内存对象。可理解为,内存中的对象A、C、D、G是当前进程经常使用的对象,例如在当前进程下可以作为热对象;磁盘中的对象B、E、F是当前进程不经常使用的对象,例如在当前进程下可以作为冷对象。示例性地,在一次GC过程中,系统判断对象G是否需要回收。寻找对象G的地址为A→E→F→G(应理解,对象G的引用信息为A→E→F→G),但寻找对象的过程只能在内存中进行。因此,在寻找对象G之前需要将对象E和对象F重新读回内存中,如图2中的(b)所示。Figure 2 shows a schematic diagram of the traditional parallel copy garbage collection process currently used by ART. As shown in (a) in Figure 2, A, B, C, D, E, F, and G respectively represent memory objects. It can be understood that objects A, C, D, and G in the memory are objects that are frequently used by the current process. For example, they can be used as hot objects in the current process; objects B, E, and F in the disk are objects that are not frequently used by the current process. , for example, it can be used as a cold object under the current process. For example, during a GC process, the system determines whether object G needs to be recycled. The address of finding object G is A→E→F→G (it should be understood that the reference information of object G is A→E→F→G), but the process of finding the object can only be performed in memory. Therefore, objects E and F need to be read back into memory before searching for object G, as shown in (b) in Figure 2.
应理解,内存中能存储的对象一般是有限的。例如,该内存中只能存储3个对象。当对象E和对象F重新读回内存中后,系统将对象C和对象D移入磁盘中。当通过上述地址寻找到对象G后,表示对象G是不需要回收的(另一种情况,当通过上述地址不能寻找到对象G,则表示对象G需要回收)。而对于当前进程,对象C和对象D仍为经常用的对象。因此,对象C和对象D需要重新读回内存中,如图2中的(c)所示。It should be understood that the objects that can be stored in memory are generally limited. For example, only 3 objects can be stored in this memory. When object E and object F are read back into memory, the system moves object C and object D to disk. When the object G is found through the above address, it means that the object G does not need to be recycled (on the other hand, when the object G cannot be found through the above address, it means that the object G needs to be recycled). For the current process, object C and object D are still frequently used objects. Therefore, object C and object D need to be read back into memory again, as shown in (c) in Figure 2.
由此可见,传统的垃圾回收过程会从根集合开始,将内存堆中所有的存活对象进行扫描,并且将存活对象拷贝到空闲的目标空间。但是这种垃圾回收过程会与内存交换机制相互冲突。It can be seen that the traditional garbage collection process starts from the root collection, scans all surviving objects in the memory heap, and copies the surviving objects to the free target space. But this garbage collection process will conflict with the memory swap mechanism.
在内存压力大时,数据可能在内存与交换空间之间频繁地换入换出。这样会导致系统产生不必要的开销,影响运行性能;且系统难以高效利用交换空间来减小内存占用,从而导致应用程序内存占用很大;同时,手机系统为了保证用户操作的低延迟,常常会主动杀死一些进程,当用户重新打开被杀死的应用程序时,延迟较高。When memory pressure is high, data may be swapped in and out frequently between memory and swap space. This will cause the system to generate unnecessary overhead and affect operating performance; and it is difficult for the system to efficiently use swap space to reduce memory usage, resulting in applications taking up a large amount of memory. At the same time, in order to ensure low latency for user operations, mobile phone systems often Actively kill some processes, resulting in higher latency when the user reopens the killed application.
本申请实施例提供了一种控制内存的方法。示例性地,从应用层面上看,简单的应用程序一般对应一个进程,较为复杂的应用程序可对应多个进程。以简单的应用程序为例,一个进程可理解为系统为该应用程序分配的一个独立的内存,与其他进程互相不关联,不能互相访问。一个进程内的内存对象之间是可以互相访问的。本申请实施例提供的方法适用于某一个进程内的GC过程。The embodiment of this application provides a method for controlling memory. For example, from the application level, a simple application program generally corresponds to one process, and a more complex application program may correspond to multiple processes. Taking a simple application as an example, a process can be understood as an independent memory allocated by the system to the application. It is not related to other processes and cannot access each other. Memory objects within a process can access each other. The method provided by the embodiment of this application is suitable for the GC process within a certain process.
该控制内存的方法同时考虑了安卓系统运行时的GC过程和操作系统的交换机制,并且将这两者进行协同。该方法可以充分利用交换空间,节省不必要的开销,在保证程序运行性能的情况下减少应用的内存占用,尽量避免暂时不用的应用程序被杀死的情况,降低重新打开应用程序的延迟。This method of controlling memory takes into account both the GC process when the Android system is running and the exchange mechanism of the operating system, and coordinates the two. This method can make full use of swap space, save unnecessary overhead, reduce the memory footprint of applications while ensuring program running performance, try to avoid killing temporarily unused applications, and reduce the delay in reopening applications.
在本申请实施例的技术方案中,可以通过不同方式在安卓系统的ART和内核内存管理代码流程中作出改进,节省交换机制中不必要的开销,以及减少内存的占用。In the technical solutions of the embodiments of this application, improvements can be made in the ART and kernel memory management code processes of the Android system in different ways to save unnecessary overhead in the switching mechanism and reduce memory usage.
如图3所示,图3示出了本申请实施例的一种控制内存的方法所包含的模块示意图。虚线框内分别表示第一模块、第二模块和第三模块所包含的内容,该包含关系为虚拟的,仅为示例性说明,本申请对此不作限定。As shown in FIG. 3 , FIG. 3 shows a schematic diagram of modules included in a method for controlling memory according to an embodiment of the present application. The contents contained in the first module, the second module and the third module are respectively represented in the dotted boxes. This inclusion relationship is virtual and is only an exemplary explanation, and this application does not limit it.
第一模块可以通过读取对象代码或写入对象代码获取应用程序的访问情况。利用现有的GC拷贝阶段,将应用程序的冷对象拷贝到冷空间中内存页中;将其他对象保留在原本的堆内存中,从而将冷对象和热对象分离;并且将冷对象聚集在冷页中。其中,冷页可以包括聚集一个、两个或多个冷对象的内存页。第一模块可以用于区分冷对象和热对象,并将冷对象聚集在冷页中。The first module can obtain the access status of the application program by reading the object code or writing the object code. Utilize the existing GC copy phase to copy the cold objects of the application to the memory pages in the cold space; keep other objects in the original heap memory, thereby separating cold objects and hot objects; and gather cold objects in the cold space. page. Among them, cold pages can include memory pages that aggregate one, two or more cold objects. The first module can be used to distinguish cold objects from hot objects and aggregate cold objects into cold pages.
一些实施例中,读取对象代码可以指读屏障(read barrier)。写入对象代码可以指写屏障(write barrier)。In some embodiments, reading object code may refer to a read barrier. Writing object code may be referred to as a write barrier.
为了节省内存,第二模块将冷页中的冷对象换出到交换空间中;将换出对象(冷页中的冷对象)的引用保存在第一集合(例如:Remember Set)中。应理解,第二模块采用动态换出的方式将冷对象换出到交换空间。具体的动态换出和换入的方式将在下文中具体描述。第二模块用于将聚集在冷页中的冷对象换出到交换空间中,有助于对任意大小对象的管理。In order to save memory, the second module swaps out the cold objects in the cold page to the swap space; saves the reference of the swapped out object (cold object in the cold page) in the first set (for example: Remember Set). It should be understood that the second module uses dynamic swapping to swap out the cold objects to the swap space. The specific dynamic swap-out and swap-in methods will be described in detail below. The second module is used to swap out cold objects accumulated in cold pages to the swap space, which helps manage objects of any size.
第三模块可以利用第二模块生成的Remember Set中的引用信息,在ART的GC过程中对程序剩余在内存中的对象引用进行扫描。应理解,对于不需要重新换入的对象的数据,第三模块可以不执行从交换空间换入到内存的操作,能够避免没必要的数据在内存和交换空间之间频繁地换入和换出。The third module can use the reference information in the Remember Set generated by the second module to scan the object references remaining in the memory of the program during the GC process of ART. It should be understood that for the data of objects that do not need to be re-swapped in, the third module may not perform the operation of swapping in from the swap space to the memory, which can avoid unnecessary data being frequently swapped in and out between the memory and the swap space. .
为了更好理解本申请实施例中的技术方案,下面对每个模块执行的任务进行具体描述。In order to better understand the technical solutions in the embodiments of this application, the tasks performed by each module are described in detail below.
如图4所示,图4示出了第一模块的结构示意图。图4中每个较大的框表示内存页,较小的框表示对象,各个对象之间的箭头表示对象之间可能存在的引用关系,GC拷贝前和拷贝后的第一个内存页中的对象为所有的存活对象(包括冷对象和热对象)。第一模块可以用于识别并分离冷对象和热对象。首先,第一模块可以使用read barrier或write barrier记录程序对不同对象的访问,将所有的存活对象分为冷对象和热对象;其次,第一模块可以创建冷空间,该冷空间用于保存冷对象。应理解,本申请实施例可以对目标空间进行区分。其中,冷空间可以是另外创建的内存空间,也可以是区域空间中的一块区域,本申请实施例对此不作限定;再次,第一模块可以利用现有的GC拷贝阶段,区分冷对象和热对象,并将冷对象移动到冷空间中的内存页(冷页)中;最后,第一模块可以将多个冷对象聚集在相同的内存页中(例如,图4中GC拷贝后中间的内存页),便于后续的换出操作。应理解,本申请对象访问模式估计方法可以同时使用read barrier和write barrier进行估计,也可以使用固定周期采样的方法,本申请实施例对此不作限定。As shown in Figure 4, Figure 4 shows a schematic structural diagram of the first module. In Figure 4, each larger box represents a memory page, and the smaller box represents an object. The arrows between each object represent possible reference relationships between objects. The first memory page before and after GC copy The objects are all living objects (including cold objects and hot objects). The first module can be used to identify and separate cold and hot objects. First, the first module can use read barrier or write barrier to record the program's access to different objects and divide all surviving objects into cold objects and hot objects; secondly, the first module can create a cold space, which is used to store cold objects. object. It should be understood that the embodiments of the present application can differentiate target spaces. Among them, the cold space can be a separately created memory space, or it can be an area in the regional space. The embodiments of the present application are not limited to this; again, the first module can use the existing GC copy stage to distinguish cold objects and hot objects. objects and move the cold objects to memory pages (cold pages) in the cold space; finally, the first module can gather multiple cold objects in the same memory page (for example, the middle memory after GC copy in Figure 4 page) to facilitate subsequent swap-out operations. It should be understood that the object access mode estimation method of this application can use read barrier and write barrier at the same time for estimation, or it can also use a fixed period sampling method, which is not limited in the embodiment of this application.
如图5所示,图5示出了第二模块的结构示意图。第二模块用于将聚集在内存中的冷对象进行动态换入和换出。As shown in Figure 5, Figure 5 shows a schematic structural diagram of the second module. The second module is used to dynamically swap in and out the cold objects accumulated in the memory.
应理解,在安卓系统的前台应用的工作模式中,可以动态进行换入和换出。可以使用基于活动的方法进行任务估计;也可以将服务(service)考虑进来,也可以使用基于线程的方法,本申请对此不作限定。示例性地,下面以使用基于活动的方法为例,对任务估计过程进行描述。It should be understood that in the working mode of the foreground application of the Android system, swapping in and out can be performed dynamically. An activity-based method can be used for task estimation; services can also be taken into consideration, or a thread-based method can be used, which is not limited in this application. Illustratively, the task estimation process is described below using the activity-based method as an example.
一个任务一般以活动的方式进行。不同的活动之间的跳转模式是相对固定的,下一个任务可以通过下一个可能运行的活动所决定,因此活动的跳转不是任意的。下一次的活动依赖程序的定义和堆栈(stack)的顶部元素,用户可根据下一跳的可能情况进行提前换入和换出。A task is generally carried out in the form of activities. The jump pattern between different activities is relatively fixed. The next task can be determined by the next activity that may be run, so the jump of activities is not arbitrary. The next activity depends on the definition of the program and the top element of the stack. The user can swap in and out in advance according to the possible situation of the next hop.
一些实施例中,工作集预测的方法可以分为两个层级,分别是活动层级和对象层级。活动层级用于预测用户有可能访问的应用程序中的页面和特定功能。对象层级用于估计用户具体可能需要访问到的Java对象。In some embodiments, the working set prediction method can be divided into two levels, namely the activity level and the object level. Activity levels are used to predict which pages and specific features within an application a user is likely to visit. The object hierarchy is used to estimate the specific Java objects that users may need to access.
一些实施例中,在活动层级,系统可以根据两个数据的信息估计下一跳的活动。第一个数据信息可以是活动栈中的顺序信息。系统对每个应用程序可以使用一个活动栈来管理活动。应用程序在初始化时,活动栈初始化为空。随着应用程序的运行和用户的触控操作,不同活动之间可以跳转,系统可以将每次用户访问到的活动对象压入到活动栈中,活动栈的栈顶的活动对象可以对应于用户当前所看到的界面。当用户单击返回控件时,系统将当前活动栈栈顶的活动对象出栈,此时,新的栈顶的活动对象是用户跳转的新的界面。因此,系统可以根据当前活动栈中的信息,估计用户点击返回控件后访问的活动。例如,图5中活动栈的栈顶是活动B,估计用户下一次访问的活动很可能是活动D。In some embodiments, at the activity level, the system can estimate the activity of the next hop based on information from two data. The first data message can be the sequence message in the active stack. The system can use an activity stack for each application to manage activities. When the application is initialized, the activity stack is initially empty. As the application runs and the user performs touch operations, different activities can jump. The system can push the activity object that the user accesses each time into the activity stack. The activity object at the top of the activity stack can correspond to The interface currently seen by the user. When the user clicks the return control, the system pops the active object at the top of the current active stack. At this time, the active object at the top of the new stack is the new interface to which the user jumps. Therefore, the system can estimate the activities that the user will access after clicking the return control based on the information in the current activity stack. For example, in Figure 5, the top of the activity stack is activity B. It is estimated that the activity the user visits next is probably activity D.
第二个数据信息可以是根据历史活动跳转信息构建的有向图。系统根据访问活动的先后时间顺序,将活动访问的历史信息保存;并且,还可以附加是否使用返回控件进行返回的动作。系统根据保存的历史活动访问信息,可以获取每个活动可能跳转的其他活动,根据活动之间的跳转信息建立一个有向图。如图5所示,该有向图表示历史信息为:活动A,活动C,活动D,活动C,(返回)活动A,(返回)活动B,活动A,(返回)活动D。如果当前界面为活动C,下一跳转可能为活动D。The second data information can be a directed graph constructed based on historical activity jump information. The system saves the historical information of activity access according to the time sequence of access activities; and can also add an action of whether to use the return control to return. Based on the saved historical activity access information, the system can obtain other activities that each activity may jump to, and build a directed graph based on the jump information between activities. As shown in Figure 5, the directed graph represents the historical information as: activity A, activity C, activity D, activity C, (return) activity A, (return) activity B, activity A, (return) activity D. If the current interface is activity C, the next jump may be activity D.
在对象层级,系统根据历史对象访问信息估计每个活动关联的工作集。每个活动都有一个工作集,工作集包含用户访问该界面时可能访问到的对象集合。访问到一个对象时,系统通过插入read barrier或write barrier,将访问的对象加入到当前活动相关联的工作集中。At the object level, the system estimates the working set associated with each activity based on historical object access information. Each activity has a working set, which contains the collection of objects that a user may access when accessing the interface. When an object is accessed, the system adds the accessed object to the working set associated with the current activity by inserting a read barrier or a write barrier.
因此,通过上述两个层级的方法,系统首先预测下一跳转可能访问的活动;然后根据该活动关联的对象,预测下一跳转需要访问的对象集合。第三模块可以根据预测的工作集预测下一跳转需要访问的对象,从而实现对这些对象的提前换入;并预测下一跳转不需要访问的对象,在内存压力到来之前提前换出。其中,每个活动对应的冷对象与热对象都可能不同。在每个活动进行换入换出之前,需要第一模块将该活动下的冷对象和热对象进行区分。Therefore, through the above two-level method, the system first predicts the activities that may be accessed by the next jump; and then predicts the set of objects that need to be accessed by the next jump based on the objects associated with the activity. The third module can predict the objects that need to be accessed by the next jump based on the predicted working set, so as to swap in these objects in advance; and predict the objects that do not need to be accessed by the next jump, and swap them out in advance before the memory pressure arrives. Among them, the cold objects and hot objects corresponding to each activity may be different. Before each activity is swapped in and out, the first module is required to distinguish between cold objects and hot objects under the activity.
如图6所示,图6示出了第三模块的结构示意图。第三模块用于避免不必要的数据交换。第二模块将冷页中聚集的冷对象换出到交换空间的同时,将冷空间中对象的引用记录在第一集合中。应理解,第一集合在内存中。首先,第一集合记载了换出对象的地址;其次,在GC过程的开始阶段或者从Root Set开始,将第一集合的引用加入根集合,从而能够保证找出全部存活对象;最后,在GC过程的进行阶段,当回收器(collector)访问到了冷空间中的对象的引用的时候,则跳过该对象的访问。应理解,该冷空间中的对象在垃圾回收过程之后仍属于冷对象,第三模块保证不把数据从交换空间重新换入内存,能够有效利用交换空间,避免内存占用过大。当回收器没有访问到冷空间中对象的引用的时候,则会按照正常的GC流程进行,将需要重新换入的对象从交换空间换入到内存中。As shown in Figure 6, Figure 6 shows a schematic structural diagram of the third module. The third module is used to avoid unnecessary data exchange. The second module swaps out the cold objects gathered in the cold page to the swap space and records the references of the objects in the cold space in the first collection. It should be understood that the first set is in memory. First of all, the first set records the address of the swapped out object; secondly, at the beginning of the GC process or starting from the Root Set, the reference of the first set is added to the root set, thereby ensuring that all surviving objects are found; finally, in the GC During the process, when the collector accesses a reference to an object in the cold space, the access to the object is skipped. It should be understood that the objects in the cold space are still cold objects after the garbage collection process. The third module ensures that data is not re-swapped from the swap space into the memory, which can effectively utilize the swap space and avoid excessive memory usage. When the collector does not access the reference of the object in the cold space, it will follow the normal GC process and swap the object that needs to be re-swapped from the swap space into the memory.
示例性地,冷空间的范围为[begin,end),回收器判断第一引用信息是否在该冷空间的范围内。当第一引用信息在该冷空间的范围内时,保留与该第一引用信息对应的第一对象。基于此,回收器不再访问该第一对象,该第一对象在垃圾回收过程后仍是冷对象。进入下一轮循环过程,回收器判断下一个对象(例如:第二对象)的第二引用信息是否在该冷空间范围内。当第二引用信息不在该冷空间的范围内时,该第二对象在垃圾回收过程之后不再属于冷对象,GC进行正常的后续执行流程,进一步找到第二引用信息对应的第二对象,对该第二对象进行扫描,并将第二对象换入内存中。For example, the range of the cold space is [begin, end), and the collector determines whether the first reference information is within the range of the cold space. When the first reference information is within the scope of the cold space, the first object corresponding to the first reference information is retained. Based on this, the collector no longer accesses the first object, which remains a cold object after the garbage collection process. Entering the next cycle, the collector determines whether the second reference information of the next object (for example, the second object) is within the cold space range. When the second reference information is not within the scope of the cold space, the second object no longer belongs to the cold object after the garbage collection process. The GC performs the normal subsequent execution process and further finds the second object corresponding to the second reference information. The second object is scanned and the second object is swapped into memory.
图7示出了本申请实施例的控制内存方法700的示例性流程图,如图7所示,该控制内存方法主要包括估计访问对象阶段、将冷对象和热对象分离阶段、动态换入换出阶段和动态更新阶段。以当前任务即将结束,马上开启下一任务为例,具体内容如下:Figure 7 shows an exemplary flow chart of the memory control method 700 according to the embodiment of the present application. As shown in Figure 7, the memory control method mainly includes the stage of estimating access objects, the stage of separating cold objects and hot objects, and the stage of dynamic swap-in and swap-in. exit stage and dynamic update stage. Take for example that the current task is about to end and the next task will be started immediately. The specific content is as follows:
S710,估计访问对象。S710, estimate access objects.
在程序运行过程中,可通过read barrier或write barrier、对堆内存中对象的访问情况进行估计,将所有存活对象区分为冷对象和热对象。During the running of the program, the access status of objects in the heap memory can be estimated through read barrier or write barrier, and all surviving objects can be divided into cold objects and hot objects.
S720,利用GC拷贝阶段,将冷对象和热对象进行分离。S720, use the GC copy stage to separate cold objects and hot objects.
应理解,创建冷空间,将冷对象保存在冷空间中的内存页中,避免将所有存活对象保存在空闲的目标空间。It should be understood that cold space is created, cold objects are saved in memory pages in the cold space, and all surviving objects are avoided in free target space.
S730,根据前台任务以及基于该前台任务可能执行的下一步任务,将对象进行动态地提前换入和换出。S730: dynamically swap objects in and out in advance according to the foreground task and the next task that may be executed based on the foreground task.
示例性地,用户根据可能执行的下一步任务,将保存在冷空间的内存页中的换出对象提前换出到交换空间。并且在换出时,使用一个Remember Set记录该换出对象向其他对象的全部引用,能够提前释放内存占用。随后,在GC过程中,系统将Remember Set的全部引用加入根集合,在GC遍历时不再访问已经换出的对象。应理解,系统不会将已经换出的对象重新换入到内存中,尽量避免了不必要的数据换入到内存中,避免不必要的额外开销,更加高效地利用交换空间来减少内存占用。For example, the user swaps out the swapped objects stored in the memory pages of the cold space to the swap space in advance based on the next task that may be performed. And when swapping out, use a Remember Set to record all references of the swapped out object to other objects, which can release the memory occupation in advance. Subsequently, during the GC process, the system adds all references to the Remember Set to the root collection, and no longer accesses the objects that have been swapped out during GC traversal. It should be understood that the system will not swap out objects that have been swapped out again into the memory, try to avoid unnecessary data being swapped into the memory, avoid unnecessary additional overhead, and use the swap space more efficiently to reduce memory usage.
S740,根据前台任务和下一步任务对区分的冷对象和热对象进行动态更新。S740: Dynamically update the distinguished cold objects and hot objects according to the foreground task and the next task.
基于上述步骤,用户可以动态换入和换出。Based on the above steps, users can dynamically swap in and out.
为了便于理解,图8示出了上述控制内存方法700的过程性示意图。如图8所示,对象A、B、C、D、E、F、G、H、I均表示内存对象;虚线框内表示根节点集合;实线框内的对象A、C、D、G可以表示冷对象或热对象。For ease of understanding, FIG. 8 shows a schematic process diagram of the above method 700 for controlling memory. As shown in Figure 8, objects A, B, C, D, E, F, G, H, and I all represent memory objects; the dotted line box represents the root node set; the objects A, C, D, and G in the solid line box Can represent cold or hot objects.
应理解,首先,系统将所有存活对象区分,当实线框内的对象为冷对象时,实现框外的其他对象为热对象;当实线框内的对象为热对象时,实线框外的其他对象为冷对象。其次,系统将冷对象和热对象分离,系统可以将所有的冷对象聚集在冷页中。再次,系统将聚集在冷页中的冷对象换出到交换空间中,同时将冷对象的引用信息保存在第一集合中。最后,系统可以根据前台任务和下一步任务,对冷对象和热对象动态更新。It should be understood that first, the system distinguishes all living objects. When the objects inside the solid line box are cold objects, other objects outside the solid line box are hot objects; when the objects inside the solid line box are hot objects, the objects outside the solid line box are hot objects. The other objects are cold objects. Secondly, the system separates cold objects and hot objects, and the system can gather all cold objects in cold pages. Again, the system swaps out the cold objects gathered in the cold page to the swap space, and at the same time saves the reference information of the cold objects in the first collection. Finally, the system can dynamically update cold objects and hot objects based on foreground tasks and next tasks.
图9示出了本申请实施例提供的控制内存的方法900的示意性流程图。如图9所示,该方法900可以由电子设备执行,其中电子设备可以是手机、平板电脑、智慧屏或智能手表等。该方法900包括:Figure 9 shows a schematic flowchart of a memory control method 900 provided by an embodiment of the present application. As shown in Figure 9, the method 900 can be executed by an electronic device, where the electronic device can be a mobile phone, a tablet computer, a smart screen or a smart watch, etc. The method 900 includes:
S910,电子设备将第一任务的对象区分为第一冷对象和第二热对象。S910: The electronic device distinguishes the objects of the first task into first cold objects and second hot objects.
应理解,第一冷对象和第一热对象为第一任务的存活对象;其中,对象之间具有引用关系。第一冷对象为该第一任务的时间窗口内没有访问到的对象,第一热对象为该第一任务的时间窗口内访问到的对象。本申请实施例利用在系统中本身就存在的GC拷贝操作对存活对象进行冷热区分,无需引入额外的内存复制操作。It should be understood that the first cold object and the first hot object are surviving objects of the first task; there is a reference relationship between the objects. The first cold object is an object that has not been accessed within the time window of the first task, and the first hot object is an object that has been accessed within the time window of the first task. The embodiment of the present application uses the GC copy operation that already exists in the system to distinguish between hot and cold objects, without introducing additional memory copy operations.
一些实施例中,电子设备将该第一冷对象保存至第一目标空间,该第一目标空间为第一冷空间。In some embodiments, the electronic device saves the first cold object to a first target space, and the first target space is a first cold space.
一些实施例中,当第一冷对象包括多个第一冷对象时,电子设备将多个第一冷对象保存至第一目标空间中的第一内存页中,第一内存页为第一冷页。应理解,多个第一冷对象聚集在第一目标空间的第一内存页中,有利于提高后续步骤中将第一冷对象从内存中移入到交换空间。In some embodiments, when the first cold object includes multiple first cold objects, the electronic device saves the multiple first cold objects to the first memory page in the first target space, and the first memory page is the first cold object. Page. It should be understood that a plurality of first cold objects are gathered in the first memory page of the first target space, which is beneficial to improving the ability to move the first cold objects from the memory to the swap space in subsequent steps.
一些实施例中,在电子设备将第一冷对象保存至第一目标空间之前,电子设备确定第一冷对象的访问情况,也就是说,电子设备确定第一冷对象的所有存活对象(包括第一冷对象和第一热对象)。示例性地,电子设备根据read barrier或write barrier确定第一任务对象的访问情况,或根据固定周期采样的方法确定第一任务的访问情况,本申请实施例对此不作限定。In some embodiments, before the electronic device saves the first cold object to the first target space, the electronic device determines the access status of the first cold object. That is, the electronic device determines all surviving objects of the first cold object (including the first cold object). one cold object and one hot object). For example, the electronic device determines the access status of the first task object based on a read barrier or a write barrier, or determines the access status of the first task based on a fixed period sampling method. This is not limited in the embodiments of the present application.
S920,将所述第一冷对象从内存移入到交换空间。S920: Move the first cold object from the memory to the swap space.
应理解,将该第一冷对象从内存移入到交换空间可用于减少内存占用,其中,将对象从内存移入到交换空间这个动作可称为“换出”。It should be understood that moving the first cold object from the memory to the swap space can be used to reduce memory usage, where the action of moving the object from the memory to the swap space can be called "swapping out".
一些实施例中,在该第一任务内,电子设备将第二任务的对象区分为第二冷对象和第二热对象,其中,对象之间具有引用关系;第二冷对象可以为所该第二任务的时间窗口内没有访问到的对象;第二热对象可以为该第二任务的时间窗口内访问到的对象,第二任务为第一任务的下一个任务,将第二冷对象从内存移入到交换空间,保存第二冷对象的引用信息,该第二冷对象的引用信息包括该第二冷对象的引用关系;根据第二冷对象的引用信息,移出或者保存该第二冷对象。In some embodiments, within the first task, the electronic device distinguishes the objects of the second task into a second cold object and a second hot object, where there is a reference relationship between the objects; the second cold object may be the third There is no object accessed within the time window of the second task; the second hot object can be an object accessed within the time window of the second task. The second task is the next task of the first task. The second cold object is removed from the memory. Move it into the swap space and save the reference information of the second cold object. The reference information of the second cold object includes the reference relationship of the second cold object; move out or save the second cold object according to the reference information of the second cold object.
应理解,第二任务与第一任务相同,当多次访问相同的任务时,电子设备在第一任务内预测第二任务的工作集,并根据第二任务的工作集预测第二任务的对象的访问情况,其中第二任务的对象可以包括第二冷对象和第二热对象。It should be understood that the second task is the same as the first task. When the same task is accessed multiple times, the electronic device predicts the working set of the second task within the first task and predicts the object of the second task based on the working set of the second task. The access situation, wherein the objects of the second task may include a second cold object and a second hot object.
一些实施例中,任务估计可以使用基于活动的方法,也可以将服务考虑进来,也可以使用基于线程的方法,本申请实施例对此不作限定。In some embodiments, task estimation may use an activity-based method, services may also be taken into consideration, or a thread-based method may be used, which is not limited in the embodiments of the present application.
一些实施例中,电子设备将第二冷对象保存至第二目标空间,第二目标空间为第二冷空间。In some embodiments, the electronic device saves the second cold object to the second target space, and the second target space is the second cold space.
一些实施例中,当第二冷对象包括多个第二冷对象时,电子设备将第二冷对象保存至第二目标空间的第二内存页中,第二内存页为第二冷页。应理解,多个第二冷对象聚集在第二目标空间的第二内存页中,有利于提高后续步骤中将第二冷对象从内存中移入到交换空间的效率,从而减少内存占用。In some embodiments, when the second cold object includes multiple second cold objects, the electronic device saves the second cold object to the second memory page of the second target space, and the second memory page is the second cold page. It should be understood that a plurality of second cold objects are gathered in the second memory page of the second target space, which is beneficial to improving the efficiency of moving the second cold objects from the memory to the swap space in subsequent steps, thereby reducing memory usage.
S930,保存所述第一冷对象的引用信息。S930: Save the reference information of the first cold object.
应理解,将第一冷对象从内存移入到交换空间时,保存第一冷对象的引用信息,该第一对象的引用信息包括第一对象的引用关系。It should be understood that when the first cold object is moved from the memory to the swap space, the reference information of the first cold object is saved, and the reference information of the first object includes the reference relationship of the first object.
S940,根据所述第一冷对象的引用信息,移出或者保存所述第一冷对象。S940: Remove or save the first cold object according to the reference information of the first cold object.
需要说明的是,当根据第一冷对象的引用信息确定第一冷对象为第二冷对象时,将第一冷对象保存在交换空间里。也就是说,当第一冷对象的引用信息在冷空间的范围内时,表示该第一冷对象在一次垃圾回收后仍然为冷对象,不再扫描该第一对象,将该第一冷对象继续保留在交换空间里。当根据第一冷对象的引用信息确定第一冷对象为第二热对象时,将第一冷对象从交换空间移入到内存。也就是说,当第一冷对象的引用信息不在冷空间的范围内时,表示该第一冷对象在一次垃圾回收后成为了热对象,需要重新换入到内存中。本申请提供的实施例在现有GC扫描对象之前先对需要扫描的对象进行判断,如果该对象仍属于冷对象时,不必对该对象进行扫描。因此,上述方法能够提高换入换出的效率,减少不必要的开销。It should be noted that when the first cold object is determined to be the second cold object based on the reference information of the first cold object, the first cold object is stored in the swap space. That is to say, when the reference information of the first cold object is within the scope of the cold space, it means that the first cold object is still a cold object after a garbage collection, and the first cold object is no longer scanned, and the first cold object is Continue to remain in the swap space. When it is determined that the first cold object is the second hot object according to the reference information of the first cold object, the first cold object is moved from the swap space to the memory. That is to say, when the reference information of the first cold object is not within the scope of the cold space, it means that the first cold object has become a hot object after a garbage collection and needs to be swapped into the memory again. The embodiment provided by this application determines the object that needs to be scanned before the existing GC scans the object. If the object is still a cold object, it is not necessary to scan the object. Therefore, the above method can improve the efficiency of swapping in and out and reduce unnecessary overhead.
示例性地,系统将第一对象的引用信息保存在第一集合中,第一集合为RememberSet,第一集合在内存页中,第二集合为根集合,包括上述第一集合。电子设备通过扫描根集合可获知第一集合中的引用信息。通过上述对象提前的换入换出操作,有助于更加充分利用内存页的交换带宽。For example, the system saves the reference information of the first object in a first set, the first set is a RememberSet, the first set is in a memory page, and the second set is a root set, including the above-mentioned first set. The electronic device can obtain the reference information in the first set by scanning the root set. Through the advance swap-in and swap-out operations of the above objects, it helps to make full use of the swap bandwidth of the memory page.
一些实施例中,第一目标空间和第二目标空间为新建的内存空间,或者,第一目标空间和第二目标空间属于区域空间中的空间,无需新建内存空间,本申请实施例对此不作限定。In some embodiments, the first target space and the second target space are newly created memory spaces, or the first target space and the second target space belong to the space in the regional space, and there is no need to create a new memory space. The embodiments of this application do not do this. limited.
以上各个实施例可以单独使用,也可以相互结合使用,以实现不同的技术效果。Each of the above embodiments can be used alone or in combination with each other to achieve different technical effects.
上述本申请提供的实施例中,从电子设备作为执行主体的角度对本申请实施例提供的方法进行了介绍。为了实现上述本申请实施例提供的方法中的各功能,电子设备可以包括硬件结构和/或软件模块,以硬件结构、软件模块、或硬件结构加软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。In the above-mentioned embodiments provided by the present application, the method provided by the embodiments of the present application is introduced from the perspective of the electronic device as the execution subject. In order to implement each function in the method provided by the above embodiments of the present application, the electronic device may include a hardware structure and/or a software module to implement the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above functions is performed as a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraints of the technical solution.
本申请实施例还提供了一种电子设备,包括:显示屏、处理器、存储器、电源键、应用程序以及计算机程序。上述各器件可以通过一个或多个通信总线连接。其中,该一个或多个计算机程序被存储在上述存储器中并被配置为被该一个或多个处理器执行,该一个或多个计算机程序包括指令,上述指令可以用于使电子设备执行上述各实施例中收发红包方法的各个步骤。An embodiment of the present application also provides an electronic device, including: a display screen, a processor, a memory, a power button, an application program, and a computer program. Each of the above devices can be connected through one or more communication buses. Wherein, the one or more computer programs are stored in the above-mentioned memory and configured to be executed by the one or more processors. The one or more computer programs include instructions, and the above-mentioned instructions can be used to cause the electronic device to execute each of the above-mentioned tasks. Each step of the method of sending and receiving red envelopes in the embodiment.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.
本实施例可以根据上述方法示例对电子设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。This embodiment can divide the electronic device into functional modules according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. In actual implementation, there may be other division methods.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be described again here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, each unit can exist physically alone, or two or more units can be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program code. .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application. should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims (20)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210271760.0A CN116820734A (en) | 2022-03-18 | 2022-03-18 | A method and electronic device for controlling memory |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210271760.0A CN116820734A (en) | 2022-03-18 | 2022-03-18 | A method and electronic device for controlling memory |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116820734A true CN116820734A (en) | 2023-09-29 |
Family
ID=88122671
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210271760.0A Pending CN116820734A (en) | 2022-03-18 | 2022-03-18 | A method and electronic device for controlling memory |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116820734A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119248463A (en) * | 2024-02-07 | 2025-01-03 | 荣耀终端有限公司 | Garbage recycling method, electronic device and storage medium |
CN119271390A (en) * | 2024-02-07 | 2025-01-07 | 荣耀终端有限公司 | Garbage recycling method, electronic equipment and storage medium |
CN119576806A (en) * | 2025-02-08 | 2025-03-07 | 荣耀终端股份有限公司 | Memory management method, electronic device, storage medium and program product |
-
2022
- 2022-03-18 CN CN202210271760.0A patent/CN116820734A/en active Pending
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119248463A (en) * | 2024-02-07 | 2025-01-03 | 荣耀终端有限公司 | Garbage recycling method, electronic device and storage medium |
CN119271390A (en) * | 2024-02-07 | 2025-01-07 | 荣耀终端有限公司 | Garbage recycling method, electronic equipment and storage medium |
CN119576806A (en) * | 2025-02-08 | 2025-03-07 | 荣耀终端股份有限公司 | Memory management method, electronic device, storage medium and program product |
CN119576806B (en) * | 2025-02-08 | 2025-07-04 | 荣耀终端股份有限公司 | Memory management method, electronic device, storage medium and program product |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN116244067B (en) | Virtual memory management method and electronic equipment | |
CN116820734A (en) | A method and electronic device for controlling memory | |
CN114168065B (en) | Method and device for adjusting memory configuration parameters | |
WO2021185352A1 (en) | Version upgrade method and related apparatus | |
CN113885973B (en) | Translation result display method and device and electronic equipment | |
CN114880251B (en) | Storage unit access method, access device and terminal equipment | |
CN114461588A (en) | Method and electronic device for adjusting pre-reading window | |
CN114461589B (en) | Method for reading compressed file, file system and electronic equipment | |
CN113568634A (en) | Application-optimized processing method and processing device | |
WO2021238387A1 (en) | Application execution method and apparatus | |
CN114968543A (en) | Method for processing document page and related device | |
WO2024027544A1 (en) | Memory management method and electronic device | |
CN112765383A (en) | File cleaning method and electronic equipment | |
WO2023273543A1 (en) | Folder management method and apparatus | |
WO2025026077A1 (en) | Method and apparatus for starting application program, and electronic device | |
CN116048772B (en) | Central processing unit frequency adjustment method, device and terminal equipment | |
CN114489469B (en) | A data reading method, electronic device and storage medium | |
WO2023051094A1 (en) | Memory recovery method and apparatus, electronic device, and readable storage medium | |
CN113157599B (en) | Flash memory exchange partition control method and mobile device | |
CN116860429A (en) | Memory management method and electronic equipment | |
CN114968248A (en) | Code optimization method, electronic device and storage medium | |
CN116095512B (en) | Photographing method of terminal equipment and related device | |
CN118474522B (en) | Photographing method, terminal equipment, chip and storage medium | |
CN119254883B (en) | Ambient light reporting method, terminal device and storage medium | |
WO2025026076A1 (en) | Method and apparatus for call switching, and electronic device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |