An application program running management method, device and equipment and readable storage medium

By applying pressure to the server memory using chaosblade and recording response time and available memory, the stuttering problem caused by improper memory release in the application was resolved, and the application was able to run stably.

CN116244077BActive Publication Date: 2026-04-17JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2023-02-10
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies make it difficult to accurately determine the minimum memory required for an application to function properly, leading to improper memory release and resulting in stuttering issues.

Method used

By gradually applying pressure to the server memory using Chaosblade, recording available memory and response time, determining whether the response time exceeds a preset threshold, identifying the minimum memory requirements of the target application, and allocating the corresponding memory to avoid lag.

Benefits of technology

Accurately determine and allocate the minimum memory required for the application to avoid lag and reduce the impact on other applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244077B_ABST
    Figure CN116244077B_ABST
Patent Text Reader

Abstract

This application relates to the field of computers and discloses an application runtime management method, apparatus, electronic device, and computer-readable storage medium, comprising: when a target application runs alone on a server, gradually applying pressure to the server's memory using chaosblade; recording the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure; determining whether the response time exceeds a preset response time; if the target response time exceeds the preset response time, determining the target available memory as the minimum memory required for the target application to run; the target response time is the shortest time exceeding the preset response time among response times, and the target available memory is the available memory corresponding to the response time preceding the target response time; allocating the minimum memory to the target application to ensure its normal operation. This application can determine the minimum memory required for the target application to run, ensuring its normal operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and in particular to an application operation management method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] When a server hosts many applications, and the server's memory usage is too high, the remaining memory may not be enough to support the normal operation of the applications, resulting in service lag.

[0003] To resolve application lag, the current common practice is to monitor server memory usage in the background and manually release memory used by certain applications to ensure the target application runs normally. However, it's currently difficult to accurately determine the minimum memory resources required for the target application to run properly. Therefore, it's impossible to know how much memory needs to be released, which may result in either insufficient memory released for the target application to run normally, or more memory released than the target application needs.

[0004] Therefore, how to solve the above-mentioned technical problems should be a key focus for those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide an application runtime management method, apparatus, electronic device, and computer-readable storage medium to determine the minimum memory required for the normal operation of an application, thereby enabling the application to run normally and avoiding lag.

[0006] To address the aforementioned technical problems, this application provides an application runtime management method, comprising:

[0007] When the target application runs alone on the server, chaosblade gradually puts pressure on the server's memory.

[0008] Record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure;

[0009] Determine whether the response time exceeds the preset response time;

[0010] If the target response time exceeds the preset response time, then the target available memory is determined to be the minimum memory required for the target application to run; the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the response time preceding the target response time;

[0011] Allocate the minimum memory to the target application so that the target application can run normally.

[0012] Optionally, allocating the minimum memory to the target application includes:

[0013] Obtain the memory currently used by the target application on the server;

[0014] Based on the minimum memory and the currently used memory, determine the compensation memory required by the target application;

[0015] The compensated memory is then allocated to the target application.

[0016] Optionally, when the free memory in the server is not less than the compensation memory, compensating the target application with the compensation memory includes:

[0017] Virtual memory is created using the mmap function, and the virtual memory is adjusted using the brk and sbrk functions so that the adjusted virtual memory is equal to the compensation memory.

[0018] Allocate memory from the free memory equal to the adjusted virtual memory to the target application.

[0019] Optionally, when the free memory in the server is less than the compensation memory, compensating the target application with the compensation memory includes:

[0020] Virtual memory is created using the mmap function, where the virtual memory is less than or equal to the free memory.

[0021] Terminate applications running on the server with a priority lower than the target application to free up memory on the server. The freed memory shall not be less than the difference between the compensated memory and the virtual memory.

[0022] Allocate memory equal to the virtual memory from the free memory and free up memory to the target application.

[0023] Optionally, terminating applications running on the server with a lower priority than the target application includes:

[0024] Step S1: Select the application with the lowest running priority as the application to be released, and determine whether the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory;

[0025] Step S2: If the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory, then terminate the application to be released in the server;

[0026] Step S3: If the memory occupied by the application to be released is less than the difference between the compensation memory and the virtual memory, then add the application with the lowest running priority among the remaining running programs to the application to be released, resulting in a new application to be released, and proceed to step S1 until the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory.

[0027] Optionally, before terminating applications running on the server with a lower priority than the target application, the method further includes:

[0028] Obtain the PID numbers of all applications on the server;

[0029] The memory usage of the corresponding application is determined based on the PID number.

[0030] Optionally, before obtaining the memory currently used by the target application on the server, the method further includes:

[0031] Obtain the current response time of the target application during runtime;

[0032] Determine whether the current response time exceeds the preset response time;

[0033] If the current response time exceeds the preset response time, then the step of obtaining the memory currently used by the target application on the server is executed.

[0034] This application also provides an application runtime management device, including:

[0035] The stress module is used to gradually apply pressure to the server's memory via chaosblade when the target application is running alone on the server.

[0036] A recording module is used to record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure;

[0037] The first judgment module is used to determine whether the response time exceeds a preset response time;

[0038] The first determining module is used to determine the target available memory as the minimum memory required for the target application to run if the target response time exceeds the preset response time; the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the response time preceding the target response time;

[0039] An allocation module is used to allocate the minimum memory to the target application so that the target application can run normally.

[0040] This application also provides an electronic device, including:

[0041] Memory, used to store computer programs;

[0042] A processor, configured to implement the steps of any of the above-described application operation management methods when executing the computer program.

[0043] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described application program operation management methods.

[0044] This application provides an application runtime management method, comprising: when a target application runs alone on a server, gradually applying pressure to the server's memory using chaosblade; recording the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure; determining whether the response time exceeds a preset response time; if the target response time exceeds the preset response time, determining the target available memory as the minimum memory required for the target application to run; the target response time being the shortest response time exceeding the preset response time, and the target available memory being the available memory corresponding to the response time preceding the target response time; allocating the minimum memory to the target application to enable the target application to run normally.

[0045] As can be seen, this application gradually applies pressure to the server's memory using chaosblade, causing the available memory on the server to gradually decrease and the response time of the target application to gradually increase. The available memory on the server and the response time of the target application are recorded under each pressure level. When the response time is less than a preset response time, the target application cannot run normally, resulting in lag. The response time preceding the target response time is then considered the normal response time for the target application. Correspondingly, the available memory on the server at this point is the minimum memory required for the target application to run. Therefore, the minimum memory is allocated to the target application during its operation to ensure its normal operation, avoid lag, and minimize impact on the operation of other applications on the server.

[0046] In addition, this application also provides an apparatus, electronic device, and computer-readable storage medium having the above advantages. Attached Figure Description

[0047] To more clearly illustrate the technical solutions of the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 A flowchart illustrating an application runtime management method provided in this application embodiment;

[0049] Figure 2 A flowchart illustrating another application runtime management method provided in this application embodiment;

[0050] Figure 3 A flowchart illustrating another application runtime management method provided in this application embodiment;

[0051] Figure 4 A flowchart illustrating another application runtime management method provided in this application embodiment;

[0052] Figure 5 A structural block diagram of the application runtime management device provided in the embodiments of this application;

[0053] Figure 6 A structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0054] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0055] As described in the background section, it is currently difficult to accurately determine the minimum memory resources required for a target application to run normally, so it is impossible to know how much memory needs to be freed up.

[0056] In view of this, this application provides an application runtime management method, please refer to... Figure 1 The method includes:

[0057] Step S101: When the target application is running alone on the server, gradually apply pressure to the server's memory using chaosblade.

[0058] Chaosblade is an experiment injection tool that follows the principles of chaos engineering and chaos experiment models. It includes commands for creating, destroying, and querying experiments, preparing and canceling experimental environments. It serves as the execution tool for chaos experiments, offering both CLI and HTTP execution methods. It provides comprehensive command descriptions, experiment scenarios, and scenario parameter explanations, with a simple and clear interface.

[0059] The server can use the Linux operating system.

[0060] As Chaosblade gradually puts pressure on the server's memory, the available memory on the server gradually decreases.

[0061] When chaosblade applies pressure to the server's memory, the initial pressure is such that the available memory on the server is the memory used by the target application when the server has relatively sufficient memory.

[0062] For example, if the server has relatively sufficient memory, and the memory occupied by the target application is recorded as Mem0, then when applying pressure to the server's memory using Chaosblade, the available memory of the server will first be reduced to Mem0, and then the pressure will be gradually increased.

[0063] Step S102: Record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure.

[0064] As Chaosblade gradually puts pressure on the server's memory, the available memory gradually decreases, becoming Mem1, Mem2, Mem3, ..., Mem... n ,Mem1>Mem2>Mem3>…>Mem n .

[0065] As available memory on the server decreases, the response time of the target application gradually increases. The response time of the target application is recorded at each stress level as t1, t2, t3, ... t n t1<t2<t3<…<t n .

[0066] At each stress level, we can obtain the available memory of a server and the response time of a target application. In other words, there is a one-to-one correspondence between the available memory of the server and the response time of the target application.

[0067] Step S103: Determine whether the response time exceeds the preset response time.

[0068] This application does not impose a limit on the preset response time; it depends on the circumstances.

[0069] Step S104: If the target response time exceeds the preset response time, then the target available memory is determined to be the minimum memory required for the target application to run.

[0070] Wherein, the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the previous response time.

[0071] For response times t1, t2, t3, ... t n Assuming from t x Initial response time t x t x+1 t x+2 、…、t n All are greater than the preset response time, i.e., t x t x+1 t x+2 、…、t n Corresponding available memory Mem x Mem x+1 Mem x+2 ... Mem n Insufficient to meet the normal operation requirements of the target application, t1, t2, ..., t x-1 All are less than or equal to the preset response time, t1, t2, ..., t x-1 The corresponding available memory Mem1, Mem2, ..., Mem x-1 If this satisfies the normal operation of the target application, then t x The target response time is given by the target available memory (i.e., minimum memory) in Mem. x-1 .

[0072] Understandably, when the target response time does not exceed the preset response time, it indicates that the target application is running normally and will not experience any lag, thus requiring no memory compensation.

[0073] Step S105: Allocate the minimum memory to the target application so that the target application can run normally.

[0074] In this step, the target application can run alone on the server, or it can run together with other applications. This application allocates the minimum available memory to the target application to minimize the impact on the operation of other applications.

[0075] In this embodiment, the server's memory is gradually pressured using chaosblade, causing the available memory to decrease and the target application's response time to gradually increase. The available memory and the target application's response time are recorded under each pressure level. When the response time is less than a preset response time, the target application cannot run normally, resulting in lag. The response time preceding the target application's response time is then considered the normal response time for the target application. Correspondingly, the available memory on the server at this point is the minimum memory required for the target application to run. Therefore, the minimum memory is allocated to the target application during its operation to ensure its normal operation, avoid lag, and minimize impact on other applications on the server.

[0076] Please refer to Figure 2 Based on the above embodiments, in one embodiment of this application, the application runtime management method includes:

[0077] Step S201: When the target application is running alone on the server, gradually apply pressure to the server's memory using chaosblade.

[0078] Step S202: Record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure.

[0079] Step S203: Determine whether the response time exceeds the preset response time.

[0080] Step S204: If the target response time exceeds the preset response time, then the target available memory is determined to be the minimum memory required for the target application to run.

[0081] Wherein, the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the previous response time.

[0082] Step S205: Obtain the memory currently used by the target application on the server.

[0083] Step S206: Determine the compensation memory required by the target application based on the minimum memory and the currently used memory.

[0084] Compensation memory is the difference between the minimum required memory and the currently used memory. For example, assuming the target application requires a minimum of 5GB of memory to run on the server, and the server is currently using 3GB of memory, then the target application requires 2GB of compensation memory.

[0085] Step S207: Compensate the target application with the compensated memory.

[0086] It should be noted that steps S201, S202, S203, and S204 in this embodiment are described in the above embodiment and will not be repeated in detail here.

[0087] In this embodiment, by determining the difference between the memory currently used by the target application on the server and the minimum memory, the required compensation memory is provided to the target application, thereby ensuring that the memory occupied by the target application on the server reaches the minimum memory, so as to ensure that the target application runs normally and does not lag.

[0088] When the free memory in the server is not less than the compensation memory, please refer to... Figure 3 Based on the above embodiments, in one embodiment of this application, the application runtime management method includes:

[0089] Step S301: When the target application is running alone on the server, gradually apply pressure to the server's memory using chaosblade.

[0090] Step S302: Record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure.

[0091] Step S303: Determine whether the response time exceeds the preset response time.

[0092] Step S304: If the target response time exceeds the preset response time, then the target available memory is determined to be the minimum memory required for the target application to run.

[0093] Wherein, the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the previous response time.

[0094] Step S305: Obtain the memory currently used by the target application on the server.

[0095] Step S306: Determine the compensation memory required by the target application based on the minimum memory and the currently used memory.

[0096] Step S307: Create virtual memory using the mmap function, and adjust the virtual memory using the brk and sbrk functions so that the adjusted virtual memory is equal to the compensated memory.

[0097] The mmap function maps a file to a process's virtual memory space. By reading from and modifying this memory, files can be read and modified without using the read and write functions.

[0098] It's important to note that the `mmap` function creates virtual memory equal to the difference between the initial memory used by the target application on the server and the minimum memory required for normal operation. As the target application runs, the memory used on the server may change; it may be less or more than the initial memory used. Therefore, the `brk` and `sbrk` functions are used to adjust the size of the virtual memory created by `mmap` to ensure that the adjusted virtual memory always equals the compensated memory. This prevents situations where the target application runs out of memory or uses more memory than the minimum required for normal operation after memory compensation.

[0099] In this step, the brk and sbrk functions are used to adjust the size of the virtual memory created by the mmap function, so that the virtual memory only needs to be created once. This avoids the need to use the munmap function to cancel the previously created virtual memory and then use the mmap function to create a new virtual memory when the memory used by the target application changes during its operation.

[0100] Step S308: Allocate memory from the free memory equal to the adjusted virtual memory to the target application.

[0101] It should be noted that steps S301, S302, S303, S304, S305, and S306 in this embodiment are the same as those in the above embodiment and will not be described in detail here.

[0102] This embodiment uses a memory allocation strategy for dynamic memory partitioning. When the free memory in the server exceeds the adjusted virtual memory, this embodiment allocates a portion of the free memory in the server to the target application. This ensures the normal operation of the target application without adversely affecting other applications running on the server.

[0103] When the free memory in the server is less than the compensation memory, please refer to... Figure 4 Based on the above embodiments, in one embodiment of this application, the application runtime management method includes:

[0104] Step S401: When the target application is running alone on the server, gradually apply pressure to the server's memory using chaosblade.

[0105] Step S402: Record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure.

[0106] Step S403: Determine whether the response time exceeds the preset response time.

[0107] Step S404: If the target response time exceeds the preset response time, then determine the target available memory as the minimum memory required for the target application to run.

[0108] Wherein, the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the previous response time.

[0109] Step S405: Obtain the memory currently used by the target application on the server.

[0110] Step S406: Determine the compensation memory required by the target application based on the minimum memory and the currently used memory.

[0111] Step S407: Create virtual memory using the mmap function, wherein the virtual memory is less than or equal to the free memory.

[0112] Step S408: Terminate applications running on the server with a priority lower than the target application to release memory in the server. The released memory shall not be less than the difference between the compensated memory and the virtual memory.

[0113] Optionally, as one possible implementation, when terminating other applications with lower priority than the target application, any application can be selected to be terminated.

[0114] Alternatively, as another possible implementation, terminating applications running on the server with a lower priority than the target application includes:

[0115] Step S1: Select the application with the lowest running priority as the application to be released, and determine whether the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory;

[0116] Step S2: If the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory, then terminate the application to be released in the server;

[0117] Step S3: If the memory occupied by the application to be released is less than the difference between the compensation memory and the virtual memory, then add the application with the lowest running priority among the remaining running programs to the application to be released, resulting in a new application to be released, and proceed to step S1 until the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory.

[0118] Assuming applications are ordered from lowest to highest priority, denoted as Application A, Application B, Application C, ..., and the memory released upon termination of each application is denoted as M1, M2, M3, ..., the process begins by determining if the memory released when terminating Application A is not less than the difference between the compensated memory and virtual memory. If so, only Application A is terminated. Otherwise, the process checks if the sum of the released memory (M1 and M2) when terminating Application A and Application B is not less than the difference between the compensated memory and virtual memory. If so, both Application A and Application B are terminated. If not, the process continues, checking if the sum of the released memory (M1, M2, and M3) when terminating Application A, Application B, and Application C is not less than the difference between the compensated memory and virtual memory, and so on, until the released memory is greater than or equal to the difference between the compensated memory and virtual memory.

[0119] Optionally, before terminating applications running on the server with a lower priority than the target application, the method further includes:

[0120] Obtain the PID (Process Identification Number) of all applications on the server;

[0121] The memory usage of the corresponding application is determined based on the PID number.

[0122] To obtain the application's PID, the command is: `ps -ef|grep service process name`; to determine the memory usage of the application based on the PID, the command is: `top -p PID_number`; to terminate the application, the command is: `kill -9 PID_number`.

[0123] Optionally, before step S408, the method further includes:

[0124] Identify all applications running on the server;

[0125] The running priority of each application is determined according to preset rules.

[0126] Preset rules can be set independently; this application does not impose any restrictions. The main point to note is that when determining execution priorities, the dependencies between applications must be considered. For example, if application M requires application N to run, then application N must have a higher execution priority than application M.

[0127] Step S409: Allocate memory equal to the virtual memory in the free memory and free memory to the target application.

[0128] Assuming the target application requires a minimum of 5GB of memory to run on the server, and the server is currently using 3GB of memory, the target application needs 2GB of compensation memory. With 1GB of free memory and 1GB of virtual memory, the memory released by closing other applications will be at least 1GB. Therefore, the 1GB of free memory and the released memory will be used to compensate the target application.

[0129] It should be noted that steps S401, S402, S403, S404, S405, and S406 in this embodiment are the same as those in the above embodiments, and will not be described in detail here.

[0130] This embodiment dynamically allocates memory based on application execution priority and memory allocation strategy. When free memory is insufficient to compensate for the target application's memory requirements, this embodiment allocates free memory to the target application. The remaining memory shortage for the target application is compensated by terminating applications with lower execution priority, thus minimizing the impact on the application.

[0131] Based on any of the above embodiments, in one embodiment of this application, before obtaining the memory currently used by the target application in the server, the method further includes:

[0132] Obtain the current response time of the target application during runtime;

[0133] Determine whether the current response time exceeds the preset response time;

[0134] If the current response time exceeds the preset response time, then the step of obtaining the memory currently used by the target application on the server is executed.

[0135] If the current response time does not exceed the preset response time, it indicates that the target application is running normally and no additional memory compensation is required.

[0136] In this application, the response time of the target application is used to determine whether the target application is running normally or experiencing lag.

[0137] The application running management device provided in the embodiments of this application is described below. The application running management device described below can be referred to in correspondence with the application running management method described above.

[0138] Figure 5 The structural block diagram of the application runtime management device provided in the embodiments of this application is shown below. Figure 5 Application runtime management devices may include:

[0139] The stress application module 100 is used to gradually apply stress to the server's memory via chaosblade when the target application is running alone on the server.

[0140] The recording module 200 is used to record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure;

[0141] The first judgment module 300 is used to determine whether the response time exceeds a preset response time;

[0142] The first determining module 400 is used to determine the target available memory as the minimum memory required for the target application to run if the target response time exceeds the preset response time; the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the response time preceding the target response time.

[0143] The allocation module 500 is used to allocate the minimum memory to the target application so that the target application can run normally.

[0144] The application running management device of this embodiment is used to implement the aforementioned application running management method. Therefore, the specific implementation of the application running management device can be found in the embodiment section of the application running management method above. For example, the pressure application module 100, the recording module 200, the first judgment module 300, the first determination module 400, and the allocation module 500 are respectively used to implement steps S101, S102, S103, S104, and S105 in the above application running management method. Therefore, its specific implementation can be referred to the description of the corresponding embodiments, which will not be repeated here.

[0145] In this embodiment, the application runtime management device gradually applies pressure to the server's memory using chaosblade, causing the available memory on the server to gradually decrease and the response time of the target application to gradually increase. It records the available memory on the server and the response time of the target application under each pressure level. When the response time is less than a preset response time, the target application cannot run normally, resulting in lag. The response time preceding the target response time is then considered the normal response time for the target application. Correspondingly, the available memory on the server at this point is the minimum memory required for the target application to run. Therefore, the minimum memory is allocated to the target application during its runtime to ensure its normal operation, avoid lag, and minimize impact on the operation of other applications on the server.

[0146] Optionally, the allocation module 500 includes:

[0147] The acquisition unit is used to acquire the memory currently used by the target application on the server;

[0148] The determining unit is configured to determine the compensation memory required by the target application based on the minimum memory and the currently used memory;

[0149] The compensation unit is used to compensate the target application for the compensation memory.

[0150] Optionally, when the free memory in the server is not less than the compensation memory, the compensation unit includes:

[0151] Create and adjust sub-units for creating virtual memory via the mmap function and adjusting the virtual memory via the brk and sbrk functions so that the adjusted virtual memory is equal to the compensated memory;

[0152] The first allocation subunit is used to allocate memory in the free memory that is equal to the adjusted virtual memory to the target application.

[0153] Optionally, when the free memory in the server is less than the compensation memory, the compensation unit includes:

[0154] Create a sub-unit for creating virtual memory using the mmap function, wherein the virtual memory is less than or equal to the free memory;

[0155] The release subunit is used to terminate applications running on the server with a priority lower than the target application, so as to release memory in the server. The released memory is not less than the difference between the compensation memory and the virtual memory.

[0156] The second allocation subunit is used to allocate memory equal to the virtual memory in the free memory and freed memory to the target application.

[0157] Optionally, the release subunit includes:

[0158] The judgment unit is used to execute step S1: the application with the lowest running priority is taken as the application to be released, and it is determined whether the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory;

[0159] The sub-unit ends, and step S2 is executed: if the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory, then the application to be released in the server is terminated;

[0160] Repeat the sub-unit process for step S3: If the memory occupied by the application to be released is less than the difference between the compensation memory and the virtual memory, then add the application with the lowest running priority among the remaining running programs to the application to be released, resulting in a new application to be released, and proceed to step S1 until the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory.

[0161] Optional, also includes:

[0162] The first acquisition module is used to acquire the PID number of all applications in the server;

[0163] The second determining module is used to determine the memory occupied by the corresponding application based on the PID number.

[0164] Optional, also includes:

[0165] The second acquisition module is used to acquire the current response time of the target application during runtime;

[0166] The second judgment module is used to determine whether the current response time exceeds the preset response time;

[0167] An execution module is configured to, if the current response time exceeds the preset response time, execute the step of obtaining the memory currently used by the target application in the server.

[0168] The electronic device provided in the embodiments of this application is described below. The electronic device described below can be referred to in correspondence with the application operation management method described above.

[0169] This application provides an electronic device; please refer to [reference needed]. Figure 6 ,include:

[0170] Memory 11 is used to store computer programs;

[0171] The processor 12 is configured to implement the steps of the application program operation management method described in any of the above embodiments when executing the computer program.

[0172] The following describes the computer-readable storage medium provided in the embodiments of this application. The computer-readable storage medium described below can be referred to in correspondence with the application operation management method described above.

[0173] This application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the application program operation management method described in any of the above embodiments.

[0174] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0175] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0176] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0177] The application operation management method, apparatus, electronic device, and computer-readable storage medium provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. An application runtime management method, characterized in that, include: When the target application runs alone on the server, chaosblade gradually puts pressure on the server's memory. Record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure; Determine whether the response time exceeds the preset response time; If the target response time exceeds the preset response time, then the target available memory is determined to be the minimum memory required for the target application to run; the target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the response time preceding the target response time; Allocate the minimum memory to the target application so that the target application can run normally.

2. The application runtime management method as described in claim 1, characterized in that, Allocating the minimum memory to the target application includes: Obtain the memory currently used by the target application on the server; Based on the minimum memory and the currently used memory, determine the compensation memory required by the target application; The compensated memory is then allocated to the target application.

3. The application runtime management method as described in claim 2, characterized in that, When the free memory in the server is not less than the compensation memory, compensating the target application with the compensation memory includes: Virtual memory is created using the mmap function, and the virtual memory is adjusted using the brk and sbrk functions so that the adjusted virtual memory is equal to the compensation memory. Allocate memory from the free memory equal to the adjusted virtual memory to the target application.

4. The application runtime management method as described in claim 2, characterized in that, When the free memory in the server is less than the compensation memory, compensating the target application with the compensation memory includes: Virtual memory is created using the mmap function, where the virtual memory is less than or equal to the free memory. Terminate applications running on the server with a priority lower than the target application to free up memory on the server. The freed memory shall not be less than the difference between the compensated memory and the virtual memory. Allocate memory equal to the virtual memory from the free memory and free up memory to the target application.

5. The application runtime management method as described in claim 4, characterized in that, Terminating applications running on the server with a lower priority than the target application includes: Step S1: Select the application with the lowest running priority as the application to be released, and determine whether the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory; Step S2: If the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory, then terminate the application to be released in the server; Step S3: If the memory occupied by the application to be released is less than the difference between the compensation memory and the virtual memory, then add the application with the lowest running priority among the remaining running programs to the application to be released, resulting in a new application to be released, and proceed to step S1 until the memory occupied by the application to be released is not less than the difference between the compensation memory and the virtual memory.

6. The application runtime management method as described in claim 4, characterized in that, Before terminating applications running on the server with a lower priority than the target application, the process also includes: Obtain the PID numbers of all applications on the server; The memory usage of the corresponding application is determined based on the PID number.

7. The application runtime management method as described in claim 2, characterized in that, Before obtaining the memory currently used by the target application on the server, the method further includes: Obtain the current response time of the target application during runtime; Determine whether the current response time exceeds the preset response time; If the current response time exceeds the preset response time, then the step of obtaining the memory currently used by the target application on the server is executed.

8. An application runtime management device, characterized in that, include: The stress module is used to gradually apply pressure to the server's memory via chaosblade when the target application is running alone on the server. A recording module is used to record the available memory of the server corresponding to the pressure, and the response time of the target application corresponding to the pressure; The first judgment module is used to determine whether the response time exceeds a preset response time; The first determining module is used to determine the target available memory as the minimum memory required for the target application to run if the target response time exceeds the preset response time. The target response time is the shortest response time that exceeds the preset response time, and the target available memory is the available memory corresponding to the previous response time. An allocation module is used to allocate the minimum memory to the target application so that the target application can run normally.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for implementing the steps of the application runtime management method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the application program runtime management method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Memory management method and apparatus, electronic device and computer-readable medium

    CN114096953A

  • Memory management method and device, computer equipment and storage medium

    CN115629877A