Application program hot start method and device, equipment and storage medium

By acquiring and using a pre-determined foreground memory recycling waterline during the application hot start process, the problem of memory recycling waterline triggering garbage collection during the hot start process is solved, and the application's hot start fluency and user experience are improved.

CN119883589APending Publication Date: 2025-04-25BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311396709.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-25
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

During the hot startup process of the application, occupancy of a large amount of memory causes the memory recycling waterline to trigger the garbage collection mechanism, causing CPU resource preemption and other threads to hang, affecting the user experience.

Method used

Retrieve the foreground memory recycling waterline of the predetermined application in response to the hot start instruction, and determine the target memory recycling waterline as the trigger limit of the garbage collection mechanism based on the waterline, and postpone the triggering of the garbage collection mechanism during the hot start process.

Benefits of technology

It reduces the impact of garbage collection mechanism triggering on the application hot start speed, improves the fluency of application hot start, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883589A_ABST
    Figure CN119883589A_ABST
Patent Text Reader

Abstract

The invention relates to an application program hot start method and device, equipment and a storage medium, and the method comprises the steps: responding to a received hot start instruction for an application program, and obtaining a predetermined foreground memory recovery waterline of the application program; a target memory recovery waterline of the application program is determined based on the foreground memory recovery waterline, the target memory recovery waterline is used as a boundary for triggering a garbage collection GC mechanism of the application program, and the target memory recovery waterline is higher than a background memory recovery waterline of the application program; and determining whether to trigger a garbage collection GC mechanism of the application program or not based on the target memory collection waterline in a hot start process of the application program. According to the method and the device, the triggering of the GC mechanism in the hot start process can be delayed, the influence of the triggering of the GC mechanism on the hot start speed of the application program can be reduced, the hot start fluency of the application program is improved, and then the use experience of a user can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of terminal technology, and in particular to a method, device, equipment and storage medium for hot starting an application. Background Art

[0002] In the related art, in order to control the memory occupancy rate of an application and improve the usage of memory space, a memory recycling watermark is usually set for each application. When the memory occupied by an application reaches the memory recycling watermark, a garbage collection (GC) mechanism is triggered to recycle part of the memory occupied by the application.

[0003] During the hot start of an application, a large amount of memory is often requested, which makes it very easy for the occupied memory to reach the memory recycling waterline, and then the GC mechanism is easily triggered. The triggering of the GC mechanism will cause the preemption of the central processing unit (CPU) resources and the suspension of other threads, thus slowing down the hot start speed of the application and affecting the user experience. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the embodiments of the present disclosure provide an application hot start method, device, equipment and storage medium to solve the defects in the related art.

[0005] According to a first aspect of an embodiment of the present disclosure, a method for hot starting an application is provided, the method comprising:

[0006] In response to receiving a hot start instruction for an application, obtaining a predetermined foreground memory reclaim waterline of the application;

[0007] Determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application;

[0008] During the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline.

[0009] In some embodiments, the method further includes determining the foreground memory reclaim watermark based on the following manner:

[0010] In response to the application program switching from foreground operation to background operation, starting a garbage collection (GC) mechanism of the application program and detecting a memory size currently occupied by the application program;

[0011] The foreground memory reclaim waterline is determined based on the currently occupied memory size, memory utilization, and a preset foreground application memory growth size magnification factor.

[0012] In some embodiments, the method further comprises:

[0013] detecting how long the application is running in the background;

[0014] In response to the background running time reaching a set time threshold, the garbage collection GC mechanism of the application is started and the operation of detecting the memory size currently occupied by the application is performed.

[0015] In some embodiments, the determining the foreground memory reclaim waterline based on the current occupied memory size, memory utilization, and a preset foreground application memory growth magnification factor includes:

[0016] Determining the memory growth size of the application based on the currently occupied memory size and the memory utilization rate;

[0017] The foreground memory reclaim waterline is determined based on the currently occupied memory size, the memory growable size, and a preset foreground application memory growable size magnification factor.

[0018] In some embodiments, the method further comprises:

[0019] Get the current memory reclaim watermark of the application;

[0020] The determining the target memory reclaim waterline of the application based on the foreground memory reclaim waterline includes:

[0021] Compare the current memory reclaim waterline with the foreground memory reclaim waterline;

[0022] In response to the current memory reclaim watermark being less than or equal to the foreground memory reclaim watermark, the foreground memory reclaim watermark is determined as the target memory reclaim watermark.

[0023] According to a second aspect of an embodiment of the present disclosure, a device for hot starting an application is provided, the device comprising:

[0024] A foreground watermark acquisition module, configured to acquire a predetermined foreground memory reclaim watermark of the application in response to receiving a hot start instruction for the application;

[0025] A target waterline determination module is used to determine the target memory recovery waterline of the application based on the foreground memory recovery waterline, the target memory recovery waterline is used as a limit for triggering the garbage collection GC mechanism of the application, and the target memory waterline is higher than the background memory recovery waterline of the application;

[0026] The recycling mechanism control module is used to determine whether to trigger the garbage collection (GC) mechanism of the application program based on the target memory recycling waterline during the hot start of the application program.

[0027] In some embodiments, the apparatus further comprises a foreground waterline determination module;

[0028] The foreground waterline determination module includes:

[0029] A memory size detection unit, configured to start a garbage collection (GC) mechanism of the application program in response to the application program switching from foreground operation to background operation, and detect the memory size currently occupied by the application program;

[0030] The foreground waterline determination unit is used to determine the foreground memory recovery waterline based on the current occupied memory size, memory utilization and a preset foreground application memory growth size magnification factor.

[0031] In some embodiments, the foreground waterline determination module further includes:

[0032] A running time detection unit, used to detect the background running time of the application program;

[0033] The memory size detection unit is also used to execute the operation of starting the garbage collection GC mechanism of the application and detecting the memory size currently occupied by the application in response to the background running time reaching a set time threshold.

[0034] In some embodiments, the foreground waterline determination unit is further configured to:

[0035] Determining the memory growth size of the application based on the currently occupied memory size and the memory utilization rate;

[0036] The foreground memory reclaim waterline is determined based on the currently occupied memory size, the memory growable size, and a preset foreground application memory growable size magnification factor.

[0037] In some embodiments, the apparatus further comprises:

[0038] A current waterline acquisition module, used to acquire the current memory recycling waterline of the application;

[0039] The target waterline determination module comprises:

[0040] A watermark comparison unit, used to compare the current memory reclaim watermark with the foreground memory reclaim watermark;

[0041] The watermark determination unit is used to determine the foreground memory reclaim watermark as the target memory reclaim watermark in response to the current memory reclaim watermark being less than or equal to the foreground memory reclaim watermark.

[0042] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, the device comprising:

[0043] a processor and a memory for storing a computer program;

[0044] Wherein, the processor is configured to implement, when executing the computer program:

[0045] In response to receiving a hot start instruction for an application, obtaining a predetermined foreground memory reclaim waterline of the application;

[0046] Determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application;

[0047] During the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline.

[0048] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the following is implemented:

[0049] In response to receiving a hot start instruction for an application, obtaining a predetermined foreground memory reclaim waterline of the application;

[0050] Determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application;

[0051] During the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline.

[0052] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0053] The present invention obtains a predetermined foreground memory recycle waterline of the application in response to receiving a hot start instruction for the application, and determines a target memory recycle waterline of the application based on the foreground memory recycle waterline, and then determines whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycle waterline during the hot start of the application. Since the target memory recycle waterline of the application is determined based on the predetermined foreground memory recycle waterline of the application to determine whether to trigger the garbage collection (GC) mechanism of the application, compared with the solution in the related art that still uses the background memory recycle waterline when the application is hot started until the GC mechanism is triggered, the triggering of the GC mechanism during the hot start process can be postponed, the influence of the triggering of the GC mechanism on the hot start speed of the application can be reduced, the smoothness of the hot start of the application can be improved, and the user experience can be improved.

[0054] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0056] Figure 1A is a flow chart of a method for hot starting an application program according to an exemplary embodiment of the present disclosure;

[0057] Figure 1B is a schematic diagram of a memory recycling waterline according to an exemplary embodiment of the related art;

[0058] Figure 1C is a schematic diagram of a memory recycling waterline according to an exemplary embodiment of the present disclosure;

[0059] Figure 2 is a flow chart showing how to determine the foreground memory recycling waterline according to an exemplary embodiment of the present disclosure;

[0060] Figure 3 It is a flowchart showing how to determine the foreground memory recycling waterline based on the current occupied memory size, memory utilization and a preset foreground application memory growth magnification factor according to an exemplary embodiment of the present disclosure;

[0061] Figure 4 is a flowchart showing how to determine the target memory reclaim waterline of the application based on the foreground memory reclaim waterline according to an exemplary embodiment of the present disclosure;

[0062] Figure 5is a block diagram of a device for hot starting an application according to an exemplary embodiment of the present disclosure;

[0063] Figure 6 is a block diagram showing another device for hot starting an application program according to an exemplary embodiment of the present disclosure;

[0064] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0065] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0066] Figure 1A is a flow chart of a method for hot starting an application program according to an exemplary embodiment; the method of this embodiment can be executed by an application hot starting device, which can be configured in an electronic device, such as a server, a workstation, a personal computer, a mobile terminal (such as a mobile phone, a tablet computer, etc.), a wearable device (such as glasses, a watch, etc.), etc. Specifically, Figure 1A As shown, the method includes the following steps S101-S103:

[0067] In step S101, in response to receiving a hot start instruction for an application, a predetermined foreground memory reclaim waterline of the application is obtained.

[0068] In this embodiment, the electronic device may obtain a predetermined foreground memory reclaim waterline of the application in response to receiving a hot start instruction for the application.

[0069] The hot start instruction includes an instruction for controlling the application to perform a hot start. Specifically, a hot start means that when the application is started, there is already a process of the application in the background. If there is an existing process, the application will be started from the existing process. The corresponding cold start means that when the application is started, there is no process of the application in the background. At this time, the system will recreate a new process and assign it to the application.

[0070] As the name implies, the foreground memory reclaim waterline of this embodiment refers to the memory reclaim waterline when the application is running in the foreground.

[0071] In some embodiments, the foreground memory recycling waterline prediction method can refer to the following Figure 2 The illustrated embodiment will not be described in detail here.

[0072] In step S102, a target memory reclaim waterline of the application is determined based on the foreground memory reclaim waterline.

[0073] In this embodiment, after the predetermined foreground memory reclaim watermark of the application is obtained, the target memory reclaim watermark of the application may be determined based on the foreground memory reclaim watermark.

[0074] The target memory recycling watermark can be used as a limit for triggering the garbage collection GC mechanism of the application during the hot start of the application, and the target memory watermark is higher than the background memory recycling watermark of the application. The background memory recycling watermark of this embodiment refers to the memory recycling watermark of the application when it is running in the background.

[0075] Since the target memory recycle waterline of the application is determined based on the predetermined foreground memory recycle waterline of the application, and under normal circumstances, the foreground memory recycle waterline is higher than the background memory recycle waterline, the present embodiment can improve the target memory recycle waterline. Therefore, compared with the solution in the related art that still uses the background memory recycle waterline during hot start of the application until the GC mechanism is triggered, the present embodiment can postpone the triggering of the GC mechanism during the hot start process, thereby reducing the impact of the triggering of the GC mechanism on the hot start speed of the application.

[0076] In some embodiments, the above method for determining the target memory recycling waterline of the application can refer to the following Figure 4 The illustrated embodiment will not be described in detail here.

[0077] In step S103, during the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling watermark.

[0078] In this embodiment, after the target memory recycle waterline of the application is determined based on the foreground memory recycle waterline, whether to trigger the garbage collection (GC) mechanism of the application can be determined based on the target memory recycle waterline during the hot start of the application.

[0079] For example, during the hot start of the application, the memory occupied by the application can be detected, and when the memory occupied by the application reaches the target memory recovery waterline, the garbage collection GC mechanism of the application is triggered to recycle the garbage memory occupied by the application.

[0080] The above-mentioned garbage collection GC mechanism is an automatic memory management mechanism. When a part of the memory space occupied by an application is no longer accessed by the program, the garbage collection mechanism will help the application release this part of the memory space. Specifically, the garbage collection mechanism can determine which objects in the heap memory are garbage, where garbage refers to objects in the heap memory that are no longer used. After determining the garbage, the garbage collection mechanism can destroy the garbage, and the memory space occupied by the garbage can also be recycled.

[0081] For example, Figure 1B is a schematic diagram of a memory recycling waterline according to an exemplary embodiment of the related art; Figure 1C FIG. 1 is a schematic diagram showing a memory recycling waterline according to an exemplary embodiment of the present disclosure. Figure 1B As shown in the figure, in the related art, when the application is switched from the foreground to the background, GC will occur after 5 seconds, which will reduce the memory recycling watermark (i.e., the GC watermark in the figure). On this basis, when the application is hot-started, i.e., switched from the background to the foreground, the current memory recycling watermark (i.e., the background memory recycling watermark) will be used until the GC mechanism is triggered. Since the used GC watermark is extremely low, the first GC will be triggered earlier, which will affect the speed of the application hot-start. In this embodiment, Figure 1C As shown in the figure, after the application switches from the foreground to the background, the foreground memory recycling waterline (i.e. Figure 1C The foreground waterline is shown by the dotted line in the middle), and then when a hot start is performed in response to a hot start instruction, the predicted foreground waterline can be immediately enabled, that is, the target memory reclaim waterline is determined based on the foreground waterline, so that during the hot start of the application, it is determined based on the target memory reclaim waterline whether to trigger the garbage collection GC mechanism of the application, thereby delaying the triggering of the GC mechanism in the hot start process and reducing the impact of the triggering of the GC mechanism on the hot start speed of the application.

[0082] From the above description, it can be seen that the method of this embodiment obtains a predetermined foreground memory recovery waterline of the application in response to receiving a hot start instruction for the application, and determines the target memory recovery waterline of the application based on the foreground memory recovery waterline, and then determines whether to trigger the garbage collection GC mechanism of the application based on the target memory recovery waterline during the hot start of the application. Since the target memory recovery waterline of the application is determined based on the predetermined foreground memory recovery waterline of the application to determine whether to trigger the garbage collection GC mechanism of the application, compared with the solution in the related art that still uses the background memory recovery waterline when the application is hot started until the GC mechanism is triggered, it can achieve the delay of the triggering of the GC mechanism during the hot start process, can reduce the impact of the triggering of the GC mechanism on the hot start speed of the application, improve the smoothness of the hot start of the application, and thus improve the user experience.

[0083] Figure 2 It is a flowchart showing how to determine the foreground memory recycling waterline according to an exemplary embodiment of the present disclosure; this embodiment is based on the above embodiment and takes how to determine the foreground memory recycling waterline as an example for exemplary description.

[0084] like Figure 2 As shown, the application hot start method of this embodiment may further include determining the foreground memory recycling waterline based on the following steps S201-S202:

[0085] In step S201, in response to the application being switched from foreground operation to background operation, a garbage collection (GC) mechanism of the application is started, and the size of the memory currently occupied by the application is detected.

[0086] In this embodiment, in response to the application program switching from foreground operation to background operation, the electronic device may start the garbage collection (GC) mechanism of the application program and detect the memory size currently occupied by the application program.

[0087] For example, in response to detecting a preset exit operation for an application, the electronic device may switch the application from foreground operation to background operation, and may detect the memory size currently occupied by the application. Exemplarily, the preset exit operation may include a click operation on at least one key such as a close key, a return key, and a home key.

[0088] It is understandable that when the application is switched from the foreground to the background, the application is not completely terminated, and when the application is triggered to start again, the startup mode of the application is hot start.

[0089] In some embodiments, the electronic device can also detect the background running time of the application in response to the application switching from foreground operation to background operation, and then in response to the background running time reaching a set time threshold, execute the above-mentioned operation of starting the garbage collection GC mechanism of the application and detecting the memory size currently occupied by the application. It is worth noting that the above-mentioned set time threshold can be set based on actual business needs, such as being set to 5 seconds, etc., and this embodiment does not limit this. Since the garbage collection GC mechanism of the application is started after waiting for the background running time to reach the set time threshold, and the memory size currently occupied by the application is detected, the stability of starting the garbage collection GC mechanism can be improved, and then the accuracy of detecting the memory size currently occupied by the application can be improved, thereby avoiding the disadvantage of starting the GC mechanism when the application occasionally switches from foreground operation to background operation.

[0090] In step S202, the foreground memory reclaim waterline is determined based on the current occupied memory size, memory utilization, and a preset foreground application memory growth magnification factor.

[0091] In this embodiment, after detecting the memory size currently occupied by the application, the foreground memory recovery waterline can be determined based on the current memory size, memory utilization, and a preset foreground application memory growth size magnification factor.

[0092] In some embodiments, the above method for determining the foreground memory recycling waterline can refer to the following Figure 3 The illustrated embodiment will not be described in detail here.

[0093] As can be seen from the above description, this embodiment starts the garbage collection GC mechanism of the application in response to the application switching from foreground operation to background operation, detects the memory size currently occupied by the application, and determines the foreground memory recovery waterline based on the current memory size occupied, memory utilization and a preset foreground application memory growth magnification factor. This can achieve a reasonable prediction of the foreground memory recovery waterline, and then subsequently determine the target memory recovery waterline of the application based on the foreground memory recovery waterline, and in the process of hot starting the application, determine whether to trigger the garbage collection GC mechanism of the application based on the target memory recovery waterline, which can reduce the impact of the triggering of the GC mechanism on the hot start speed of the application, improve the smoothness of the hot start of the application, and thus enhance the user experience.

[0094] Figure 3It is a flowchart showing how to determine the foreground memory recovery waterline based on the currently occupied memory size, memory utilization and a preset foreground application memory growth magnification factor according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment uses the example of how to determine the foreground memory recovery waterline based on the currently occupied memory size, memory utilization and a preset foreground application memory growth magnification factor as an example.

[0095] like Figure 3 As shown, the foreground memory recycling waterline determined based on the current occupied memory size, memory utilization and the preset foreground application memory growth magnification factor in the above step S202 may include the following steps S301-S302:

[0096] In step S301, the memory growth size of the application is determined based on the currently occupied memory size and the memory utilization rate.

[0097] In this embodiment, after detecting the memory size currently occupied by the application, the electronic device may determine the memory growth size of the application based on the currently occupied memory size and the memory utilization rate.

[0098] For example, the calculation method of the memory growth size can be shown in the following formula (3-1):

[0099] delta = bytes_allocated * (1.0 / targetUtilization - 1.0); (3-1)

[0100] In the above formula, delta indicates the memory growth size of the application, bytes_allocated indicates the memory size currently occupied by the application, and targetUtilization indicates the memory utilization.

[0101] In step S302, the foreground memory reclaim waterline is determined based on the currently occupied memory size, the memory growable size, and a preset foreground application memory growable size magnification factor.

[0102] In this embodiment, after determining the memory growth size of the application based on the currently occupied memory size and the memory utilization, the electronic device can determine the foreground memory recovery waterline based on the currently occupied memory size, the memory growth size and the preset foreground application memory growth size magnification factor.

[0103] For example, the calculation method of the foreground memory recycling waterline can be shown in the following formula (3-2):

[0104] target_size = bytes_allocated + delta * foreground_multiplier; (3-2)

[0105] In the above formula, target_size represents the foreground memory recovery waterline, bytes_allocated represents the memory size currently occupied by the application, delta represents the memory growth size of the application, and foreground_multiplier represents the preset foreground application memory growth size magnification multiple (for example, 3).

[0106] It can be understood that the calculation method of the background memory recovery waterline is similar to the above formula (3-2), and it is only necessary to replace the foreground application memory growth size magnification foreground_multiplier with the background application memory growth size magnification background_multiplier (for example, 1). Since the foreground application memory growth size magnification is greater than the background application memory growth size magnification (that is, 3 is greater than 1), it can be ensured that the foreground memory recovery waterline is greater than the background memory recovery waterline, and then by determining the target memory recovery waterline of the application based on the foreground memory recovery waterline, it is possible to improve the target memory recovery waterline. Therefore, compared with the solution in the related art that still uses the background memory recovery waterline until the GC mechanism is triggered when the application is hot started, this embodiment can delay the triggering of the GC mechanism during the hot start process, thereby reducing the impact of the triggering of the GC mechanism on the hot start speed of the application.

[0107] As can be seen from the above description, this embodiment determines the memory growable size of the application based on the currently occupied memory size and the memory utilization rate, and determines the foreground memory recovery waterline based on the currently occupied memory size, the memory growable size and the preset foreground application memory growth size magnification multiple. This can achieve a reasonable prediction of the foreground memory recovery waterline based on the currently occupied memory size, the memory utilization rate and the preset foreground application memory growth size magnification multiple, and then can achieve subsequent determination of the target memory recovery waterline of the application based on the foreground memory recovery waterline, and in the process of hot starting the application, determine whether to trigger the garbage collection GC mechanism of the application based on the target memory recovery waterline, which can reduce the impact of the triggering of the GC mechanism on the hot start speed of the application, improve the smoothness of the hot start of the application, and thus improve the user experience.

[0108] Figure 4It is a flowchart showing how to determine the target memory reclaim waterline of the application based on the foreground memory reclaim waterline according to an exemplary embodiment of the present disclosure; this embodiment, based on the above embodiment, uses the example of how to determine the target memory reclaim waterline of the application based on the foreground memory reclaim waterline.

[0109] In this embodiment, before determining the target memory recycle waterline of the application based on the foreground memory recycle waterline, the method may further include obtaining the current memory recycle waterline of the application (at this time, the application is still running in the background and has not yet switched to the foreground, so the current memory recycle waterline is the background memory recycle waterline). Figure 4 As shown, the determination of the target memory reclaim waterline of the application based on the foreground memory reclaim waterline in the above step S102 may include the following steps S401-S404:

[0110] In step S401, the current memory reclaim watermark and the foreground memory reclaim watermark are compared;

[0111] In step S402, determine whether the current memory recycle watermark is less than or equal to the foreground memory recycle watermark: if so, execute step S403; if not, execute step S404;

[0112] In step S403, the foreground memory reclaim watermark is determined as the target memory reclaim watermark;

[0113] In step S404, the current memory reclaim watermark is determined as the target memory reclaim watermark.

[0114] In this embodiment, after obtaining the foreground memory recycle waterline of the application, the current memory recycle waterline and the foreground memory recycle waterline can be compared to determine the larger of the current memory recycle waterline and the foreground memory recycle waterline as the target memory recycle waterline, thereby reasonably determining the target memory recycle waterline, delaying the triggering of the GC mechanism during the hot start process, and reducing the impact of the triggering of the GC mechanism on the hot start speed of the application.

[0115] Usually, based on the above Figure 2 or Figure 3 The foreground memory recycling waterline predicted by the embodiment shown is greater than the current memory recycling waterline (i.e., the background memory recycling waterline). However, in some special cases (for example, the user switches the application from the foreground to the background within 5 seconds, and then switches the application from the background back to the foreground), based on the above Figure 2 or Figure 3The foreground memory reclaim waterline (for example, 0) predicted by the illustrated embodiment will be smaller than the current memory reclaim waterline, and thus the target memory reclaim waterline can be determined by taking the larger of the two, which can further improve the rationality of determining the target memory reclaim waterline.

[0116] As can be seen from the above description, this embodiment obtains the current memory recovery waterline of the application, compares the current memory recovery waterline with the foreground memory recovery waterline, and then, in response to the current memory recovery waterline being less than or equal to the foreground memory recovery waterline, determines the foreground memory recovery waterline as the target memory recovery waterline, and in response to the current memory recovery waterline being greater than the foreground memory recovery waterline, determines the current memory recovery waterline as the target memory recovery waterline. This can accurately determine the target memory recovery waterline of the application based on the foreground memory recovery waterline, and then, in the subsequent hot start process of the application, determine whether to trigger the garbage collection GC mechanism of the application based on the target memory recovery waterline, and postpone the triggering of the GC mechanism during the hot start process, reduce the impact of the triggering of the GC mechanism on the hot start speed of the application, improve the smoothness of the hot start of the application, and thus improve the user experience.

[0117] Figure 5 is a block diagram of an application hot start device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be configured in an electronic device, such as a server, a workstation, a personal computer, a mobile terminal (such as a mobile phone, a tablet computer, etc.), a wearable device (such as glasses, a watch, etc.), etc. Specifically, Figure 5 As shown, the device may include: a foreground waterline acquisition module 110, a target waterline determination module 120 and a recycling mechanism control module 130, wherein:

[0118] A foreground watermark acquisition module 110, configured to acquire a predetermined foreground memory reclaim watermark of the application in response to receiving a hot start instruction for the application;

[0119] A target waterline determination module 120 is used to determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, wherein the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application;

[0120] The recycling mechanism control module 130 is used to determine whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline during the hot start of the application.

[0121] From the above description, it can be seen that the device of this embodiment obtains a predetermined foreground memory recycle watermark of the application in response to receiving a hot start instruction for the application, and determines the target memory recycle watermark of the application based on the foreground memory recycle watermark, and then determines whether to trigger the garbage collection GC mechanism of the application based on the target memory recycle watermark during the hot start of the application. Since the target memory recycle watermark of the application is determined based on the predetermined foreground memory recycle watermark of the application to determine whether to trigger the garbage collection GC mechanism of the application, compared with the solution in the related art that still uses the background memory recycle watermark until the GC mechanism is triggered when the application is hot started, it is possible to postpone the triggering of the GC mechanism during the hot start process, reduce the impact of the triggering of the GC mechanism on the hot start speed of the application, improve the smoothness of the hot start of the application, and thus improve the user experience.

[0122] Figure 6 2 is a block diagram of another application hot start device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be configured in an electronic device, such as a server, a workstation, a personal computer, a mobile terminal (such as a mobile phone, a tablet computer, etc.), a wearable device (such as glasses, watches, etc.), etc. Among them, the foreground waterline acquisition module 210, the target waterline determination module 220 and the recycling mechanism control module 230 are the same as the aforementioned Figure 5 The functions of the foreground waterline acquisition module 110, the target waterline determination module 120 and the recycling mechanism control module 130 in the illustrated embodiment are the same and will not be described in detail herein.

[0123] In this embodiment, the above device may further include a foreground waterline determination module 240;

[0124] The foreground waterline determination module 240 may include:

[0125] A memory size detection unit 241 is used to start a garbage collection (GC) mechanism of the application in response to the application switching from foreground operation to background operation, and detect the memory size currently occupied by the application;

[0126] The foreground waterline determination unit 242 is used to determine the foreground memory reclaim waterline based on the current occupied memory size, memory utilization and a preset foreground application memory growth size magnification factor.

[0127] In some embodiments, the foreground waterline determination module 240 may further include:

[0128] A running time detection unit 243, used for detecting the background running time of the application program;

[0129] Furthermore, the memory size detection unit 241 can also be used to execute the operation of starting the garbage collection GC mechanism of the application and detecting the memory size currently occupied by the application in response to the background running time reaching a set time threshold.

[0130] In some embodiments, the foreground waterline determination unit 242 may also be used to:

[0131] Determining the memory growth size of the application based on the currently occupied memory size and the memory utilization rate;

[0132] The foreground memory reclaim waterline is determined based on the currently occupied memory size, the memory growable size, and a preset foreground application memory growable size magnification factor.

[0133] In some embodiments, the above apparatus may further include:

[0134] The current watermark acquisition module 250 is used to acquire the current memory recycling watermark of the application program;

[0135] Furthermore, the target waterline determination module 220 may include:

[0136] A watermark comparison unit 221, configured to compare the current memory reclaim watermark with the foreground memory reclaim watermark;

[0137] The watermark determining unit 222 is configured to determine the foreground memory reclaim watermark as the target memory reclaim watermark in response to the current memory reclaim watermark being less than or equal to the foreground memory reclaim watermark.

[0138] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0139] Figure 7 900 is a block diagram of an electronic device according to an exemplary embodiment. For example, the device 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0140] Reference Figure 7 , device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 916 .

[0141] The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned application hot start method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.

[0142] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of such data include instructions for any application or method operating on the device 900, contact data, phone book data, messages, pictures, videos, etc. The memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0143] The power supply component 906 provides power to the various components of the device 900. The power supply component 906 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.

[0144] The multimedia component 908 includes a screen that provides an output interface between the device 900 and the user. In some embodiments, the screen may include a liquid crystal display panel and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0145] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the device 900 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.

[0146] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0147] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the device 900. For example, the sensor assembly 914 can detect the open / closed state of the device 900, the relative positioning of components, such as the display panel and keypad of the device 900, and the sensor assembly 914 can also detect the position change of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, the orientation or acceleration / deceleration of the device 900, and the temperature change of the device 900. The sensor assembly 914 can also include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0148] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G or 5G or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0149] In an exemplary embodiment, the device 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-described application hot start method.

[0150] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by the processor 920 of the device 900 to complete the above-mentioned application hot start method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0151] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0152] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for hot starting an application, characterized in that: The method comprises: In response to receiving a hot start instruction for an application, obtaining a predetermined foreground memory reclaim waterline of the application; Determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application; During the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline.

2. The method according to claim 1, characterized in that The method further includes determining the foreground memory reclaim waterline based on the following manner: In response to the application program switching from foreground operation to background operation, starting a garbage collection (GC) mechanism of the application program and detecting a memory size currently occupied by the application program; The foreground memory reclaim waterline is determined based on the currently occupied memory size, memory utilization, and a preset foreground application memory growth size magnification factor.

3. The method according to claim 2, characterized in that The method further comprises: detecting how long the application is running in the background; In response to the background running time reaching a set time threshold, the operation of starting the garbage collection GC mechanism of the application and detecting the memory size currently occupied by the application is executed.

4. The method according to claim 2, characterized in that: The determining the foreground memory recycling waterline based on the current occupied memory size, memory utilization, and a preset foreground application memory growth magnification factor includes: Determining the memory growth size of the application based on the currently occupied memory size and the memory utilization rate; The foreground memory reclaim waterline is determined based on the currently occupied memory size, the memory growable size, and a preset foreground application memory growable size magnification factor.

5. The method according to claim 1, characterized in that The method further comprises: Get the current memory reclaim watermark of the application; Determining the target memory reclaim waterline of the application based on the foreground memory reclaim waterline includes: Compare the current memory reclaim waterline with the foreground memory reclaim waterline; In response to the current memory reclaim watermark being less than or equal to the foreground memory reclaim watermark, the foreground memory reclaim watermark is determined as the target memory reclaim watermark.

6. An application hot start device, characterized in that: The device comprises: A foreground waterline acquisition module, configured to acquire a predetermined foreground memory reclaim waterline of the application in response to receiving a hot start instruction for the application; A target waterline determination module is used to determine the target memory recovery waterline of the application based on the foreground memory recovery waterline, the target memory recovery waterline is used as a limit for triggering the garbage collection GC mechanism of the application, and the target memory waterline is higher than the background memory recovery waterline of the application; The recycling mechanism control module is used to determine whether to trigger the garbage collection (GC) mechanism of the application program based on the target memory recycling waterline during the hot start of the application program.

7. The device according to claim 6, characterized in that The device also includes a foreground waterline determination module; The foreground waterline determination module includes: A memory size detection unit, configured to start a garbage collection (GC) mechanism of the application program in response to the application program switching from foreground operation to background operation, and detect the memory size currently occupied by the application program; The foreground waterline determination unit is used to determine the foreground memory recovery waterline based on the current occupied memory size, memory utilization and a preset foreground application memory growth size magnification factor.

8. The device according to claim 7, characterized in that The foreground waterline determination module also includes: A running time detection unit, used to detect the background running time of the application program; The memory size detection unit is also used to execute the operation of starting the garbage collection GC mechanism of the application and detecting the memory size currently occupied by the application in response to the background running time reaching a set time threshold.

9. The device according to claim 7, characterized in that The foreground waterline determination unit is also used for: Determining the memory growth size of the application based on the currently occupied memory size and the memory utilization rate; The foreground memory reclaim waterline is determined based on the currently occupied memory size, the memory growable size, and a preset foreground application memory growable size magnification factor.

10. The device according to claim 6, characterized in that The device also includes: A current waterline acquisition module, used to acquire the current memory recycling waterline of the application; The target waterline determination module comprises: A watermark comparison unit, used to compare the current memory reclaim watermark with the foreground memory reclaim watermark; The watermark determination unit is used to determine the foreground memory reclaim watermark as the target memory reclaim watermark in response to the current memory reclaim watermark being less than or equal to the foreground memory reclaim watermark.

11. An electronic device, characterized in that: The device comprises: a processor and a memory for storing a computer program; Wherein, the processor is configured to implement, when executing the computer program: In response to receiving a hot start instruction for an application, obtaining a predetermined foreground memory reclaim waterline of the application; Determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application; During the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by the processor, it realizes: In response to receiving a hot start instruction for an application, obtaining a predetermined foreground memory reclaim waterline of the application; Determine a target memory recycle waterline of the application based on the foreground memory recycle waterline, the target memory recycle waterline is used as a limit for triggering a garbage collection (GC) mechanism of the application, and the target memory waterline is higher than a background memory recycle waterline of the application; During the hot start of the application, it is determined whether to trigger the garbage collection (GC) mechanism of the application based on the target memory recycling waterline.

Citation Information

Cited By

  • Equipment starting performance optimization method and device, equipment and storage medium

    CN120085928A

  • A method, device, equipment and storage medium for optimizing device startup performance

    CN120085928B