WO2017206302A1 - 一种应用程序的运行方法和运行装置 - Google Patents

一种应用程序的运行方法和运行装置 Download PDF

Info

Publication number
WO2017206302A1
WO2017206302A1 PCT/CN2016/091943 CN2016091943W WO2017206302A1 WO 2017206302 A1 WO2017206302 A1 WO 2017206302A1 CN 2016091943 W CN2016091943 W CN 2016091943W WO 2017206302 A1 WO2017206302 A1 WO 2017206302A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
running
environment
code
virtual
Prior art date
Application number
PCT/CN2016/091943
Other languages
English (en)
French (fr)
Inventor
贾鑫
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2017206302A1 publication Critical patent/WO2017206302A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances

Definitions

  • This article refers to, but is not limited to, the field of software, and relates to an operating method and operating device of an application.
  • the operating systems of mobile terminals mainly include Android and iOS.
  • Android is based on Java language
  • iOS is based on Obejctive-C.
  • Java code actually needs two "conversions" in order to finally run in a user-visible program, once before the developer releases the installation package, using the developer's own machine's CPU ( Central Processing Unit (Central Processing Unit), another time using the phone's CPU before the user starts the app.
  • the Objective-C-based code only needs this "conversion" once, before the developer releases the installation package, so it only takes up the CPU time of the developer machine.
  • the bottleneck of Java application startup speed is that the Java application is interpreted and executed, and needs to be compiled again during this run. This has led to the acceleration of the Java application startup process. Therefore, how to improve the startup speed of an application becomes one of the problems to be solved in the related art.
  • the running of the application is based on the virtual running environment.
  • ART's processing mechanism is completely different. It converts the program code into machine language when the application is installed, making the program a real local application. The advantage of this is that the startup time of the program is increased and the speed is faster. The way ART handles application execution is completely different from Dalvik.
  • JIT Just-In-Time
  • AOT Ahead-Of-Time
  • the first drawback is the time required to increase the installation of the application.
  • the larger the amount of code the longer it takes to precompile the bytecode into the machine language.
  • This increase in duration is relatively large, especially in games.
  • the app because of the large amount of code in their own.
  • the second drawback is that the installed files take up more space and have a growth of nearly 20%. For example, a 100M game, the code has 50M, and the installation space required for 20% increase is 10M. User experience is not good. Since ART requires an application to convert program code into machine language at install time, this consumes more storage space.
  • the embodiment of the invention provides an operating method and an operating device of an application program, which solves the problem that the speed of the application is increased during the running process and the conflict of the memory is excessive.
  • An embodiment of the present invention provides a method for running an application, including:
  • the environment selection model is based on a usage frequency threshold and/or a currently available memory setting of the application.
  • the method further includes: after loading the running code corresponding to the virtual running environment of the application to the memory execution, updating a running record for recording historical usage data of the application.
  • the method further includes: before the historical usage data of the application to be run is read, installing according to any one of the virtual running environments when the application is installed.
  • the virtual running environment includes a Dalvik environment and an ART environment, the Dalvik
  • the running code corresponding to the environment and the ART environment are the application code and the local machine code respectively;
  • the method further includes: after loading the running code corresponding to the virtual running environment of the application to the memory execution, if the loaded running code is an application code, and the local machine of the application is recorded in the memory The code deletes the local machine code.
  • An embodiment of the present invention further provides an operating device for an application, including
  • a data reading unit configured to read historical usage data of an application to be run
  • An environment matching unit configured to match the historical usage data with a preset environment selection model to confirm and start a virtual running environment corresponding to the application;
  • the code loading unit is configured to load the running code corresponding to the virtual running environment of the application to the memory execution.
  • the environment selection model is based on a usage frequency threshold and/or a currently available memory setting of the application.
  • the running device further includes:
  • a data update unit configured to update a run record for recording historical usage data of the application.
  • the running device further includes:
  • the program installation unit is configured to be installed corresponding to any one of the virtual running environments when the application is installed.
  • the virtual running environment includes a Dalvik environment and an ART environment
  • the running codes corresponding to the Dalvik environment and the ART environment are application code and local machine code, respectively;
  • the operating device further includes:
  • the code deletion unit is configured to delete the local machine code if the loaded running code is an application code and the local machine code of the application is recorded in the memory.
  • the embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores computer executable instructions, and when the computer executable instructions are executed, the method for running the application is implemented.
  • the operating method and running device of the application program of the embodiment of the present invention by reading the pending operation Using the historical usage data of the program, selecting a virtual running environment suitable for the application requirements of the application according to the historical usage data, loading the corresponding running code into the memory execution in the selected virtual running environment, and realizing the running of the application Optimized balance of speed or memory savings makes the application's operational choices more reasonable.
  • Other aspects will be apparent upon reading and understanding the drawings and detailed description.
  • FIG. 1 is a flowchart of a method for running an application according to Embodiment 1 of the present invention
  • FIG. 3 is a structural block diagram of an apparatus for running an application according to Embodiment 2 of the present invention.
  • FIG. 4 is a block diagram showing another structure of an apparatus for running an application according to Embodiment 2 of the present invention.
  • FIG. 1 is a flowchart of a method for running an application according to an embodiment of the present invention.
  • the method for running the application includes:
  • Step S11 reading historical usage data of the application to be run
  • Each use of the application will generate corresponding usage data, and the comprehensive statistics of the multiple usage data form historical usage data, forming a reference to the manner in which the application is launched.
  • the running process of the application is recorded in a special database, that is, a running record, which records the name of each application and the number of starts corresponding to each application.
  • the running frequency of the application is obtained according to the number of startups of each application in the stored preset time, for example, how many times a day or how many times a week, and the average running time in the cycle can be further counted.
  • Step S12 Match the historical usage data with the preset environment selection model to confirm and start the virtual running environment corresponding to the application;
  • the environment selection model can be based on the application's usage frequency threshold and/or current available memory settings. If the application is used frequently, then the application is in use. Priority should be given to which application can get faster in which virtual operating environment, because high frequency usage is relatively faster in terms of speed; if the application is used less frequently, then the application During the use of the program, priority should be given to which application has a lower running memory requirement in which virtual operating environment.
  • the ART environment may be selected when the application frequency is higher than the usage frequency threshold set in the environment selection model.
  • the Dalvik environment can be used when the application frequency is lower than or equal to the usage frequency threshold set in the environment selection model.
  • the preset usage frequency threshold is 10 times per week. After obtaining the running frequency of each application in a week, it is judged whether each application runs at a frequency of more than 10 times, if each application runs at a frequency of More than 10 times, the application is determined to be running using ART. If each application does not run more than 10 times, then the application is determined to be running Dalvik.
  • the values listed are only a clear description of the way to determine the method of operation. In actual use, the user can set it according to the actual needs.
  • the specific operation mode can also be calculated by historical usage data and current available memory quantity analysis. If the currently available memory is less than or slightly exceeds the memory requirements of the application running in a virtual runtime environment, then the application cannot choose to run in that virtual runtime environment. Also for the Dalvik environment and the ART environment, when the amount of available memory is large, it means that there is more available memory for storing the local machine code to run in the ART environment, which means that there are more applications that can use ART. By running the method, you can set the preset usage frequency threshold to a lower value, and more applications will adopt the ART running method. Conversely, when the available memory is small, the terminal does not have enough. The available memory is used to store the local machine code, which means that more applications need to use Dalvik's running method, you can set the preset frequency threshold to a higher value, and more applications will use Dalvik. How to run.
  • Step S13 Load the running code corresponding to the virtual running environment of the application to the memory execution.
  • the identification information may include a program name and a software package name of the application, and loading the application corresponding to the virtual running environment by using the identification information Run the code into memory. If it is an ART environment, the local machine code of the application is loaded; if it is a Dalvik environment, the application is loaded. Ordered application code.
  • the local machine code When the local machine code needs to be loaded, find the local machine code corresponding to the code segment of the application, and confirm whether the code segment of the application has a local machine code. If the code segment of the application has a local machine code, when the application starts, It can be executed on the ART virtual running platform; otherwise, when the local machine code corresponding to the code segment is not found, that is, the code segment of the application is confirmed to have no local machine code, the compiler module is notified, and the application code segment is locally The machine code forms a local machine code, and at the same time, the local machine code and the corresponding code segment correspondence are saved in the memory.
  • the content is a pointer to the local machine code obtained by compiling the currently executed application code. According to the pointer, the local machine code corresponding to the code currently to be executed can be obtained.
  • FIG. 2 is another flowchart of a method for running an application according to an embodiment of the present invention.
  • the method for running the application includes:
  • Step S21 installing the application corresponding to any virtual running environment
  • the default installation method can be set or manually selected by the user. Statistics of historical usage data are made after the application is installed. For example, if an application is used frequently, you can consider installing it in the ART environment to directly generate the local machine code.
  • Step S22 reading historical usage data of the application to be run
  • Historical usage data in addition to statistical usage frequency, can also count the duration of the application, will The usage duration is also used as a selection reference for the virtual running environment. The corresponding usage time can also be recorded in the running record.
  • Step S23 Match the historical usage data with the preset environment selection model to confirm and start the virtual running environment corresponding to the application;
  • Step S24 Load the running code corresponding to the virtual running environment of the application to the memory execution.
  • the virtual running environment includes a Dalvik environment and an ART environment, and the running codes corresponding to the Dalvik environment and the ART environment are application code and local machine code, respectively.
  • Step S25 updating a running record for recording historical usage data of the application
  • new usage data is generated.
  • the operation record for recording the history usage data of the application is updated, that is, the usage frequency, the usage duration, and the like corresponding to the application are updated.
  • Step S26 If the loaded running code is the application code, and the local machine code of the application is recorded in the memory, the local machine code is deleted.
  • the code corresponding to the application or the local machine code can be saved in a table and stored in memory.
  • the keyword of the table is the application identification number
  • the content of the table is the storage location of the local machine code obtained after the code of the application performs the local machine code.
  • the save information of the local machine code or the like is added to the local machine code record table shown in Table 1.
  • N times is used after installation.
  • N conversions are required for N starts; however, according to the ART method, regardless of the program used. On a few occasions, only one "conversion" occurred. Therefore, the method of selecting ART will reduce the frequency of CPU usage, thereby reducing the use of power.
  • the running method of the application in this solution can select different running modes according to the actual use of the application, obtain the balance between the use speed and the occupied memory, and realize the optimized combination of respective advantages.
  • the following is an operation device for an application program according to an embodiment of the present invention.
  • the embodiment of the operation device of the application program is implemented based on the foregoing embodiment of the operation method.
  • the embodiment of the operation device please refer to the foregoing.
  • FIG. 3 is a structural block diagram of an apparatus for running an application program according to an embodiment of the present invention.
  • the running device of the application program includes:
  • the data reading unit 10 is configured to read historical usage data of the application to be run;
  • the environment matching unit 20 is configured to match the historical usage data with the preset environment selection model to confirm and start the virtual running environment corresponding to the application;
  • the code loading unit 30 is configured to load the running code corresponding to the virtual running environment of the application to the memory execution.
  • each of the above units cooperates to read the historical usage data of the application to be run, and according to the historical usage data, select a virtual running environment that is compatible with the application requirements of the application, in the selected virtual
  • the corresponding running code is loaded into the memory execution in the running environment, which realizes the optimization balance of speed improvement or memory saving during the running of the application, and the operation selection of the application is more reasonable.
  • FIG. 4 is another structural block diagram of an apparatus for running an application according to an embodiment of the present invention.
  • the running apparatus of the application includes:
  • the data reading unit 10 is configured to read historical usage data of the application to be run;
  • the environment matching unit 20 is configured to match the historical usage data with the preset environment selection model to confirm and start the virtual running environment corresponding to the application;
  • the code loading unit 30 is configured to load the running code corresponding to the virtual running environment of the application to the memory execution.
  • the environment selection model is based on at least one of an application frequency threshold and a currently available memory.
  • the running device of the application further includes:
  • the data update unit 40 is arranged to update a log of the history usage data for recording the application.
  • the running device of the application further includes:
  • Program installation unit 00 set to correspond to any one of the virtual operations when the application is installed The line environment is installed.
  • the virtual running environment includes a Dalvik environment and an ART environment
  • the running codes corresponding to the Dalvik environment and the ART environment are respectively an application code and a local machine code
  • the running device of the application further includes:
  • the code deleting unit 50 is configured to delete the local machine code if the loaded running code is the application code and the local machine code of the application is recorded in the memory.
  • each of the above units cooperates to read the historical usage data of the application to be run, selects a virtual running environment that is compatible with the usage requirements of the application according to the historical usage data, and selects the virtual running environment.
  • the corresponding running code is loaded into the memory to execute in the environment, which realizes the optimization balance of speed improvement or memory saving during the running of the application, and the operation selection of the application is more reasonable. Selecting how the application works during installation can make the application run more efficiently; deleting the local machine code can further save memory space.
  • the embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores computer executable instructions, and when the computer executable instructions are executed, the method for running the application is implemented.
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and can also be implemented by hardware, but in many cases, the former is A better implementation.
  • the technical solution of the present application which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.
  • the above technical solution realizes an optimized balance of speed improvement or memory saving during the running of the application, and makes the operation selection of the application more reasonable.

Landscapes

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

Abstract

一种应用程序的运行方法和运行装置。该运行方法包括:读取待运行的应用程序的历史使用数据;将所述历史使用数据与预设的环境选择模型进行匹配,以确认并启动所述应用程序对应的虚拟运行环境;加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行。上述技术方案通过读取待运行的应用程序的历史使用数据,根据历史使用数据选择与该应用程序的使用需求相适应的虚拟运行环境,在选定的虚拟运行环境下加载对应的运行代码到内存执行,实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,使应用程序的运行选择更加合理。

Description

一种应用程序的运行方法和运行装置 技术领域
本文涉及但不限于软件领域,涉及一种应用程序的运行方法和运行装置。
背景技术
随着电子技术的不断发展,移动终端的使用也越来越广发。当前移动终端的操作系统主要有Android和iOS,其中,Android是基于Java语言的,iOS是基于Obejctive-C。表现在手机和应用程序运行机制上,Java的代码实际上需要两次“转换”才能最终以用户可看的程序跑起来,一次发生在开发者发布安装包前,使用开发者自己机器的CPU(Central Processing Unit,中央处理器),另一次在用户启动APP前,使用手机的CPU。而基于Objective-C的代码只需要一次这种“转换”,在开发者发布安装包前,所以只占用开发者机器的CPU时间。Java应用程序启动速度的瓶颈在于Java应用程序是解释执行的,需要在本次运行过程中再次编译。这就导致了Java应用程序启动流程需要加速。因此,如何提高应用程序的启动速度成为相关技术中亟待解决的问题之一。
应用程序的运行基于虚拟运行环境实现,在不同的虚拟运行环境中程序运行有不同的优缺点。以Dalvik和ART(Android Runtime)为例,在以前的Android系统上,所有的应用程序都是运行在Dalvik中。在Dalvik中,应用程序每次运行时其中一部分代码都要需要机器重新编译。这个过程消耗时间和系统资源,所以执行效率低。相比Dalvik,ART的处理机制完全不同,它会在应用程序安装时就把程序代码转换成机器语言,让程序成为真正的本地应用。这样做的好处是程序的启动时间被提高,运行速度也会更快。ART处理应用程序执行的方式完全不同于Dalvik,Dalvik是依靠一个Just-In-Time(JIT)编译器去解释字节码,开发者编译后的应用代码需要通过一个解释器在用户的设备上运行,这一机制并不高效。ART则完全改变了这套做法,在应用程序安装时就预编译字节码到机器语言,这一机制叫Ahead-Of-Time(AOT)编译。在移除解释代码这一过程后,应用程序执行将更有效率,启动更快。
但是ART会带来其他的负面影响。
第一个缺点是增加应用程序安装所需的时间,尤其是代码量越大,预编译字节码到机器语言所花的时间就越长,这个时长的增加比较大,尤其是以游戏为主的应用程序,因为他们本身代码量大。
第二个缺点是会使安装后的文件占用更多的空间,有接近20%的增长。比如一个100M的游戏,代码有50M,增加20%的安装所需空间多了10M。用户体验不好。由于ART需要应用程序在安装时就把程序代码转换成机器语言,所以这会消耗掉更多的存储空间。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
本发明实施例提供一种应用程序的运行方法和运行装置,解决了应用程序在运行过程中速度提升和内存节约的冲突过大的问题。
本发明实施例提供一种应用程序的运行方法,包括:
读取待运行的应用程序的历史使用数据;
将所述历史使用数据与预设的环境选择模型进行匹配,以确认并启动所述应用程序对应的虚拟运行环境;
加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行。
可选地,所述环境选择模型基于所述应用程序的使用频率阈值和/或当前可用内存设置。
可选地,所述方法还包括:所述加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行之后,更新用于记录所述应用程序的历史使用数据的运行记录。
可选地,所述方法还包括:所述读取待运行的应用程序的历史使用数据之前,在安装所述应用程序时对应于任意一个虚拟运行环境进行安装。
可选地,所述虚拟运行环境包括Dalvik环境和ART环境,所述Dalvik 环境和ART环境对应的运行代码分别为应用程序代码和本地机器码;
所述方法还包括:所述加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行之后,若加载的运行代码为应用程序代码,且存储器中记录有所述应用程序的本地机器码,则删除所述本地机器码。
本发明实施例还提供一种应用程序的运行装置,包括
数据读取单元,设置为读取待运行的应用程序的历史使用数据;
环境匹配单元,设置为将所述历史使用数据与预设的环境选择模型进行匹配,以确认并启动所述应用程序对应的虚拟运行环境;
代码加载单元,设置为加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行。
可选地,所述环境选择模型基于所述应用程序的使用频率阈值和/或当前可用内存设置。
可选地,所述运行装置还包括:
数据更新单元,设置为更新用于记录所述应用程序的历史使用数据的运行记录。
可选地,所述运行装置还包括:
程序安装单元,设置为在安装所述应用程序时对应于任意一个虚拟运行环境进行安装。
可选地,所述虚拟运行环境包括Dalvik环境和ART环境,所述Dalvik环境和ART环境对应的运行代码分别为应用程序代码和本地机器码;
所述运行装置,还包括:
代码删除单元,设置为若加载的运行代码为应用程序代码,且存储器中记录有所述应用程序的本地机器码,则删除所述本地机器码。
本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机可执行指令,所述计算机可执行指令被执行时实现应用程序的运行方法。
本发明实施例的应用程序的运行方法和运行装置,通过读取待运行的应 用程序的历史使用数据,根据历史使用数据选择与该应用程序的使用需求相适应的虚拟运行环境,在选定的虚拟运行环境下加载对应的运行代码到内存执行,实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,使应用程序的运行选择更加合理。在阅读并理解了附图和详细描述后,可以明白其它方面。
附图说明
图1为本发明实施例一提供的一种应用程序的运行方法的流程图;
图2为本发明实施例一提供的一种应用程序的运行方法的另一流程图;
图3为本发明实施例二提供的一种应用程序的运行装置的结构方框图;
图4为本发明实施例二提供的一种应用程序的运行装置的另一结构方框图。
具体实施方式
以下结合附图和实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
请参考图1,是本发明实施例提供的一种应用程序的运行方法的流程图,如图1所示,该应用程序的运行方法包括:
步骤S11:读取待运行的应用程序的历史使用数据;
应用程序的每次使用都会产生对应的使用数据,多个使用数据的综合统计形成历史使用数据,形成对应用程序启动的方式的参考。应用程序的运行过程记录在专门的数据库,即运行记录,该运行记录记录各应用程序名称,及每个应用程序对应的启动次数。根据存储的预设时间内每一应用程序的启动次数获得该应用程序的运行频率,例如一天多少次或一周多少次,进一步还可以统计该周期内的平均运行时长。
步骤S12:将历史使用数据与预设的环境选择模型进行匹配,以确认并启动应用程序对应的虚拟运行环境;
环境选择模型可以是基于应用程序的使用频率阈值和/或当前可用内存设置的。如果应用程序的使用频率很高,那么说明该应用程序的使用过程中 应优先考虑该应用程序在哪个虚拟运行环境中能获得更快的运行速度,因为高频率的使用相对而言在速度方面具有更高的要求;如果应用程序的使用频率很低,那么说明该应用程序的使用过程中应优先考虑该应用程序在哪个虚拟运行环境中有更低的运行内存需求。
由此,基于使用频率阈值设置的环境选择模型中,如果虚拟运行环境包括Dalvik环境和ART环境,那么在应用程序的使用频率高于环境选择模型中设定的使用频率阈值时,可以选用ART环境;在应用程序的使用频率低于或等于环境选择模型中设定的使用频率阈值时,可以选用Dalvik环境。例如预设的使用频率阈值为每周运行10次,在获取一周内每个应用程序的运行频率后,判断每一应用程序的运行频率是否均超过10次,如果每一应用程序的运行频率均超过10次,则将该应用程序确定为采用ART的运行方法。如果每一应用程序的运行频率不是均超过10次,则将该应用程序确定为采用Dalvik的运行方法。所列举的数值仅为了清晰的说明确定运行方法的方式,在实际使用过程中用户可以根据实际的使用需要自行设置。
具体的运行方式,还可以由历史使用数据和当前可用内存数量分析计算得出。如果当前可使用内存小于或者略超出应用程序在一虚拟运行环境中运行的内存需求,那么该应用程序不能选择在该虚拟运行环境下运行。同样对于Dalvik环境和ART环境,当可用内存数量较大时,说明此时可以有较多的可用内存用于存储本地机器码以在ART环境中运行,代表有更多的应用程序可以采用ART的运行方法,就可以将预设的使用频率阈值设定一个比较低的数值,就会有更多的应用程序采用ART的运行方法;反之,当可用内存数量较小时,说明此时终端没有足够的可用内存用于存储本地机器码,则代表需要更多的应用程序采用Dalvik的运行方法,就可以将预设的频率阈值设定一个比较高的数值,就会有更多的应用程序采用Dalvik的运行方法。
步骤S13:加载应用程序与虚拟运行环境对应的运行代码到内存执行。
当确认应用程序的虚拟运行环境后,获取要运行的应用程序的标识信息,该标识信息可以包括该应用程序的程序名称和软件包名称,通过该标识信息加载应用程序对应于该虚拟运行环境的运行代码到内存中。如果是ART环境,则加载的是应用程序的本地机器码;如果是Dalvik环境,则加载的是应用程 序的应用程序代码。
接下来对本地机器码和应用程序代码的加载过程进行详细描述。
当需要加载本地机器码时,查找该应用程序的代码段对应的本地机器码,确认应用程序的代码段是否有本地机器码,如果应用程序的代码段有本地机器码,则当应用程序启动后就可以在ART虚拟运行平台执行;否则,在未查找到该代码段对应的本地机器码时,即确认应用程序的代码段没有本地机器码,则通知编译器模块,对应用程序代码段进行本地机器码形成本地机器码,同时,将本地机器码和对应的代码段对应关系保存在存储器中。以当前要执行的应用程序的代码作为关键字,查找存储区中该应用程序对应的本地机器码,该内容就是指向存放该当前要执行的应用程序代码进行编译后得到的本地机器码的指针,根据该指针,便可以获取当前要执行的代码对应的本地机器码。
如果需要加载应用程序代码,则在应用程序创建并启动之后,就会通过它里面的Dalvik虚拟机加载应用程序的代码文件到内存进行执行,在这里是class.odex文件,获取到将要运行的Activity的代码,应用程序就启动起来了。
综上所述,通过读取待运行的应用程序的历史使用数据,根据历史使用数据选择与该应用程序的使用需求相适应的虚拟运行环境,在选定的虚拟运行环境下加载对应的运行代码到内存执行,实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,应用程序的运行选择更加合理。
请参考图2,是本发明实施例提供的一种应用程序的运行方法的另一流程图,如图2所示,该应用程序的运行方法包括:
步骤S21:在安装应用程序时对应于任意一个虚拟运行环境进行安装;
可以设定默认的安装方式或者由用户手动选择。当应用程序安装之后则进行历史使用数据的统计。例如一应用程序会经常使用,则可以考虑选择在ART环境下进行安装,以直接生成本地机器码。
步骤S22:读取待运行的应用程序的历史使用数据;
历史使用数据除了统计使用频率,还可以统计应用程序的使用时长,将 使用时长也作为虚拟运行环境的选择参考,运行记录中对应还可以记录平均使用时长。
步骤S23:将历史使用数据与预设的环境选择模型进行匹配,以确认并启动应用程序对应的虚拟运行环境;
除了使用频率和可用内存的大小,还可参考使用时长,如果一应用程序虽然使用频率较低,但是平均每次使用的时长较长,也可选择运行速度较快的虚拟运行环境。
步骤S24:加载应用程序与虚拟运行环境对应的运行代码到内存执行。
虚拟运行环境包括Dalvik环境和ART环境,所述Dalvik环境和ART环境对应的运行代码分别为应用程序代码和本地机器码。
应用程序代码或本地机器码写入内存后,执行应用程序代码或者本地机器码,即可运行该应用程序。应用程序代码和本地机器码的运行机制在此不做赘述。
步骤S25:更新用于记录应用程序的历史使用数据的运行记录;
待运行的应用程序开始运行后,产生新的使用数据,此时更新用于记录应用程序的历史使用数据的运行记录,即将该应用程序对应的使用频率,使用时长等进行更新。
步骤S26:若加载的运行代码为应用程序代码,且存储器中记录有应用程序的本地机器码,则删除本地机器码。
应用程序对应的代码或本地机器码的保存格式可以为表格,存放位置为存储器。如表1所示,该表格的关键字是应用程序标识号,该表格的内容是该应用程序的代码进行本地机器码后得到的本地机器码的存放位置。在前序步骤中,在生成本地机器码之后,将本地机器码的保存信息等添加到表1所示的本地机器码记录表中。
序号 应用程序标识号 本地机器码
1 22 本地机器码存放的位置
2 11 本地机器码存放的位置
3 333 本地机器码存放的位置
表1
在应用程序满足采用Dalvik的方法时,进一步查找该应用程序代码对应的本地机器码,确认应用程序的代码段是否有本地机器码,如果应用程序的代码段有本地机器码,则将本地机器码进行删除,节省出内存空间。同时将本地机器码保存记录表中对应的记录删除。
整体而言,对于使用频率较高的应用程序,安装后使用了N次的情况,按原先Dalvik的方法,N次启动就需要进行N次“转换”;但是按照ART的方法,不管这个程序使用几次,都只发生一次“转换”。从而选择ART的方法会降低CPU的使用频率,进而降低电量的使用。
对于使用频率较低的应用程序,安装后使用了1次的情况,按照ART的方法,只发生一次“转换”。选择ART的方法会降低CPU的使用频率,但是由于该程序使用次数很少,所以节省效果不明显。按Dalvik的方法,1次启动需要进行1次“转换”。但是节省了内存,安装后的文件比ART的方法减少20%占用空间,所以这会节省更多的存储空间。
本方案中的应用程序的运行方法,能够根据应用程序的实际使用情况选择不同的运行方式,获得使用速度与占用内存的平衡,实现了各自优势的优化组合。
综上所述,通过读取待运行的应用程序的历史使用数据,根据历史使用数据选择与该应用程序的使用需求相适应的虚拟运行环境,在选定的虚拟运行环境下加载对应的运行代码到内存执行,实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,应用程序的运行选择更加合理。在安装时选定应用程序的运行方式,能够让应用程序的运行更加高效;而删除本地机器码的操作能够进一步有效节约内存空间。
实施例二
以下为本发明实施例提供的一种应用程序的运行装置,该应用程序的运行装置的实施例基于前述的运行方法的实施例实现,在运行装置的实施例中未尽的描述,请参考前述的应用程序的运行方法的实施例。
请参考图3,是本发明实施例提供的一种应用程序的运行装置的结构方框图,如图3所示,该应用程序的运行装置包括:
数据读取单元10,设置为读取待运行的应用程序的历史使用数据;
环境匹配单元20,设置为将历史使用数据与预设的环境选择模型进行匹配,以确认并启动应用程序对应的虚拟运行环境;
代码加载单元30,设置为加载应用程序与虚拟运行环境对应的运行代码到内存执行。
综上所述,上述每个单元协同工作,通过读取待运行的应用程序的历史使用数据,根据历史使用数据,选择与该应用程序的使用需求相适应的虚拟运行环境,在选定的虚拟运行环境下加载对应的运行代码到内存执行,实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,应用程序的运行选择更加合理。
请参考图4,是本发明实施例提供的一种应用程序的运行装置的另一结构方框图,如图4所示,该应用程序的运行装置包括:
数据读取单元10,设置为读取待运行的应用程序的历史使用数据;
环境匹配单元20,设置为将历史使用数据与预设的环境选择模型进行匹配,以确认并启动应用程序对应的虚拟运行环境;
代码加载单元30,设置为加载应用程序与虚拟运行环境对应的运行代码到内存执行。
其中,环境选择模型基于应用程序的使用频率阈值、当前可用内存中的至少一个设置。
可选地,所述应用程序的运行装置还包括:
数据更新单元40,设置为更新用于记录应用程序的历史使用数据的运行记录。
可选地,所述应用程序的运行装置还包括:
程序安装单元00,设置为在安装应用程序时对应于其中任意一个虚拟运 行环境进行安装。
可选地,虚拟运行环境包括Dalvik环境和ART环境,Dalvik环境和ART环境对应的运行代码分别为应用程序代码和本地机器码;
所述应用程序的运行装置还包括:
代码删除单元50,设置为若加载的运行代码为应用程序代码,且存储器中记录有应用程序的本地机器码,则删除本地机器码。
综上所述,上述每个单元协同工作,通过读取待运行的应用程序的历史使用数据,根据历史使用数据选择与该应用程序的使用需求相适应的虚拟运行环境,在选定的虚拟运行环境下加载对应的运行代码到内存执行,实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,应用程序的运行选择更加合理。在安装时选定应用程序的运行方式,能够让应用程序的运行更加高效;而删除本地机器码的操作能够进一步有效节约内存空间。
本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机可执行指令,所述计算机可执行指令被执行时实现应用程序的运行方法。
需要说明的是,上述装置实施例与方法实施例属于同一构思,其具体实现过程详见方法实施例,且方法实施例中的技术特征在装置实施例中均对应适用,这里不再赘述。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件来实现,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上参照附图说明了本申请的可选实施例,并非因此局限本申请的权利范围。本领域技术人员不脱离本申请的范围和实质,可以有多种变型方案实现本申请,比如作为一个实施例的特征可用于另一实施例而得到又一实施例。 凡在运用本申请的技术构思之内所作的任何修改、等同替换和改进,均应在本申请的权利范围之内。
工业实用性
上述技术方案实现了应用程序运行过程中对速度提升或对内存节约的优化平衡,使应用程序的运行选择更加合理。

Claims (10)

  1. 一种应用程序的运行方法,包括
    读取待运行的应用程序的历史使用数据;
    将所述历史使用数据与预设的环境选择模型进行匹配,以确认并启动所述应用程序对应的虚拟运行环境;
    加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行。
  2. 根据权利要求1所述的运行方法,其中:所述环境选择模型基于所述应用程序的使用频率阈值和/或当前可用内存设置。
  3. 根据权利要求1所述的运行方法,所述方法还包括:所述加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行之后,更新用于记录所述应用程序的历史使用数据的运行记录。
  4. 根据权利要求1所述的运行方法,所述方法还包括:所述读取待运行的应用程序的历史使用数据之前,在安装所述应用程序时对应于任意一个虚拟运行环境进行安装。
  5. 根据权利要求1所述的运行方法,其中:所述虚拟运行环境包括Dalvik环境和ART环境,所述Dalvik环境和ART环境对应的运行代码分别为应用程序代码和本地机器码;
    所述方法还包括:所述加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行之后,若加载的运行代码为应用程序代码,且存储器中记录有所述应用程序的本地机器码,则删除所述本地机器码。
  6. 一种应用程序的运行装置,包括
    数据读取单元,设置为读取待运行的应用程序的历史使用数据;
    环境匹配单元,设置为将所述历史使用数据与预设的环境选择模型进行匹配,以确认并启动所述应用程序对应的虚拟运行环境;
    代码加载单元,设置为加载所述应用程序与所述虚拟运行环境对应的运行代码到内存执行。
  7. 根据权利要求6所述的运行装置,其中:所述环境选择模型基于所述 应用程序的使用频率阈值和/或当前可用内存设置。
  8. 根据权利要求6所述的运行装置,所述运行装置还包括:
    数据更新单元,设置为更新用于记录所述应用程序的历史使用数据的运行记录。
  9. 根据权利要求6所述的运行装置,所述运行装置还包括:
    程序安装单元,设置为在安装所述应用程序时对应于任意一个虚拟运行环境进行安装。
  10. 根据权利要求6所述的运行装置,其中:所述虚拟运行环境包括Dalvik环境和ART环境,所述Dalvik环境和ART环境对应的运行代码分别为应用程序代码和本地机器码;
    所述运行装置,还包括:
    代码删除单元,设置为若加载的运行代码为应用程序代码,且存储器中记录有所述应用程序的本地机器码,则删除所述本地机器码。
PCT/CN2016/091943 2016-05-31 2016-07-27 一种应用程序的运行方法和运行装置 WO2017206302A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610374841.8A CN107450937B (zh) 2016-05-31 2016-05-31 一种应用程序的运行方法和运行装置
CN201610374841.8 2016-05-31

Publications (1)

Publication Number Publication Date
WO2017206302A1 true WO2017206302A1 (zh) 2017-12-07

Family

ID=60479666

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/091943 WO2017206302A1 (zh) 2016-05-31 2016-07-27 一种应用程序的运行方法和运行装置

Country Status (2)

Country Link
CN (1) CN107450937B (zh)
WO (1) WO2017206302A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078318A (zh) * 2019-12-18 2020-04-28 Oppo广东移动通信有限公司 配置文件的处理方法、装置、系统及存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112953721B (zh) * 2021-01-28 2023-04-14 浪潮通用软件有限公司 一种ipa文件的解析方法、装置、设备及存储介质
CN117390627B (zh) * 2023-11-29 2024-06-21 读书郎教育科技有限公司 用于应用程序的安全属性识别方法和装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103493016A (zh) * 2011-04-21 2014-01-01 惠普发展公司,有限责任合伙企业 将应用程序安装到虚拟化环境中
US20140282465A1 (en) * 2013-03-12 2014-09-18 Bluebox Security Inc. Methods for Dynamic Mobile Application Behavior Modification Subject to a Behavior Policy
CN104239102A (zh) * 2014-09-15 2014-12-24 腾讯科技(深圳)有限公司 应用程序运行方法和装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101957770B (zh) * 2010-10-09 2015-09-02 中兴通讯股份有限公司 一种移动设备上应用程序的启动方法及装置
US8819678B2 (en) * 2010-12-15 2014-08-26 Red Hat Israel, Ltd. Live migration of a guest from a source hypervisor to a target hypervisor
CN103514004B (zh) * 2012-06-28 2016-12-21 联想(北京)有限公司 Windows系统下的系统环境管理方法及装置
CN103677920B (zh) * 2013-12-11 2017-01-25 清华大学 关键应用程序识别及启动提速的方法及系统
CN105528229B (zh) * 2015-12-16 2018-09-07 广东欧珀移动通信有限公司 提高移动终端首次开机速度的方法及装置
CN105490860B (zh) * 2015-12-24 2019-03-05 北京奇虎科技有限公司 部署应用程序运行环境的方法、装置及系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103493016A (zh) * 2011-04-21 2014-01-01 惠普发展公司,有限责任合伙企业 将应用程序安装到虚拟化环境中
US20140282465A1 (en) * 2013-03-12 2014-09-18 Bluebox Security Inc. Methods for Dynamic Mobile Application Behavior Modification Subject to a Behavior Policy
CN104239102A (zh) * 2014-09-15 2014-12-24 腾讯科技(深圳)有限公司 应用程序运行方法和装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078318A (zh) * 2019-12-18 2020-04-28 Oppo广东移动通信有限公司 配置文件的处理方法、装置、系统及存储介质
CN111078318B (zh) * 2019-12-18 2023-06-13 Oppo广东移动通信有限公司 配置文件的处理方法、装置、系统及存储介质

Also Published As

Publication number Publication date
CN107450937A (zh) 2017-12-08
CN107450937B (zh) 2021-02-19

Similar Documents

Publication Publication Date Title
US10810051B1 (en) Autoscaling using file access or cache usage for cluster machines
US8041707B2 (en) Database management system and method capable of dynamically generating new tasks that can be processed in parallel
KR100589798B1 (ko) 중지동안 바이트 코드 최적화 장치 및 방법
CN110990019B (zh) 一种Java类分析方法、装置、存储介质及电子设备
CN104182255A (zh) 一种系统应用的库文件升级方法及终端
JP6481415B2 (ja) データストレージ管理装置及びデータストレージ管理方法
CN110175677A (zh) 自动更新方法、装置、计算机设备及存储介质
CN103227812A (zh) 智能设备中支持断点续传的下载方法和装置
CN104113576A (zh) 一种客户端的更新方法及装置
WO2017206302A1 (zh) 一种应用程序的运行方法和运行装置
CN105574141B (zh) 一种对数据库进行数据迁移的方法和装置
CN110688175A (zh) 文件加载的方法、装置、终端设备和存储介质
CN104182252A (zh) 一种app版本增量更新方法
CN101727344A (zh) 安装软件的方法和装置
CN103902562A (zh) 一种终端数据库升级方法及相关装置
CN103513956A (zh) 一种处理器处理数据的方法以及装置
JP2015172862A (ja) データライフサイクルを制御する情報処理装置、データライフサイクル制御方法、及びそのためのプログラム
CN116361031A (zh) 消息的传输方法、系统、装置、处理器以及电子设备
CN114077580A (zh) 系统及移动终端对无线便携设备进行文件操作的方法
CN117170634A (zh) 代码编译方法、装置、存储介质及电子设备
CN111090627B (zh) 基于池化的日志存储方法、装置、计算机设备及存储介质
CN108874625B (zh) 信息处理方法及装置、电子设备、存储介质
CN113342270A (zh) 卷卸载方法、装置和电子设备
CN112799690A (zh) 信息处理方法、装置、设备和存储介质
CN112783557A (zh) 一种Linux内核中加载和解压并行执行的方法

Legal Events

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

Ref document number: 16903684

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16903684

Country of ref document: EP

Kind code of ref document: A1