Memory processing method, device, electronic device and computer-readable storage medium
By obtaining and updating the memory data of the target application, predicting the memory required for startup, and performing memory recovery operations, it solves the problem of lag caused by excessive memory usage when the application starts, and realizes efficient management of memory resources.
Patent Information
- Application Number
- CN202210038316.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-13
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2042-01-13
AI Technical Summary
When the application starts, the electronic device is stuck due to excessive memory usage.
By obtaining the target memory table of the current memory value and historical memory value at the start of the target application, calculate the target average value, and update the memory table based on the current memory value, predicting the memory value required for the next startup. If the predicted memory value exceeds the remaining memory value, a memory recovery operation is performed to ensure sufficient memory.
It effectively avoids lag when the application starts and ensures the rational allocation and utilization of memory resources.
Smart Images

Figure CN114490432B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a memory processing method, apparatus, electronic device, and computer-readable storage medium. Background Art
[0002] With the development of science and technology, there are more and more applications, and the applications downloaded on electronic devices are also increasing.
[0003] When an application is launched, it will occupy the memory of the electronic device. If the memory occupied by the application is greater than the remaining memory of the electronic device, the application will start slowly, resulting in a lag phenomenon. Summary of the Invention
[0004] Embodiments of this application provide a memory processing method, apparatus, electronic device, and computer-readable storage medium, which can solve the technical problem of lag when an application is launched.
[0005] A memory processing method includes:
[0006] Obtaining a current memory value occupied when a target application is launched in an electronic device and a target memory table, where the target memory table includes a preset number of historical memory values;
[0007] Determining a target average value of the historical memory values in the target memory table;
[0008] If the target average value is less than or equal to the current memory value, updating the target memory table according to the current memory value to obtain an updated target memory table;
[0009] Predicting a predicted memory value required when the target application is launched next time according to the historical memory values in the updated target memory table;
[0010] If the predicted memory value is greater than the remaining memory value of the electronic device, performing a memory recycling operation to obtain an updated remaining memory value, where the updated remaining memory value is greater than or equal to the predicted memory value.
[0011] Correspondingly, embodiments of this application provide a memory processing apparatus, including:
[0012] An obtaining module, configured to obtain a current memory value occupied when a target application is launched in an electronic device and a target memory table, where the target memory table includes a preset number of historical memory values;
[0013] A determining module, configured to determine a target average value of the historical memory values in the target memory table;
[0014] An update module, configured to update the target memory table according to the current memory value to obtain an updated target memory table if the target average value is less than or equal to the current memory value;
[0015] A prediction module, configured to predict a predicted memory value required when the target application is started next time according to historical memory values in the updated target memory table;
[0016] A recycling module, configured to perform a memory recycling operation to obtain an updated remaining memory value if the predicted memory value is greater than the remaining memory value of the electronic device, and the updated remaining memory value is greater than or equal to the predicted memory value.
[0017] In addition, an embodiment of the present application further provides an electronic device, including a processor and a memory. The memory stores a computer program, and the processor is configured to run the computer program in the memory to implement the memory processing method provided by the embodiment of the present application.
[0018] In addition, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute any memory processing method provided by the embodiment of the present application.
[0019] In addition, an embodiment of the present application further provides a computer program product, including a computer program, and the computer program implements any memory processing method provided by the embodiment of the present application when being executed by a processor.
[0020] In the embodiment of the present application, first, a current memory value and a target memory table occupied when a target application is started in an electronic device are obtained. The target memory table includes a preset number of historical memory values. Then, a target average value of the historical memory values in the target memory table is determined. If the target average value is less than or equal to the current memory value, the target memory table is updated according to the current memory value to obtain an updated target memory table. Then, a predicted memory value required when the target application is started next time is predicted according to the historical memory values in the updated target memory table. If the predicted memory value is greater than the remaining memory value of the electronic device, a memory recycling operation is performed to obtain an updated remaining memory value, and the updated remaining memory value is greater than the predicted memory value.
[0021] That is, in the embodiments of the present application, if the target average value is less than or equal to the current memory value, the target memory table is updated according to the current memory value to obtain an updated target memory table, and then, according to the historical memory values in the updated target memory table, the predicted memory value required for the next startup of the target application is predicted. If the predicted memory value is greater than the remaining memory value of the electronic device, a memory recycling operation is performed to obtain an updated remaining memory value, such that the updated remaining memory value is greater than the predicted memory value, so that when the target application is started next time, the updated remaining memory value is sufficient for the target application to use, thereby avoiding the occurrence of lagging phenomena. Description of the Drawings
[0022] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0023] Figure 1 is a schematic flowchart of an image processing method provided by an embodiment of the present application;
[0024] Figure 2 is a schematic diagram of a method for determining a target average value provided by an embodiment of the present application;
[0025] Figure 3 is a schematic diagram of a method for updating a target memory table provided by an embodiment of the present application;
[0026] Figure 4 is a schematic diagram of a method for predicting a predicted memory value provided by an embodiment of the present application;
[0027] Figure 5 is a schematic diagram of a framework provided by an embodiment of the present application;
[0028] Figure 6 is a schematic structural diagram of a memory processing device provided by an embodiment of the present application;
[0029] Figure 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments
[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the scope of protection of the present application.
[0031] An embodiment of the present application provides a memory processing method, apparatus, electronic device, and computer-readable storage medium. Among them, the memory processing apparatus can be integrated in the electronic device, and the electronic device can be a server or a terminal device, etc.
[0032] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and big data and artificial intelligence platforms.
[0033] The terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and the present application does not make any restrictions here.
[0034] In addition, "multiple" in the embodiments of the present application refers to two or more. "First" and "second" in the embodiments of the present application are used for distinguishing descriptions and cannot be understood as implying relative importance.
[0035] The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0036] In this embodiment, the description will be made from the perspective of the memory processing apparatus. The memory processing apparatus can be specifically integrated in devices such as servers or terminals. For the convenience of explaining the memory processing method of the present application, the following will take the memory processing apparatus integrated in the terminal as an example for detailed description, that is, the terminal will be used as the execution subject for detailed description.
[0037] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of the memory processing method provided by an embodiment of the present application. The memory processing method may include:
[0038] S101. Obtain the current memory value occupied when the target application starts in the electronic device and the target memory table, where the target memory table includes a preset number of historical memory values.
[0039] There is a corresponding memory table for each application program, and each memory table includes a preset number of historical memory values occupied each time the application program starts.
[0040] The current memory value is the memory value occupied by the target application when it was last started. The terminal can obtain the current memory value and the target memory table of the target application in the terminal when the target application was last started.
[0041] Alternatively, the terminal can also predict the target time for the next startup of the target application based on the historical usage time of the target application, and then obtain the current memory value and the target memory table of the target application in the terminal within a specified time period before the target time.
[0042] The preset quantity can be set according to the actual situation, and is not limited herein in this embodiment.
[0043] S102. Determine the target average value of the historical memory values in the target memory table.
[0044] Among them, referring to Figure 2 , the process by which the terminal determines the target average value of the historical average values in the target memory table can be:
[0045] The terminal determines the number of historical memory values in the target memory table. If the number of historical memory values in the target memory table is equal to the first preset threshold, the first M historical memory values and the last M historical memory values in the target memory table are deleted to obtain a first memory table, where M is an integer;
[0046] Take the average value of the historical memory values in the first memory table as the target average value.
[0047] The first preset threshold is the capacity of the target memory table, that is, the maximum number of historical memory values that the target memory table can store. The first preset threshold can be selected according to the actual situation. For example, the first preset threshold can be set to 60, and is not limited herein in this embodiment.
[0048] M can be selected according to the actual situation. For example, M can be set to 10, and is not specifically limited herein in this embodiment.
[0049] In this embodiment, when the number of historical memory values in the target memory table is equal to the first preset threshold, the first M historical memory values and the last M historical memory values in the target memory table are deleted to obtain a first memory table, and then the average value of the historical memory values in the first memory table is used as the target average value, so that the target average value is more accurate.
[0050] If the number of historical memory values in the target memory table belongs to a preset threshold range, the first K historical memory values and the last K historical memory values in the target memory table are deleted to obtain a second memory table, where K is less than M and K is an integer;
[0051] Take the average value of the historical memory values in the second memory table as the target average value.
[0052] The preset threshold interval and K can be selected according to the actual situation. For example, the preset threshold interval can be set as the open interval (5, 60), and K can be set as 1. This embodiment does not make any limitations here.
[0053] If the number of historical memory values in the target memory table is less than or equal to the second preset threshold, the average value of the historical memory values in the target memory table is used as the target average value.
[0054] The second preset threshold can be selected according to the actual situation. For example, the second preset threshold can be set as 5. This embodiment does not make any limitations here.
[0055] In this embodiment, the number of historical memory values to be deleted is determined by the number of historical memory values in the target memory table, so that the obtained target average value is more accurate.
[0056] S103. If the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain the updated target memory table.
[0057] Since when the target average value is less than or equal to the current memory value, the predicted memory value obtained according to the target average value may be inaccurate. Therefore, if the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain the updated target memory table, so that the predicted memory value obtained according to the updated target memory table is more accurate.
[0058] If the target average value is less than or equal to the current memory value, the terminal can directly store the current memory value into the target memory table to obtain the updated target memory table.
[0059] Alternatively, if the target average value is less than or equal to the current memory value, the terminal can also insert the current memory value into the target memory table to obtain a candidate target memory table. Then the terminal checks the number of historical memory values in the candidate target memory table. If the number of historical memory values in the candidate target memory table is greater than the preset threshold, delete the smallest or largest historical memory value in the candidate target memory table to obtain the updated target memory table. If the number of historical memory values in the candidate target memory table is less than or equal to the preset threshold, use the candidate target memory table as the updated target memory table.
[0060] In this embodiment, if the number of historical memory values in the candidate target memory table is greater than the preset threshold, the smallest or largest historical memory value in the candidate target memory table is deleted to obtain the updated target memory table. If the number of historical memory values in the candidate target memory table is less than or equal to the preset threshold, the candidate target memory table is used as the updated target memory table, so that the number of historical memory values in the updated memory table does not exceed the preset threshold, thereby making the difference between the number of historical memory values in the target memory table and the number of historical memory values in the updated target memory table within the preset range, and further making the predicted memory value predicted according to the updated target memory table more accurate.
[0061] Among them, referring to Figure 3 , if the number of historical memory values in the candidate target memory table is greater than the preset threshold, the process of deleting the smallest or largest historical memory value in the candidate target memory table is as follows:
[0062] Determine the number of historical memory values in the candidate target memory table;
[0063] If the number of historical memory values in the candidate target memory table is greater than the preset threshold and the preset flag bit is the first target value, delete the smallest historical memory value in the candidate target memory table to obtain the updated target memory table, and modify the preset flag bit to the second target value;
[0064] If the number of historical memory values in the candidate target memory table is greater than the preset threshold and the preset flag bit is the second target value, delete the largest historical memory value in the candidate target memory table to obtain the updated target memory table, and modify the preset flag bit to the first target value.
[0065] In this embodiment, the largest and smallest historical memory values in the candidate target memory table are alternately deleted, so that the predicted memory value predicted according to the updated target memory table is more accurate.
[0066] The first target value and the second target value can be set according to the actual situation. For example, the first target value can be set to 1 and the second target value can be set to 0.
[0067] It should be noted that after the terminal obtains the updated target memory table, it stores the updated target memory table for use when predicting the predicted memory value required for the next startup of the target application.
[0068] If the target average value is greater than the current memory value, the terminal uses the target average value as the predicted memory value required for the next startup of the target application.
[0069] S104. Predict the predicted memory value required for the next startup of the target application according to the historical memory values in the updated target memory table.
[0070] After obtaining the updated target memory table, the terminal can fit the historical memory values in the updated target memory table to obtain a target curve, and then find the predicted memory value required for the next startup of the target application from the target curve.
[0071] Alternatively, after obtaining the updated target memory table, the terminal uses the historical memory value in the updated target memory table that is greater than the current memory value as the predicted memory value required when the target application is started next time, thereby ensuring that the predicted memory value is greater than the memory value actually required to be occupied by the target application when it is started next time.
[0072] In this embodiment, if the target average value is equal to or greater than the current memory value, the target average value is used as the predicted memory value. If the target average value is less than the current memory value, the historical memory value greater than the current memory value is used as the predicted memory value, thereby ensuring that the predicted memory value is sufficient to be used when the target application is started next time.
[0073] In some embodiments, the historical memory values in the updated target memory table are stored in ascending order in the updated target memory table, and the historical memory values in the updated target memory table that are greater than the current memory value are used as the predicted memory values required when the target application is started next time, including:
[0074] The Nth historical memory value after the current memory value in the updated target memory table is used as the predicted memory value required when the target application is started next time, where N is an integer.
[0075] In this embodiment, the Nth historical memory value after the current memory value in the updated target memory table is used as the predicted memory value required when the target application is started next time. For example, N is three, that is, the third historical memory value after the current memory value is used as the predicted memory value required when the target application is started next time, thereby ensuring that the predicted memory value is sufficient to be used when the target application is started next time, and at the same time ensuring that the difference between the predicted memory value and the memory value actually required to be occupied when the target application is started next time is within a preset range, thereby ensuring that a large number of memory values will not be idle.
[0076] In other embodiments, referring to Figure 4 , the Nth historical memory value after the current memory value in the updated target memory table is used as the predicted memory value required for the next startup of the target application, where N is an integer. Including:
[0077] If the updated target memory table contains the Nth historical memory value after the current memory value, the Nth historical memory value after the current memory value in the updated target memory table is used as the predicted memory value required when the target application is started next time, where N is an integer;
[0078] If the Nth historical memory value after the current memory value is not included in the target memory table after the update, obtain a preset memory value and use the preset memory value as the predicted memory value required when the target application is started next time.
[0079] The preset memory value can be set according to the actual situation. For example, the preset memory value can be set to 18 * 4 * 1024 kb. In this embodiment, if the target memory table after the update contains the Nth historical memory value after the current memory value, the Nth historical memory value is used as the predicted memory value; if the Nth historical memory value after the current memory value is not included in the target memory table after the update, the preset memory value is used as the predicted memory value required when the target application is started next time, so as to ensure that the predicted memory value is sufficient for use when the target application is started next time.
[0080] S105. If the predicted memory value is greater than the remaining memory value of the electronic device, perform a memory recycling operation to obtain an updated remaining memory value, and the updated remaining memory value is greater than or equal to the predicted memory value.
[0081] If the terminal obtains the current memory value occupied by the target application in the terminal and the target memory table within a specified time period before the target time, after the terminal obtains the predicted memory value, if the predicted memory value is greater than the remaining memory value of the electronic device, a memory recycling operation can be directly performed.
[0082] If the terminal obtains the current memory value occupied by the target application in the terminal and the target memory table when the target application is started for the last time, the terminal can compare the predicted memory value with the remaining memory value again within a specified time period before the target time. If the predicted memory value is greater than the remaining memory value of the electronic device, a memory recycling operation is performed again.
[0083] The following refers to Figure 5 , and a framework diagram for the terminal to execute the above steps is described.
[0084] The terminal includes a memory management assistance module MemoryInfoManager, a current memory value acquisition module PackageRecord, a recycling and cleaning module AbstractStrategy, and a collection module AppRecord.
[0085] Among them, the memory management assistance module is used to predict the predicted memory value required when the target application is started next time. It includes a memory table recording unit addPss and a calculation unit getPredictSize. The memory table recording unit is used to store the target memory table, and the calculation unit is used to calculate the target average value of the historical memory values in the target memory table and calculate the predicted memory value according to the target average value and the current memory value.
[0086] The current memory value acquisition module is used to acquire the current memory value of the target application. The recycling and cleaning module is used to calculate the memory that needs to be recycled according to the predicted memory value. The collection module is used to collect the historical memory values of the target application and send the historical memory values to the memory management assistance module.
[0087] As can be seen from the above, in the embodiment of the present application, first, the current memory value occupied when the target application is started in the electronic device and the target memory table are acquired. The target memory table includes a preset number of historical memory values. Then, the target average value of the historical memory values in the target memory table is determined. If the target average value is less than or equal to the current memory value, the target memory table is updated according to the current memory value to obtain the updated target memory table. Next, according to the historical memory values in the updated target memory table, the predicted memory value required when the target application is started next time is predicted. If the predicted memory value is greater than the remaining memory value of the electronic device, a memory recycling operation is performed to obtain the updated remaining memory value, and the updated remaining memory value is greater than the predicted memory value.
[0088] That is, in the embodiment of the present application, if the target average value is less than or equal to the current memory value, the target memory table is updated according to the current memory value to obtain the updated target memory table, and then, according to the historical memory values in the updated target memory table, the predicted memory value required when the target application is started next time is predicted. If the predicted memory value is greater than the remaining memory value of the electronic device, a memory recycling operation is performed to obtain the updated remaining memory value, so that the updated remaining memory value is greater than the predicted memory value, so that when the target application is started next time, the updated remaining memory value is sufficient for the target application to use, thereby avoiding the occurrence of lag phenomena.
[0089] To facilitate better implementation of the memory processing method provided by the embodiment of the present application, the embodiment of the present application also provides a device based on the above memory processing method. The meanings of the nouns are the same as those in the above memory processing method, and the specific implementation details can refer to the description in the method embodiment.
[0090] For example, as Figure 6 shown, the memory processing device may include:
[0091] An acquisition module 601, configured to acquire the current memory value occupied when the target application is started in the electronic device and the target memory table, where the target memory table includes a preset number of historical memory values;
[0092] A determination module 602, configured to determine the target average value of the historical memory values in the target memory table;
[0093] An update module 603, configured to update the target memory table according to the current memory value to obtain the updated target memory table if the target average value is less than or equal to the current memory value;
[0094] A prediction module 604, configured to predict a predicted memory value required when a target application is started next time according to historical memory values in an updated target memory table;
[0095] A recycling module 605, configured to perform a memory recycling operation to obtain an updated remaining memory value if the predicted memory value is greater than the remaining memory value of the electronic device, and the updated remaining memory value is greater than or equal to the predicted memory value.
[0096] Optionally, the prediction module 604 is specifically configured to execute:
[0097] Use the historical memory values greater than the current memory value in the updated target memory table as the predicted memory value required when the target application is started next time.
[0098] Optionally, the historical memory values in the updated target memory table are stored in the updated target memory table in ascending order.
[0099] Correspondingly, the prediction module 604 is specifically configured to execute:
[0100] Use the Nth historical memory value after the current memory value in the updated target memory table as the predicted memory value required when the target application is started next time, where N is an integer.
[0101] Optionally, the prediction module 604 is specifically configured to execute:
[0102] If the updated target memory table contains the Nth historical memory value after the current memory value, use the Nth historical memory value after the current memory value in the updated target memory table as the predicted memory value required when the target application is started next time, where N is an integer;
[0103] If the updated target memory table does not contain the Nth historical memory value after the current memory value, obtain a preset memory value and use the preset memory value as the predicted memory value required when the target application is started next time.
[0104] Optionally, the determination module 602 is specifically configured to execute:
[0105] If the number of historical memory values in the target memory table is equal to a first preset threshold, delete the first M historical memory values and the last M historical memory values in the target memory table to obtain a first memory table, where M is an integer;
[0106] Use the average value of the historical memory values in the first memory table as the target average value.
[0107] Optionally, the determination module 602 is specifically configured to execute:
[0108] If the number of historical memory values in the target memory table belongs to a preset threshold range, delete the first K historical memory values and the last K historical memory values in the target memory table to obtain a second memory table, where K is less than M and K is an integer;
[0109] Take the average value of the historical memory values in the second memory table as the target average value.
[0110] Optionally, the determination module 602 is specifically configured to execute:
[0111] If the number of historical memory values in the target memory table is less than or equal to a second preset threshold, take the average value of the historical memory values in the target memory table as the target average value.
[0112] Optionally, the update module 603 is specifically configured to execute:
[0113] If the target average value is less than or equal to the current memory value, insert the current memory value into the target memory table to obtain a candidate target memory table;
[0114] If the number of historical memory values in the candidate target memory table is greater than a preset threshold, delete the smallest historical memory value or the largest historical memory value in the candidate target memory table to obtain an updated target memory table;
[0115] If the number of historical memory values in the candidate target memory table is less than or equal to a preset threshold, use the candidate target memory table as the updated target memory table.
[0116] Optionally, the update module 603 is specifically configured to execute:
[0117] If the number of historical memory values in the candidate target memory table is greater than a preset threshold and the preset flag bit is a first target value, delete the smallest historical memory value in the candidate target memory table to obtain an updated target memory table, and modify the preset flag bit to a second target value;
[0118] If the number of historical memory values in the candidate target memory table is greater than a preset threshold and the preset flag bit is a second target value, delete the largest historical memory value in the candidate target memory table to obtain an updated target memory table, and modify the preset flag bit to a first target value.
[0119] In specific implementation, each of the above modules can be implemented as an independent entity, or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation manners of the above modules and the corresponding beneficial effects, reference can be made to the foregoing method embodiments, which will not be elaborated herein.
[0120] The embodiment of the present application further provides an electronic device, which can be a server or a terminal, etc. As Figure 7 shown, it shows a schematic structural diagram of the electronic device involved in the embodiment of the present application. Specifically:
[0121] The electronic device may include components such as a processor 701 with one or more processing cores, a memory 702 of one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art can understand that Figure 7 the structure of the electronic device shown in
[0122] does not limit the electronic device, and it may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. Among them:
[0123] The processor 701 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and circuits. By running or executing computer programs and / or modules stored in the memory 702, and by calling data stored in the memory 702, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 701 either.
[0124] The electronic device further includes a power supply 703 that supplies power to each component. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 703 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0125] The electronic device may further include an input unit 704, which may be configured to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0126] Although not shown, the electronic device may further include a display unit and the like, which will not be elaborated here. Specifically, in this embodiment, the processor 701 in the electronic device will load the executable files corresponding to the processes of one or more computer programs into the memory 702 according to the following instructions, and the processor 701 will run the computer programs stored in the memory 702 to implement various functions, such as:
[0127] Obtain the current memory value occupied when the target application program in the electronic device is started and the target memory table, where the target memory table includes a preset number of historical memory values;
[0128] Determine the target average value of the historical memory values in the target memory table;
[0129] If the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain the updated target memory table;
[0130] Predict the predicted memory value required when the target application program is started next time according to the historical memory values in the updated target memory table;
[0131] If the predicted memory value is greater than the remaining memory value of the electronic device, perform a memory recovery operation to obtain an updated remaining memory value, and the updated remaining memory value is greater than or equal to the predicted memory value.
[0132] For the specific implementation manners of the above operations and the corresponding beneficial effects, reference may be made to the detailed description of the image processing method above, which will not be elaborated here.
[0133] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by a computer program, or by controlling related hardware through a computer program. The computer program can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0134] Therefore, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any of the memory processing methods provided by the embodiments of the present application. For example, the computer program can execute the following steps:
[0135] Obtain the current memory value occupied when the target application program in the electronic device is started and the target memory table, where the target memory table includes a preset number of historical memory values;
[0136] Determine the target average value of the historical memory values in the target memory table;
[0137] If the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain an updated target memory table;
[0138] Predict the predicted memory value required when the target application is started next time according to the historical memory values in the updated target memory table;
[0139] If the predicted memory value is greater than the remaining memory value of the electronic device, perform a memory recovery operation to obtain an updated remaining memory value, and the updated remaining memory value is greater than or equal to the predicted memory value.
[0140] For the specific implementation manners of the above various operations and the corresponding beneficial effects, reference may be made to the previous embodiments, which will not be elaborated herein.
[0141] Among them, the computer-readable storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0142] Since the computer program stored in the computer-readable storage medium can execute the steps in any of the memory processing methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the memory processing methods provided in the embodiments of the present application can be realized. For details, reference may be made to the previous embodiments, which will not be elaborated herein.
[0143] Among them, according to an aspect of the present application, a computer program product or a computer program is provided. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above memory processing method.
[0144] The above has introduced in detail a memory processing method, device, electronic device and computer-readable storage medium provided by the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A memory processing method, characterized in that, it includes: Obtain the current memory value occupied when a target application starts in an electronic device and a target memory table, where the target memory table includes a preset number of historical memory values; Determine the target average value of the historical memory values in the target memory table; If the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain an updated target memory table; Predict the predicted memory value required when the target application starts next time according to the historical memory values in the updated target memory table, where the predicted memory value is greater than the current memory value; If the target average value is greater than the current memory value, use the target average value as the predicted memory value required when the target application starts next time; If the predicted memory value is greater than the remaining memory value of the electronic device, perform a memory recovery operation to obtain an updated remaining memory value, and the updated remaining memory value is greater than or equal to the predicted memory value.
2. The memory processing method according to claim 1, characterized in that, The predicting the predicted memory value required when the target application starts next time according to the historical memory values in the updated target memory table includes: Using the historical memory values in the updated target memory table that are greater than the current memory value as the predicted memory value required when the target application starts next time.
3. The memory processing method according to claim 2, characterized in that, The historical memory values in the updated target memory table are stored in the updated target memory table in ascending order; Correspondingly, the using the historical memory values in the updated target memory table that are greater than the current memory value as the predicted memory value required when the target application starts next time includes: Using the Nth historical memory value after the current memory value in the updated target memory table as the predicted memory value required when the target application starts next time, where N is an integer.
4. The memory processing method according to claim 3, characterized in that, The using the Nth historical memory value after the current memory value in the updated target memory table as the predicted memory value required when the target application starts next time, where N is an integer; includes: If the updated target memory table contains the Nth historical memory value after the current memory value, use the Nth historical memory value after the current memory value in the updated target memory table as the predicted memory value required when the target application starts next time, where N is an integer; If the updated target memory table does not contain the Nth historical memory value after the current memory value, obtain a preset memory value and use the preset memory value as the predicted memory value required when the target application starts next time.
5. The memory processing method according to claim 2, characterized in that, The determining the target average value of the historical memory values in the target memory table includes: If the number of historical memory values in the target memory table is equal to the first preset threshold, delete the first M historical memory values and the last M historical memory values in the target memory table to obtain a first memory table, where M is an integer; Use the average value of the historical memory values in the first memory table as the target average value.
6. The memory processing method according to claim 5, wherein, the determination of the target average value of the historical memory values in the target memory table includes: if the number of historical memory values in the target memory table belongs to a preset threshold range, delete the first K historical memory values and the last K historical memory values in the target memory table to obtain a second memory table, where K is less than M and K is an integer; Use the average value of the historical memory values in the second memory table as the target average value.
7. The memory processing method according to claim 6, wherein, the determination of the target average value of the historical memory values in the target memory table includes: if the number of historical memory values in the target memory table is less than or equal to a second preset threshold, use the average value of the historical memory values in the target memory table as the target average value.
8. The memory processing method according to claim 1, wherein, if the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain an updated target memory table; if the target average value is less than or equal to the current memory value, insert the current memory value into the target memory table to obtain a candidate target memory table; if the number of historical memory values in the candidate target memory table is greater than a preset threshold, delete the smallest historical memory value or the largest historical memory value in the candidate target memory table to obtain an updated target memory table; if the number of historical memory values in the candidate target memory table is less than or equal to the preset threshold, use the candidate target memory table as the updated target memory table.
9. The memory processing method according to claim 8, wherein, the step of if the number of historical memory values in the candidate target memory table is greater than a preset threshold, delete the smallest historical memory value or the largest historical memory value in the candidate target memory table to obtain an updated target memory table, includes: if the number of historical memory values in the candidate target memory table is greater than a preset threshold and the preset flag bit is the first target value, delete the smallest historical memory value in the candidate target memory table to obtain an updated target memory table, and modify the preset flag bit to the second target value; if the number of historical memory values in the candidate target memory table is greater than a preset threshold and the preset flag bit is the second target value, delete the largest historical memory value in the candidate target memory table to obtain an updated target memory table, and modify the preset flag bit to the first target value.
10. A memory processing device, wherein, it includes: an acquisition module, configured to acquire the current memory value and the target memory table occupied when a target application program in an electronic device is started, where the target memory table includes a preset number of historical memory values; a determination module, configured to determine the target average value of the historical memory values in the target memory table; an update module, configured to if the target average value is less than or equal to the current memory value, update the target memory table according to the current memory value to obtain an updated target memory table; A prediction module, configured to predict a predicted memory value required when the target application is started next time according to historical memory values in the updated target memory table, where the predicted memory value is greater than the current memory value, and the prediction module is further configured to use the target average value as the predicted memory value required when the target application is started next time when the target average value is greater than the current memory value; A recycling module, configured to perform a memory recycling operation to obtain an updated remaining memory value if the predicted memory value is greater than the remaining memory value of the electronic device, and the updated remaining memory value is greater than or equal to the predicted memory value.
11. An electronic device, characterized in that, it includes a processor and a memory, the memory stores a computer program, and the processor is configured to run the computer program in the memory to execute the memory processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, the computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the memory processing method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Method for starting application and terminal
CN106528216A
Memory optimization method and device, mobile terminal and storage medium
CN109656722A