Memory management method and device, electronic equipment and storage medium
By using memory access prediction models in electronic devices, predicting future memory access situations, the problem of low memory resource management efficiency in the existing technology is solved, more efficient memory management is achieved, and the response speed and performance of electronic devices are improved.
Patent Information
- Application Number
- CN202311258047.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2043-09-26
AI Technical Summary
Existing memory management technology cannot effectively predict future memory access situations when memory resources are tight, resulting in frequent access pages being unnecessarily replaced, increasing disk I/O overhead, and affecting the response speed of electronic devices.
The memory access prediction model is adopted to train the prediction model by obtaining historical memory access data, predicting future memory access situations, including the memory page to be accessed and access probability, thereby carrying out targeted memory management.
By predicting future memory access situations, memory management can be better carried out, unnecessary page replacement can be reduced, and the response speed and performance of electronic devices can be improved.
Smart Images

Figure CN119718602A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of memory management technology, and in particular to a memory management method, device, electronic device and storage medium. Background Art
[0002] Kswapd is a kernel thread in the Linux kernel, responsible for reclaiming memory when memory resources are tight. It mainly works by swapping out the least recently used memory pages to the hard disk to achieve memory management. Based on this, memory pages that are used less or not used in the time period before the current moment will be swapped out, for example, to the disk; but they may be used soon in the time period after the current moment. If the least recently used memory pages are swapped out according to the relevant technology, it will cause additional memory overhead, which may cause the response speed of the electronic device. Summary of the invention
[0003] The present application proposes a memory management method, device, electronic device and storage medium to better implement memory management.
[0004] In a first aspect, an embodiment of the present application provides a memory management method, which is applied to an electronic device, and the method includes: obtaining memory access data within a first time period; inputting the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information includes at least a memory page to be accessed and the access probability of the memory page being accessed within the second time period, and the memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods; and performing corresponding memory management according to the prediction information.
[0005] In the second aspect, an embodiment of the present application provides a memory management device, which is applied to an electronic device, and the device includes: an access data acquisition module, an access prediction module, and a memory management module. The access data acquisition module is used to acquire memory access data within a first time period; the access prediction module is used to input the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information includes at least a memory page to be accessed and the access probability of the memory page being accessed within the second time period, and the memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods; the memory management module is used to perform corresponding memory management according to the prediction information.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored. The program code can be called by a processor to execute the above method.
[0008] In the scheme provided by the present application, memory access data within a first time period is obtained; the memory access data is input into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, the second time period is located after the first time period, the prediction information at least includes the memory page to be accessed and the access probability of the memory page being accessed within the second time period, the memory access prediction model is obtained by training the initial prediction model based on the training sample set, and the training sample set includes historical memory access data within multiple historical time periods; the corresponding memory management is performed according to the prediction information. In this way, the memory access prediction model is used, and based on the memory access data of the previous period, the memory page to be accessed and the access probability of the memory page in the next period are predicted as the prediction information for the memory access in the next period, so that better memory management can be achieved based on the prediction information; and the memory access prediction model is obtained by pre-training based on the historical memory access data, which can improve the accuracy of the model's prediction to a certain extent, so that the model can be better used to optimize memory management, thereby improving the response speed and performance of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0010] Figure 1 A flowchart of a memory management method provided in an embodiment of the present application is shown.
[0011] Figure 2 A flowchart of a memory management method provided in an embodiment of the present application is shown.
[0012] Figure 3 A flowchart of a memory management method provided in an embodiment of the present application is shown.
[0013] Figure 4 It is a block diagram of a memory management device provided according to an embodiment of the present application.
[0014] Figure 5 It is a block diagram of an electronic device according to an embodiment of the present application for executing the memory management method according to an embodiment of the present application.
[0015] Figure 6 It is a storage unit of an embodiment of the present application for storing or carrying program codes for implementing the memory management method according to an embodiment of the present application. DETAILED DESCRIPTION
[0016] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0017] It should be noted that in some processes described in the specification, claims and the above-mentioned drawings of the present application, multiple operations that appear in a specific order are included, and these operations may not be executed or executed in parallel in the order in which they appear in this article. The sequence numbers of operations such as S110, S120, etc. are only used to distinguish different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or less operations, and these operations may be executed in sequence or in parallel. And, the terms "first", "second", etc. in the specification, claims and the above-mentioned drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or server that includes a series of steps or sub-modules is not necessarily limited to those steps or sub-modules explicitly listed, but may include other steps or sub-modules that are not explicitly listed or that are inherent to these processes, methods, products, or devices.
[0018] In the related art, the second chance algorithm is generally used to replace memory pages. However, this replacement algorithm cannot consider whether the page will be frequently accessed in the future, that is, the second chance algorithm only focuses on whether the memory page has been accessed, but not whether the memory page will be accessed in the future. Therefore, even if a page is frequently accessed, it may be replaced as long as its access bit is zero during the inspection. This may cause some frequently accessed pages to be replaced unnecessarily, thereby increasing the disk I / O overhead.
[0019] To solve the above problems, the inventor proposes a memory management method, device, electronic device and storage medium. The memory management method provided in the embodiment of the present application is described in detail below.
[0020] Please refer to Figure 1 , Figure 1 A flowchart of a memory management method provided in an embodiment of the present application is applied to an electronic device. Figure 1 The memory management method provided in the embodiment of the present application is described in detail. The memory management method may include the following steps:
[0021] Step S110: Acquire memory access data within a first time period.
[0022] In this embodiment, the electronic device may be an electronic terminal with a data processing function, including but not limited to a smart phone, a tablet computer, a laptop computer, a smart watch, and a sports bracelet. The first time period may be understood as a historical time period before the current time. For example, if the current time is 9:06, the first time period may be a time period corresponding to the five minutes from 9:01 to 9:05.
[0023] Optionally, the memory access data includes at least one of the following data: access time and access frequency of each accessed memory page, an application program accessing the memory page, and a data type of page data contained in the memory page.
[0024] Step S120: input the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information includes at least a memory page to be accessed and the access probability of the memory page being accessed within the second time period. The memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods.
[0025] Furthermore, the memory access data in the first time period can be input into a pre-trained memory access prediction model. Since the memory access prediction model is pre-trained using historical memory access data in multiple historical time periods, the model has learned the changing trend of memory access, that is, it can infer the prediction information of memory access in the next time period based on the historical memory access data in the previous time period. Therefore, the memory access prediction model can output the prediction information of memory access in the second time period, wherein the prediction information can at least include the memory page to be accessed and the access probability of the memory page to be accessed in the second time period. The second time period can be understood as the time period after the first time period.
[0026] Exemplarily, the first time period may be 9:01-9:05, and the second time period may be 9:06-9:10.
[0027] In some implementations, before step S120, the electronic device may pre-acquire a training sample set, and iteratively train the initial prediction model based on the training sample set until the model convergence condition is met, and then use the converged initial prediction model as the memory access prediction model in step S120. Considering that the electronic device consumes more power when performing model inference training, the model training in this manner may be performed while the electronic device is in a charging state, thereby avoiding the electronic device running out of power during the model training process, resulting in interruption of the model training and
[0028] Among them, the historical memory access data in each time period in the training sample set is used as a training sample, and the historical memory access data includes at least one of the following parameters: access frequency, access time, access order, access type, access program information, historical access mode, memory occupancy, system performance parameters, and performance indicators of key threads. The access frequency is used to characterize the number of times each memory page is accessed; the access time is used to characterize the time when each access to each memory page occurs; the access order is used to characterize the order in which the memory pages are accessed; the access type is used to characterize the access type of the memory, for example, read operation or write operation; the access program information is used to characterize the program information of the memory access, including the program identification, program type, etc.; the historical access mode is used to characterize the access mode in the past period of time; the memory occupancy is used to characterize the occupancy of each memory page; the system performance indicators may include CPU utilization, disk write rate, and read quantity, etc.; the performance indicators of key threads may include the number of frame drops, the main thread block duration, etc.
[0029] The model convergence condition may be: the training loss value of each round of unsupervised training is less than the preset value, the training loss value no longer changes, or the number of training times reaches the preset number, etc. It is understandable that after the initial prediction model is iteratively trained for multiple training cycles according to the training sample set, wherein each training cycle includes multiple iterative trainings, the parameters in the initial prediction model are continuously optimized, so that the above training loss value becomes smaller and smaller, and finally becomes a fixed value, or is less than the above preset value, at this time, it means that the initial prediction model has converged; of course, it can also be determined that the initial language model has converged after the number of training times reaches the preset number, at this time, the initial language model can be used as the above pre-training model. Among them, the preset value and the preset number of times are pre-set, and their values can also be adjusted according to different application scenarios, and this embodiment does not limit this.
[0030] Optionally, the initial prediction model can be a time series prediction model, such as an autoregressive model (AR model), a moving average model (MA model), an auto-regressive moving average model (ARMA model) and an autoregressive integrated moving average model (ARIMA model).
[0031] Of course, the initial prediction model can also be a machine learning model, a deep learning model or a Markov chain model. Among them, the machine learning model can include decision trees, support vector machines, neural networks, etc., all of which can predict future memory access conditions based on historical memory access data; deep learning models can include long short-term memory (LSTM) networks, recursive neural networks (RNN), etc., which are very effective in processing and predicting time-related sequence data; the Markov chain model is a mathematical model used to describe a random process with Markov properties. The model can assume that future memory access conditions only depend on current memory access data and have nothing to do with past access data. Therefore, if based on the Markov chain model, historical access data at multiple moments are used as training samples to predict memory access conditions within a period of time after each moment. The specific training method will not be repeated.
[0032] Step S130: performing corresponding memory management according to the prediction information.
[0033] Since the prediction information includes the memory page to be accessed and the access probability of the memory page in the second time period, better memory management can be achieved based on the prediction information. The specific memory management strategy includes at least one of the following strategies: preloading memory pages with an access probability greater than a first probability threshold; reclaiming memory for unaccessed memory pages; and reordering memory pages based on access probability.
[0034] In some embodiments, after step S130, if the acquired memory access data is greater than the first data volume threshold, and the electronic device is in a charging state, the memory access prediction model is updated using the acquired memory access data to obtain the updated memory access prediction model. That is to say, in the process of memory management, new real-time memory access data will be continuously collected, so that when it is determined that the collected memory access data is sufficient and the electronic device is in a charging state, the memory access prediction model is updated using the new memory access data to obtain an updated memory access prediction model. Furthermore, in the subsequent memory management process, the updated memory access prediction model is used to predict memory access. In this way, since the memory access prediction model is updated according to the new real-time memory access data, the memory access prediction model can more accurately predict memory access in subsequent processes.
[0035] In other embodiments, after step S130, the memory access prediction model is updated at preset intervals using the acquired new memory access data to obtain the updated memory access prediction model. In other words, the memory access prediction model can also be updated periodically to ensure the prediction accuracy of the memory access prediction model.
[0036] In some other embodiments, after step S130, in response to the model update instruction, the memory access prediction model is updated using the acquired new memory access data to obtain the updated memory access prediction model. The model update instruction may be input by the user, that is, the user may decide when to update the memory access prediction model. For example, if the user feels that the overall operation of the electronic device is not smooth enough during the recent use of the electronic device, it may mean that the memory access prediction model has not been updated in time, resulting in the inability to accurately predict the memory access of the electronic device of the user who has changed the usage habits.
[0037] In this embodiment, a memory access prediction model is used to predict memory pages to be accessed in the next period of time and the access probability of the memory pages based on the memory access data of the previous period of time, as prediction information for memory access in the next period of time, so that better memory management can be achieved based on the prediction information; and the memory access prediction model is pre-trained based on historical memory access data, which can improve the prediction accuracy of the model to a certain extent, so that the model can be better utilized to optimize memory management.
[0038] Please refer to Figure 2 , Figure 2 A flowchart of a memory management method provided in another embodiment of the present application is applied to an electronic device. Figure 2 The memory management method provided in the embodiment of the present application is described in detail. The memory management method may include the following steps:
[0039] Step S210: Acquire memory access data within a first time period.
[0040] Step S220: input the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information includes at least a memory page to be accessed and the access probability of the memory page being accessed within the second time period. The memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods, and the number of memory pages is multiple.
[0041] In this embodiment, the specific implementation of step S210 to step S220 can refer to the content of the above-mentioned embodiment, which will not be repeated here.
[0042] Step S230: From the multiple memory pages, a memory page whose access probability is greater than a first probability threshold is obtained as the first memory page.
[0043] Optionally, a memory page with an access probability greater than a first probability threshold can be screened out from multiple memory pages as the first memory page. The first memory page can be understood as a memory page that is likely to be frequently accessed in the second time period; the first probability threshold can be a pre-set value, which is greater than 0 and less than 1, for example, 0.7. Of course, the value can also be adjusted according to actual needs, and this embodiment does not limit this.
[0044] Step S240: preload the page data in the first memory page.
[0045] It can be understood that for the first memory page predicted to be frequently accessed in the second time period, it can be further detected whether the page data in the first memory page is stored in the memory of the electronic device. If it is not stored in the memory of the electronic device, the page data of the first memory page is preloaded from the disk of the electronic device into the memory. In this way, when the page data of the first memory page needs to be accessed in the second time period, there is no need to temporarily obtain it from the disk, but the page data in the first memory page can be directly read from the memory. Obviously, the efficiency of memory access is greatly improved, thereby improving the operating efficiency of the electronic device.
[0046] Step S250: From the plurality of memory pages, a memory page having an access probability less than a second probability threshold is obtained as a second memory page, wherein the second probability threshold is less than the first probability threshold.
[0047] Optionally, a memory page with an access probability less than a second probability threshold may be screened out from multiple memory pages as a second memory page, wherein the second probability threshold is much smaller than the first probability threshold, and the second memory page may be understood as a memory page that is not expected to be accessed and a memory page with an extremely low access probability. The second probability threshold is a preset value, which is greater than 0 and less than 1, for example, may be 0.2. Of course, the value may also be adjusted according to actual needs, and this embodiment does not limit this.
[0048] Step S260: performing memory recycling processing on the second memory page.
[0049] Furthermore, after the second memory page is screened out, if the page data in the second memory page is still stored in the memory of the electronic device, in order to release more memory space of the electronic device, the page data in the second memory page can be memory recycled.
[0050] Among them, the memory recycling processing includes at least one of the following processing methods: after compressing the page data in the second memory page, it is still stored in the memory; the page data in the second memory page is transferred to the hard disk of the electronic device for storage; after compressing the page data in the second memory page, the compressed page data is transferred to the hard disk of the electronic device for storage.
[0051] Optionally, if the remaining memory value of the electronic device is less than the first memory threshold, the page data in the second memory page is compressed and still stored in the memory; if the remaining memory value of the electronic device is less than the second memory threshold, the page data in the second memory page is transferred to the hard disk of the electronic device for storage, and the second memory threshold is less than the first memory threshold; if the remaining memory value of the electronic device is less than the second memory threshold, and the remaining storage space size of the hard disk of the electronic device is less than the first threshold, the page data in the second memory page is compressed, and the compressed page data is transferred to the hard disk of the electronic device for storage. In this way, when the second memory page is recycled, a more suitable memory recycling processing method is used to recycle the memory according to the remaining memory value of the memory and the remaining space size of the hard disk, thereby achieving a better memory recycling effect.
[0052] In some embodiments, after obtaining the prediction information, the multiple memory pages can be sorted in descending order according to the access probability of each memory page to obtain a target memory queue; if the current remaining memory value is less than the first memory threshold, the first N memory pages at the tail of the target memory queue are subjected to memory recycling, where N is a positive integer. In this way, when the remaining memory of the electronic device is insufficient, memory pages with a lower access probability are recycled first; and memory pages with a higher access probability are arranged at the head of the target memory queue, so that the memory pages at the head of the target memory queue can be called more quickly when accessed, thereby reducing the delay of memory access.
[0053] It can be understood that the memory access prediction model in this embodiment can also be updated. The specific updating method can refer to the content in the aforementioned embodiment and will not be repeated here.
[0054] In this embodiment, a memory access prediction model is used, and based on the memory access data of the previous period, the memory pages to be accessed in the next period and the access probability of the memory pages are predicted as prediction information for the memory access in the next period, and based on the access probability, different memory management measures are performed on different memory pages, so as to allocate memory more flexibly and intelligently, reduce unnecessary page replacement, and further improve the performance of electronic devices, for example, improve the stability and response speed of electronic devices, achieve better memory management of electronic devices, and improve the memory utilization efficiency of electronic devices; and the memory access prediction model is pre-trained based on historical memory access data, which can improve the prediction accuracy of the model to a certain extent, so that the model can be better utilized to optimize memory management.
[0055] Please refer to Figure 3 , Figure 3 A flowchart of a memory management method provided in another embodiment of the present application is applied to an electronic device. Figure 3 The memory management method provided in the embodiment of the present application is described in detail. The memory management method may include the following steps:
[0056] Step S310: Acquire memory access data of a target application within a first time period.
[0057] In this embodiment, a plurality of memory access prediction models may be pre-stored in the electronic device, and the plurality of memory access prediction models correspond one to one to a plurality of preset applications. Each memory access prediction model is obtained by training an initial prediction model using a training sample set corresponding to its corresponding preset application, wherein the training sample set includes historical memory access data of its corresponding preset application in multiple historical time periods. It can be seen that the present application is provided with a corresponding memory access prediction model for each application, and performs more targeted predictions on the memory access of each application.
[0058] The target application is any running application. That is, the electronic device can detect the memory access data of each running application in real time, and predict the memory access situation of each running application in the second time period based on the memory access data.
[0059] Step S320: Determine a memory access prediction model corresponding to the target application from a plurality of pre-trained memory access prediction models as a target prediction model.
[0060] Step S330: input the target memory access data into the target prediction model to obtain prediction information of the target application in the second time period output by the target prediction model.
[0061] Based on this, the memory access prediction model corresponding to the target application can be called from multiple pre-trained memory access prediction models as the target prediction model for the target application. Then, the target memory access data is input into the target prediction model to obtain the prediction information of the target application in the second time period output by the target prediction model. Of course, the prediction information includes the memory page to be accessed of the target application and the access probability of the first memory page being accessed by the target application in the second time period.
[0062] The definitions of the first time period and the second time period can be found in the above embodiments and will not be described in detail here.
[0063] Step S340: performing corresponding memory management on the target application according to the prediction information of the target application and the memory management policy corresponding to the target application.
[0064] It is understandable that different memory management policies can be set for different target applications. Further, after obtaining the prediction information of the target application, the memory group of the target application can be managed accordingly according to the prediction information and the memory management policy corresponding to the target application.
[0065] Optionally, different memory management policies can be set according to the target application's demand for timely response and / or the size of the memory group required. For example, for applications with high demand for timely response, it can be set to: preload memory pages with access probabilities greater than a first probability threshold; recycle memory for unaccessed memory pages; and reorder memory pages based on access probabilities. In this way, the memory occupied by the target application can be managed and optimized more comprehensively.
[0066] For another example, for an application that does not require a large number of memory groups, such as an alarm clock, the memory management policy corresponding to the application can be set to: preload memory pages whose access probability is greater than a first probability threshold; reorder memory pages based on the access probability. That is, since the target application requires only a small number of memory groups and occupies a small amount of memory space, the memory pages do not need to be recycled, and only the timeliness of the application's response needs to be ensured.
[0067] In this embodiment, various thresholds in the memory management policies corresponding to different applications can be set to the same value or different values. The specific settings can be adjusted according to actual needs, and this embodiment does not impose any restrictions on this.
[0068] In some implementations, when it is detected that the memory value occupied by the memory group of the target application is greater than the specified memory threshold, the memory management method provided in this embodiment can be used to manage the memory of the target application. In this way, it is possible to avoid running multiple memory access prediction models all the time, which may lead to problems such as excessive power consumption of electronic devices. That is, only when the memory occupied by the target application is too much, the memory management method of this embodiment is activated to timely implement memory optimization management of the target application.
[0069] In this embodiment, a memory access prediction model corresponding to the target application is used, and based on the memory access data of the target application in the previous period, the memory pages to be accessed and the access probability of the memory pages of the target application in the next period are predicted as prediction information for memory access in the next period, so that better memory management can be achieved for each running application based on the prediction information; and the memory access prediction model of each application is pre-trained based on the historical memory access data of the application, which can improve the accuracy and pertinence of the model's prediction to a certain extent, so that the model can be better utilized to optimize memory management; and, since the corresponding memory access prediction model is used for each running application to predict and optimize memory access, the memory management method of the present application can more significantly improve the data processing speed and system performance of electronic devices in memory-intensive applications such as big data processing and machine learning.
[0070] Please refer to Figure 4 , which shows a structural block diagram of a memory management device 400 provided by an embodiment of the present application. The device 400 may include: an access data acquisition module 410, an access prediction module 420 and a memory management module 430.
[0071] The access data acquisition module 410 is used to acquire memory access data within a first time period.
[0072] The access prediction module 420 is used to input the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information includes at least a memory page to be accessed and the access probability of the memory page being accessed within the second time period. The memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods.
[0073] The memory management module 430 is used to perform corresponding memory management according to the prediction information.
[0074] In some embodiments, there are multiple memory pages, and the memory management module 430 can be specifically used to: obtain a memory page with an access probability greater than a first probability threshold from the multiple memory pages as the first memory page; and preload the page data in the first memory page.
[0075] In this manner, the memory management module 430 can also be specifically used to: obtain a memory page whose access probability is less than a second probability threshold from the multiple memory pages as a second memory page, wherein the second probability threshold is less than the first probability threshold; and perform memory recycling processing on the second memory page.
[0076] In this manner, the memory management module 430 can also be specifically used to: sort the multiple memory pages in descending order of the access probability of each memory page to obtain a target memory queue; if the current remaining memory value is less than the first memory threshold, perform memory recycling processing on the first N memory pages at the tail of the target memory queue, where N is a positive integer.
[0077] In some embodiments, the memory access data is target memory access data corresponding to a target application, and the target application is any application currently running. The access prediction module 420 can be specifically used to: determine a memory access prediction model corresponding to the target application from a plurality of pre-trained memory access prediction models as a target prediction model; input the target memory access data into the target prediction model, and obtain prediction information of the target application in the second time period output by the target prediction model.
[0078] In this manner, the memory management module 430 may be specifically used to perform corresponding memory management on the target application according to the prediction information of the target application and the memory management policy corresponding to the target application.
[0079] In some implementations, the memory management device 400 may further include: a model update module. The model update module may be used to update the memory access prediction model using the acquired memory access data to obtain the updated memory access prediction model after performing corresponding memory management according to the prediction information, if the acquired memory access data is greater than the first data volume threshold and the electronic device is in a charging state.
[0080] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0081] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0082] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0083] To summarize, the memory access prediction model corresponding to the target application is used, and based on the memory access data of the target application in the previous period of time, the memory pages to be accessed and the access probability of the memory pages of the target application in the next period of time are predicted as the prediction information for the memory access in the next period of time, so that better memory management can be achieved for each running application based on the prediction information; and the memory access prediction model of each application is pre-trained based on the historical memory access data of the application, which can improve the accuracy and pertinence of the model's prediction to a certain extent, so that the model can be better utilized to optimize memory management; and, since the corresponding memory access prediction model is used for each running application to predict and optimize memory access, the memory management method of the present application can more significantly improve the data processing speed and system performance of electronic devices in memory-intensive applications such as big data processing and machine learning.
[0084] The following will be combined Figure 5 An electronic device provided by the present application is described.
[0085] Reference Figure 5 , Figure 5The structural block diagram of an electronic device 500 provided in an embodiment of the present application is shown, and the above method provided in an embodiment of the present application can be executed by the electronic device 500. The electronic device can be an electronic terminal with a data processing function, and the electronic terminal includes but is not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3) player, and an MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) player, etc.
[0086] The electronic device 500 in the embodiment of the present application may include one or more of the following components: a processor 501, a memory 502, and one or more applications, wherein the one or more applications may be stored in the memory 502 and configured to be executed by one or more processors 501, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0087] The processor 501 may include one or more processing cores. The processor 501 uses various interfaces and lines to connect various parts of the entire electronic device 500, and executes various functions and processes data of the electronic device 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 502, and calling data stored in the memory 502. Optionally, the processor 501 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 501 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem can also be integrated into the processor 501 and implemented separately through a communication chip.
[0088] The memory 502 may include a random access memory (RAM) or a read-only memory (ROM). The memory 502 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 502 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as the various corresponding relationships described above) created by the electronic device 500 during use.
[0089] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0090] In several embodiments provided in the present application, the coupling or direct coupling or communication connection between the modules shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or modules, which may be electrical, mechanical or other forms.
[0091] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0092] Please refer to Figure 6 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 600 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0093] The computer readable storage medium 600 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 600 includes a non-transitory computer-readable storage medium. The computer readable storage medium 6600 has storage space for program code 610 that performs any method step of the above method. These program codes can be read from or written to one or more computer program products. The program code 610 can be compressed, for example, in an appropriate form.
[0094] In some embodiments, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the steps in the above-mentioned method embodiments.
[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A memory management method, characterized in that: Applied to electronic equipment, the method comprises: Obtaining memory access data within a first time period; Inputting the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information at least includes a memory page to be accessed and an access probability of the memory page being accessed within the second time period, wherein the memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods; Corresponding memory management is performed according to the prediction information.
2. The method according to claim 1, characterized in that The number of pages of the memory page is multiple, and the corresponding memory management is performed according to the prediction information, including: From the plurality of memory pages, obtaining a memory page whose access probability is greater than a first probability threshold as a first memory page; Preload the page data in the first memory page.
3. The method according to claim 2, characterized in that The performing corresponding memory management according to the prediction information also includes: From the plurality of memory pages, obtaining a memory page whose access probability is less than a second probability threshold as a second memory page, wherein the second probability threshold is less than the first probability threshold; Perform memory recycling processing on the second memory page.
4. The method according to claim 2, characterized in that: The performing corresponding memory management according to the prediction information also includes: Sorting the plurality of memory pages in descending order of access probability of each memory page to obtain a target memory queue; If the current remaining memory value is less than the first memory threshold, memory recycling is performed on the first N memory pages located at the tail of the target memory queue, where N is a positive integer.
5. The method according to any one of claims 1 to 4, characterized in that: The memory access data is target memory access data corresponding to a target application, and the target application is any application currently running; The step of inputting the memory access data into a pre-trained memory access prediction model to obtain prediction information of memory access within a second time period output by the memory access prediction model includes: Determining a memory access prediction model corresponding to the target application from a plurality of pre-trained memory access prediction models as a target prediction model; The target memory access data is input into the target prediction model to obtain prediction information of the target application in the second time period output by the target prediction model.
6. The method according to claim 5, characterized in that The performing corresponding memory management according to the prediction information includes: According to the prediction information of the target application and the memory management policy corresponding to the target application, corresponding memory management is performed on the target application.
7. The method according to any one of claims 1 to 4, characterized in that: After performing corresponding memory management according to the prediction information, the method further includes: If the acquired memory access data is greater than a first data volume threshold and the electronic device is in a charging state, the memory access prediction model is updated using the acquired memory access data to obtain an updated memory access prediction model.
8. A memory management device, characterized in that: Applied to electronic equipment, the device comprises: An access data acquisition module, used to acquire memory access data within a first time period; an access prediction module, used for inputting the memory access data into a pre-trained memory access prediction model, and obtaining prediction information of memory access within a second time period output by the memory access prediction model, wherein the second time period is located after the first time period, and the prediction information at least includes a memory page to be accessed and an access probability of the memory page being accessed within the second time period, and the memory access prediction model is obtained by training an initial prediction model based on a training sample set, and the training sample set includes historical memory access data within multiple historical time periods; A memory management module is used to perform corresponding memory management according to the prediction information.
9. An electronic device, characterized in that: include: one or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, which can be called by a processor to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Application program processing method and device
CN111435302A
Memory access address prediction method and device, storage medium and electronic equipment
CN114116528A
Memory missing page exception processing method and device, equipment and storage medium
CN114253458A
Memory prefetching method and device and medium
CN115203073A
Content preloading method and related equipment
CN115730166A