Memory page processing method and device and electronic equipment
By identifying and recording memory usage objects affected by the replacement of the memory pages of electronic devices during the memory page replacement process, avoiding the replacement of the memory pages of these objects, the problem of memory page replacement affecting the operational performance and improve system performance and stability.
Patent Information
- Application Number
- CN202311155560.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2025-03-07
AI Technical Summary
In electronic devices, the permutation operation of the memory page may affect the running performance of the target memory usage object, resulting in performance degradation.
During the memory page replacement process, memory usage objects affected by permutation in history are identified and recorded, so as to avoid permutation of the memory pages of these objects.
It effectively avoids the impact on the operating performance of the target memory usage object due to memory page replacement, and improves the overall performance and stability of the system.
Smart Images

Figure CN119576512A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a memory page processing method, device and electronic device. Background Art
[0002] In memory, data can usually be managed through memory pages. During the operation of an electronic device, the electronic device needs to manage the memory pages in the memory. For example, the electronic device can replace the memory pages in the memory to free up memory space for other processes. However, in the related methods, the replacement operation of the memory page may affect the performance of the memory usage object. Summary of the invention
[0003] In view of the above problems, the present application proposes a memory page processing method, device and electronic device to improve the above problems.
[0004] In a first aspect, the present application provides a memory page processing method, which is applied to an electronic device, and the method includes: in response to a memory replacement instruction, starting to replace a memory page; obtaining a memory usage object to which the current memory page to be replaced belongs; if the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, then no replacement operation is performed on the current memory page to be replaced, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during a historical memory page replacement process.
[0005] In a second aspect, the present application provides a memory page processing device that runs on an electronic device, the device comprising: a replacement trigger unit, used to start replacing memory pages in response to a memory replacement instruction; an object acquisition unit, used to obtain a memory usage object to which a current memory page to be replaced belongs; a replacement processing unit, used to not perform a replacement operation on the current memory page to be replaced if the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during a historical memory page replacement process.
[0006] In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors to implement the above method.
[0007] In a fourth aspect, the present application provides a computer-readable storage medium, in which program code is stored, wherein the above method is executed when the program code is executed by a processor.
[0008] The present application provides a memory page processing method, device, and electronic device, which can obtain the memory usage object to which the current memory page to be replaced belongs after starting to replace the memory page in response to a memory replacement instruction, and if the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, then the current memory page to be replaced will not be replaced, wherein the target memory usage object is a memory usage object whose operating performance is affected after the corresponding memory page is replaced during the historical memory page replacement process. Thus, in the above manner, in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the operating performance of the target memory usage object due to the memory page replacement operation. 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 flow chart of a memory page processing method proposed in an embodiment of the present application is shown;
[0011] Figure 2 A schematic diagram showing a method of establishing program groups in an embodiment of the present application is shown;
[0012] Figure 3 A schematic diagram showing different time consumptions for processing the same task in an embodiment of the present application;
[0013] Figure 4 A schematic diagram showing a method of dividing a memory into an uncompressed area and a memory compression area in an embodiment of the present application is shown;
[0014] Figure 5 A flowchart of a memory page processing method proposed in another embodiment of the present application is shown;
[0015] Figure 6 A flowchart of a memory page processing method proposed in another embodiment of the present application is shown;
[0016] Figure 7 A flowchart of a memory page processing method proposed in another embodiment of the present application is shown;
[0017] Figure 8 A structural block diagram of a memory replacement device proposed in an embodiment of the present application is shown;
[0018] Fig. 9 A structural block diagram of an electronic device for executing a memory page processing method according to an embodiment of the present application in real time is shown in the present application;
[0019] Fig.10 A storage unit in real time of the present application is shown for storing or carrying program codes for implementing the memory page processing method according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 creative work are within the scope of protection of this application.
[0021] Memory, also known as main memory, is a directly addressable storage space made of semiconductor devices. Programs (for example, processes or threads) in electronic devices usually need to use memory to complete data processing during operation. For example, during the startup process, the program will obtain the corresponding memory for use during the startup process or after startup. In memory, data can usually be managed through memory pages. Among them, during the operation of the electronic device, the electronic device can manage the memory pages in the memory. For example, the electronic device can replace the memory pages in the memory to free up memory space for other processes. However, in the related method, the replacement operation of the memory page is not flexible enough.
[0022] Therefore, the inventors have proposed a memory page processing method, device, and electronic device in the present application, which can obtain the memory usage object to which the current memory page to be replaced belongs after starting to replace the memory page in response to a memory replacement instruction, and if the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, then the current memory page to be replaced will not be replaced, wherein the target memory usage object is a memory usage object whose operating performance is affected after the corresponding memory page is replaced during the historical memory page replacement process. Thus, in the above manner, in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the operating performance of the target memory usage object due to the memory page replacement operation.
[0023] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0024] See also Figure 1 , an embodiment of the present application provides a memory page processing method, the method comprising:
[0025] S110: In response to the memory replacement instruction, start replacing the memory page.
[0026] The purpose of performing memory replacement is to free up more memory space for use by the memory user. In this case, the memory replacement instruction may be triggered when the memory user has a memory usage requirement, or when the remaining memory of the electronic device is insufficient.
[0027] After starting to replace the memory pages, the electronic device can determine the current memory pages to be replaced one by one according to a predetermined order. It should be noted that the current memory pages to be replaced can be understood as memory pages that are currently being determined whether they need to be replaced.
[0028] Optionally, the current memory pages to be replaced may be determined one by one according to the order of the memory addresses of all the memory pages.
[0029] Optionally, all memory pages may be sorted according to the time when the memory pages were last called, and then the current memory pages to be replaced are determined one by one according to the sorting result. In this way, the memory pages with a longer time between the last call time and the current time are ranked higher.
[0030] Optionally, all memory pages may be sorted according to the time when the memory pages were loaded into the memory, and then the current memory pages to be replaced are determined one by one according to the sorting result. In this way, the memory pages with a longer time between the time when they were loaded into the memory and the current time are ranked higher.
[0031] S120: Obtain the memory usage object to which the current memory page to be replaced belongs.
[0032] In an embodiment of the present application, a memory usage object can be understood as an object that uses the memory of an electronic device. Optionally, a memory usage object can be a program (e.g., an application), or a memory usage object can be a program grouping obtained by dividing the program. Among them, program grouping can be implemented based on the memory control group (Memory Control Group, Memcg for short) technology of an operating system (e.g., Linux system). In the case where the memory usage object is a program grouping, each program grouping can include at least one program. In an embodiment of the present application, a program can be understood as a complete application, or it can be understood as a process or thread included in the application.
[0033] Wherein, in the case of multiple program groups, the multiple program groups may be obtained by dividing the multiple programs. Optionally, the multiple program groups may be obtained by dividing according to target features of the programs, wherein the target features of the programs in the same program group are the same. In the embodiment of the present application, the target features may be implemented in multiple ways.
[0034] Optionally, the target feature includes a user identification code UID (User Identification) of the program.
[0035] In the case of dividing the program groups according to the user identification code, the user identification codes of the programs in the same program group are the same. If the program represents a process, then the same program group may include multiple processes with the same corresponding user identification code. For example, the same application may further include multiple programs (e.g., multiple processes), and because the multiple programs belong to the same application, the user identification codes of the multiple programs may be the same. In this case, the multiple programs can be divided into the same program group.
[0036] For example, Figure 2 As shown, the electronic device includes application A1, application A2 and application A3. Among them, application A1 includes program A11, program A12 and program A13. Application A2 includes program A21 and program A22. Application A3 includes program A31, program A32, program A33 and program A34. Among them, because program A11, program A12 and program A13 all belong to application A1, the user identification codes corresponding to them will be the same. Similarly, the user identification codes corresponding to program A21 and program A22 will be the same, and the user identification codes corresponding to program A31, program A32, program A33 and program A34 will be the same. When programs corresponding to the same identification code are classified into the same group, program A11, program A12, and program A13 can be classified into the same program group G1, program A21 and program A22 can be classified into the same program group G2, and program A31, program A32, program A33, and program A34 can be classified into the same program group G3.
[0037] Alternatively, the target characteristics include the memory access latency requirements of the program.
[0038] In an embodiment of the present application, the memory access delay requirement represents the timeliness requirement of the program when performing memory access. For example, some programs expect access requests to be responded to quickly when performing memory access, wherein a quick response to the access request can be understood as the data requested to be accessed can be returned to the program quickly, or a quick response to the access request can be understood as the requested calculation in the memory can get the returned calculation result quickly. Optionally, the meaning represented by the memory access delay requirement can be: the maximum delay time that the program can accept. Or, optionally, the meaning represented by the memory access delay requirement can be: the maximum number of memory access delays that the program can accept within a specified time length. In this way, an application whose memory access delay requirement meets the specified requirement conditions can be used as the first target application. Optionally, the specified requirement conditions can be: the maximum delay time is less than the specified time length, or the maximum number of memory access delays is less than the specified number.
[0039] Optionally, the electronic device can group the applications based on the memory access delay requirements of the applications, thereby obtaining multiple program groups. Among them, for the same program group, the memory access delay requirements of the included applications are the same or similar. In this case, an application in one or more of the program groups can be selected as the first target application. For example, a program in a program group with the shortest maximum delay time that the included programs can accept can be selected as the first target application. Alternatively, a program in a program group with the smallest maximum number of memory access delays that the included programs can accept can be selected as the first target application.
[0040] After the memory access latency requirements of the programs to be grouped are obtained, corresponding program groups may be configured for the programs to be grouped.
[0041] As a method, multiple program groups can be preconfigured, and a corresponding memory access latency requirement can be configured for each program group. In this way, after obtaining the application programs to be grouped, the memory access latency requirements of the application programs to be grouped can be compared with the memory access latency requirements corresponding to each program group configuration, so as to group the programs whose corresponding memory access requirements are similar or identical to the memory access requirements of the application programs to be grouped as the groups into which the application programs to be grouped are divided.
[0042] Among them, the two memory access delay requirements are similar, which can be understood as the delay requirements expressed by the two memory access delay requirements are relatively close. For example, taking the meaning represented by the memory access delay requirement as the maximum delay time that the program can accept as an example, the delay requirements expressed by the two memory access delay requirements are relatively close, which can be understood as the difference between the maximum delay times that the two memory access delay requirements can accept is less than the specified threshold. For another example, taking the meaning represented by the memory access delay requirement as the maximum number of memory access delays that the program can accept within a specified time length as an example, the delay requirements expressed by the two memory access delay requirements are relatively close, which can be understood as the difference between the maximum number of memory access delays is less than the specified threshold.
[0043] Exemplarily, the grouping of multiple programs may be shown in the following table:
[0044] ID Group ID Memory access latency requirements for groups 1 Group G1 T1 2 Group G2 T2 3 Group G3 T3
[0045] As shown in the above table, T1, T2 and T3 in the memory access delay requirements of the groups in the above table represent the maximum acceptable delay time. Among them, the values of T1, T2 and T3 can be non-negative numbers. For example, T1 can be 0.5 seconds, T2 can be 1 second, and T3 can be 2 seconds. Based on the situation shown in the above table, after obtaining the application to be grouped, if the maximum acceptable delay time represented by the memory access delay requirement of the application to be grouped is T1, the application to be grouped will be divided into group G1. If the maximum acceptable delay time represented by the memory access delay requirement of the application to be grouped is T3, the application to be grouped will be divided into group G3. If the maximum acceptable delay time represented by the memory access delay requirement of the application to be grouped is T4, and the difference between T4 and T1 is calculated to be less than the specified threshold, it is determined that the memory access delay requirement of the application to be grouped is similar to the memory access delay requirement of group G1, and the application to be grouped will be divided into group G1.
[0046] As a method, if the memory access delay requirement of the program to be grouped is different from and not similar to the memory access delay requirement of each group, it can be detected whether the creation of a new program group is allowed. If it is detected that the creation of a new program group is allowed, a new program group is created, and the memory access requirement of the program to be grouped is used as the memory access requirement of the newly created program group. If the creation of a new program group is not allowed, a group whose corresponding memory access delay requirement is closest to the memory access delay requirement of the program to be grouped is determined from the currently established program groups as the program group corresponding to the program to be grouped.
[0047] Optionally, the electronic device may determine whether to allow the creation of a new program group in a variety of ways.
[0048] As a determination method, the user of the electronic device may configure whether to allow the creation of a new program group. In this method, a configuration interface may be displayed in the electronic device, and the configuration interface may display an option of prohibiting the creation of a new program group and an option of allowing the creation of a new program group. Then, the user may select the desired option according to his or her needs.
[0049] As another determination method, the electronic device can determine whether to allow the creation of a new program group based on the currently remaining storage space. It should be noted that, in the case of creating a new program group, it is necessary to allocate corresponding storage space for the new program group to store corresponding data. The data may include the data of the program group itself to store the data in the program group. Therefore, each time a new program group is created, more storage space is consumed. In this case, the electronic device can determine that a new program group is not allowed to be created if it detects that the remaining storage space is insufficient, and correspondingly, it can determine that a new program group is allowed to be created if it detects that the remaining storage space is sufficient.
[0050] Optionally, when it is detected that the remaining storage space is greater than a specified storage threshold, it is determined that the remaining storage space is sufficient; otherwise, it is determined that the remaining storage space is insufficient.
[0051] It should be noted that, in the embodiment of the present application, the memory access delay requirement of the application can be pre-configured by the developer of the program, or can be determined by the electronic device according to the category and / or running state of the application. Correspondingly, when the memory access delay requirement of the application can be characterized by the memory access delay level, the memory access delay level of the application can be determined according to the category and / or running state of the application.
[0052] For example, if the category of an application indicates that the program is an application running in the foreground or a system program, then the memory access latency requirement of the application indicates that the memory direction requirement of the application needs to be responded to quickly. For another example, if the category of an application indicates that the program is a program running in the background, then the memory access latency requirement of the application indicates that the memory direction requirement of the application can be delayed for a certain period of time before responding.
[0053] Among them, foreground operation can be understood as the state of a program or process in the operating system, indicating that the program or process is executing and the user can interact with it directly. When a program is in the foreground running state, its window will be displayed at the forefront of the screen, and the user can interact with it directly, such as entering text, clicking buttons, etc. In contrast, background operation means that the program or process is running in the background and the user cannot interact with it directly. Programs running in the background usually perform tasks that do not require user interaction, such as data backup, file download, etc.
[0054] It should be noted that the memory access requirements for the same application in different operating states may also be different. For example, for an audio player, in the operating state when it is started and no audio playback is performed, the operations performed may include operations with low timeliness. The operations with low timeliness may include page switching operations, music search operations, or configuration operations. In the operating state of the audio player, when the audio player starts to play audio, the audio player will obtain audio data from the network in real time, and load it into the memory for decoding and playback. Therefore, the audio playback operation performed by the audio player is an operation with high timeliness.
[0055] For another example, for a game program, when it is started and the game operation interface is not entered, the operations performed may include operations with low timeliness. The operations with low timeliness may include page switching operations, game configuration operations, or game item purchase operations, etc. In the game program, when the game operation interface is displayed, the game program will obtain game data (for example, other players' data or real-time map data, etc.) from the network in real time, and load it into the memory for processing. Therefore, when the game program is in the running state of displaying the game operation interface, the memory access request needs to be responded to faster. Among them, when the game program displays the game operation interface, the game operation object in the game operation interface can be controlled.
[0056] In the embodiment of the present application, the programs in the program group may also be deleted. As shown in the foregoing, there may be multiple ways to determine the programs to be grouped, and in this case, there may also be multiple ways to delete the programs in the program group.
[0057] Wherein, when the memory usage object is a program, the program to which the current memory page to be replaced belongs can be taken as the memory usage object. When the memory usage object is a program group, the program group to which the current memory page to be replaced belongs can be taken as the memory usage object.
[0058] S130: If the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, no replacement operation is performed on the current memory page to be replaced, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
[0059] In the embodiment of the present application, it can be confirmed from multiple aspects whether the operating performance of the memory usage object is affected.
[0060] Optionally, the confirmation can be made from the utilization rate of the processing device. In the operation process of the memory usage object, the processing device is required to process related tasks. If the utilization rate of the processing device by the memory usage object decreases after the memory page of the memory usage object is replaced, it means that the memory usage object is currently in a stuck state, and the stuck state is most likely caused by the memory page replacement.
[0061] Optionally, the confirmation can be made from the number of errors in the memory page. The memory usage object needs to process the data in the memory page during operation. After replacing the memory page, the memory usage object may reuse the data in the previously replaced memory page, and then it is necessary to load the replaced memory page into the memory again, but memory page errors may occur in the process, thereby affecting the operation of the memory usage object. The memory page error may include the situation where the memory page is missing.
[0062] It should be noted that when a memory usage object calls a memory page, it accesses the corresponding memory page through the memory address. If the memory address accessed does not actually have a corresponding memory page, or if there is insufficient authority to access the memory page corresponding to the memory address, a page fault will occur, causing the memory usage object to become abnormal.
[0063] Optionally, the time taken by the memory usage object to perform tasks can be used to confirm the situation. In some cases, the memory usage object may repeatedly perform the same task. For example, the memory usage object may render and display the same application interface at different times. For another example, the memory usage object may process and display multiple images in real time. If the time taken to process the same task increases after the memory page corresponding to the memory usage object is replaced, it means that the operating performance of the memory usage object is affected. For example, Figure 3As shown in the figure, images F1, F2, F3, F4, F5 and F6 are images processed by the memory usage object J1. In the figure, the width of the image represents the corresponding processing time. It can be found that after the memory page of the memory usage object J1 is replaced, the processing time of images F4 and F5 increases. Therefore, it can be explained that replacing the memory page of the memory usage object J1 has an impact on the running performance of the memory usage object.
[0064] In the embodiment of the present application, after the memory page of the memory usage object is replaced, the aforementioned method can be used to detect whether the operation of reclaiming the memory page has an impact on the running performance of the memory usage object. If so, the affected memory usage object can be marked as the target memory usage object. In addition, when the affected memory usage object is marked as the target memory usage object, the time when the memory page replacement operation that affects the running performance occurs and the number of replaced memory pages can also be recorded.
[0065] In the embodiment of the present application, if it is detected that the memory usage object to which the current memory page to be replaced belongs is not the target memory usage object, a replacement operation may be performed on the current memory page to be replaced.
[0066] Among them, in the embodiment of the present application, replacing the memory page can be understood as replacing the memory page from the non-compressed area in the memory to the compressed area of the memory, and can also be understood as replacing the memory page from the non-compressed area to a location outside the memory, and can also be understood as replacing the memory page from the compressed area of the memory to a location outside the memory.
[0067] It should be noted that the memory of the electronic device can be divided into an uncompressed area and a memory compression area. Among them, the memory pages in the uncompressed area are not compressed, while the memory pages in the memory compression area are compressed. In this case, the memory pages in the uncompressed area can be directly used by the memory user object, but if the memory pages in the memory compression area are needed, the memory pages in the memory compression area can be decompressed first, and then loaded into the uncompressed area for use. Among them, replacing the memory pages in the memory into the memory compression area can be understood as compressing the memory pages in the uncompressed area of the memory and then replacing them into the memory compression area. For example, Figure 4 As shown, the memory of the electronic device is divided into an uncompressed area and a compressed memory area, wherein the memory pages P1 and P2 in the uncompressed area are uncompressed memory pages, and the memory pages P4 and P4 in the compressed memory area are compressed memory pages.
[0068] Optionally, a memory compression area can be established through zram. Among them, the memory pages replaced in the memory compression area will be compressed to reduce the storage space occupied. It should be noted that the memory pages replaced from the memory may be reused and then need to be loaded back into the memory. Among them, the memory pages replaced in the memory compression area can be loaded back into the memory more quickly than the memory pages replaced outside the memory.
[0069] A memory page processing method provided in this embodiment can obtain the memory usage object to which the current memory page to be replaced belongs after starting to replace the memory page in response to the memory replacement instruction, and if the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, then the current memory page to be replaced will not be replaced, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced in the historical memory page replacement process. Thus, in the above manner, in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the running performance of the target memory usage object due to the memory page replacement operation.
[0070] See also Figure 5 , an embodiment of the present application provides a memory page processing method, the method comprising:
[0071] S210: In response to the memory replacement instruction, start replacing the memory page.
[0072] S220: Obtain the memory usage object to which the current memory page to be replaced belongs.
[0073] S230: Detect whether the memory usage object to which the current memory page to be replaced belongs is the target memory usage object.
[0074] S231: If the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, the degree to which the running performance of the memory usage object to which the current memory page to be replaced belongs is affected is obtained.
[0075] S232: If the degree of impact meets the target degree condition, no replacement operation is performed on the current memory page to be replaced, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
[0076] It should be noted that the operating performance of some memory usage objects may be affected due to the replacement of the corresponding memory pages. However, the degree of impact may not be large. In this case, normal memory page replacement can still be performed. Among them, the target degree condition can be understood as the condition for judging the degree of impact on the operating performance. If the degree of impact on the operating performance of the memory usage object meets the target degree condition, it means that the operating performance of the memory usage object is greatly affected.
[0077] As an approach, the target degree condition includes at least one of the following conditions: the usage rate of the processing device by the memory usage object is lower than the usage rate threshold; the number of errors in the memory pages corresponding to the memory usage object is greater than the number threshold; and the increased time consumed by the memory usage object to execute the task is greater than the time threshold.
[0078] S240: If the memory usage object to which the current memory page to be replaced belongs is not the target memory usage object, the current memory page to be replaced is replaced.
[0079] The present embodiment provides a memory page processing method, so that in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the running performance of the target memory usage object due to the operation of replacing the memory page. In addition, in the present embodiment, when it is detected that the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, the degree of influence will be further detected, and then it is determined whether to abandon the replacement of the current memory page to be replaced according to the degree, so that the memory page can be processed more finely.
[0080] See also Figure 6 , an embodiment of the present application provides a memory page processing method, the method comprising:
[0081] S310: In response to the memory replacement instruction, start replacing the memory page.
[0082] S320: Obtain the memory usage object to which the current memory page to be replaced belongs.
[0083] S330: If the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, and the degree of occupancy of the target memory space by the memory usage object to which the current memory page to be replaced belongs is lower than the occupancy threshold, then the current memory page to be replaced will not be replaced, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
[0084] The target memory space can be understood as the target storage space that currently needs to perform memory page replacement. For example, if the memory replacement instruction is used to trigger the replacement of the memory in the memory compression area, then the target storage space refers to the memory compression area. If the memory replacement instruction is used to trigger the replacement of the entire memory, then the target storage space can be understood as the memory of the electronic device.
[0085] As one mode, the target memory space is the memory of the electronic device, or the target memory space is the available memory space configured by the electronic device for the memory usage object to which the current memory page to be replaced belongs.
[0086] The present embodiment provides a memory page processing method, so that in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the running performance of the target memory usage object due to the operation of replacing the memory page. In addition, in the present embodiment, when it is determined that the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, the degree of occupancy of the target memory space by the memory usage object to which the current memory page to be replaced belongs is further determined, and whether to replace the current memory page to be replaced is determined in combination with the occupancy degree, so that the memory page can be processed more finely.
[0087] See also Figure 7 , an embodiment of the present application provides a memory page processing method, the method comprising:
[0088] S410: In response to the memory replacement instruction, start replacing the memory page.
[0089] S420: Obtain the memory usage object to which the current memory page to be replaced belongs.
[0090] S430: If the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, the memory space that has been replaced in this memory replacement process is obtained.
[0091] S440: Check whether the replaced memory space meets the replacement target requirement.
[0092] S441: If the replaced memory space meets the replacement target requirement, no replacement operation is performed on the current memory page to be replaced, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
[0093] S442: If the replaced memory space does not meet the replacement target requirement, and the number of remaining memory pages to be replaced is lower than the target page threshold, a replacement operation is performed on the current memory page to be replaced.
[0094] It should be noted that the goal of the electronic device to replace the memory page is to free up more memory space. In this case, if there are more memory pages that are not replaced, it may cause the failure to meet the established memory recovery requirements. Therefore, when it is determined that the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, it can be further determined whether the currently replaced memory space meets the replacement target requirements. If so, the current memory page to be replaced can be skipped. In the case where the replacement target requirements are not met, and the number of remaining memory pages to be replaced is lower than the target page threshold, in order to free up more memory space, the memory page corresponding to the target memory usage object will still be replaced.
[0095] Among them, if the number of remaining memory pages to be replaced is lower than the target page threshold, it means that even if all the remaining memory pages to be replaced are replaced, the replacement target requirement cannot be met.
[0096] The present embodiment provides a memory page processing method, so that in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the running performance of the target memory usage object due to the operation of replacing the memory page. In addition, when it is determined that the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, it will be further detected whether the memory space replaced in this memory replacement process meets the demand, so as to determine whether to recycle the current memory page to be replaced according to whether the demand is met, so that the memory page can be processed more finely.
[0097] See also Figure 8 , a memory page processing device 500 provided in an embodiment of the present application runs on an electronic device, and the device 500 includes:
[0098] The replacement trigger unit 510 is used to start replacing memory pages in response to a memory replacement instruction.
[0099] The object acquisition unit 520 is used to acquire the memory usage object to which the current memory page to be replaced belongs.
[0100] The replacement processing unit 530 is used for not performing a replacement operation on the current memory page to be replaced if the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, and performing a replacement operation on the current memory page to be replaced if the memory usage object to which the current memory page to be replaced belongs is not a target memory usage object. The target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
[0101] As a method, the replacement processing unit 530 is specifically used to obtain the degree to which the running performance of the memory usage object to which the current memory page to be replaced belongs is affected if the memory usage object to which the current memory page to be replaced belongs is the target memory usage object; if the degree of impact meets the target degree condition, the replacement operation is not performed on the current memory page to be replaced.
[0102] Optionally, the target degree condition includes at least one of the following conditions: the usage rate of the processing device by the memory usage object is lower than the usage rate threshold; the number of errors in the memory pages corresponding to the memory usage object is greater than the number threshold; and the increased time consumed by the memory usage object to execute the task is greater than the time threshold.
[0103] As a method, the replacement processing unit 530 is specifically used to not perform a replacement operation on the current memory page to be replaced if the memory usage object to which the current memory page to be replaced belongs is a target memory usage object and the degree of occupancy of the target memory space by the memory usage object to which the current memory page to be replaced belongs is lower than an occupancy threshold. Optionally, the target memory space is the memory of the electronic device, or the target memory space is the memory space that the electronic device configures to be available for the memory usage object to which the current memory page to be replaced belongs.
[0104] As a method, the replacement processing unit 530 is specifically used to obtain the memory space that has been replaced during the current memory replacement process if the memory usage object to which the current memory page to be replaced belongs is the target memory usage object; if the memory space that has been replaced meets the replacement target requirement, then the replacement operation is not performed on the current memory page to be replaced. Optionally, if the memory space that has been replaced does not meet the replacement target requirement, and the number of remaining memory pages to be replaced is lower than the target page threshold, then the replacement operation is performed on the current memory page to be replaced.
[0105] A memory page processing device provided in this embodiment allows the memory page corresponding to the target memory usage object not to be replaced during the process of replacing the memory page, so as to avoid affecting the running performance of the target memory usage object due to the memory page replacement operation.
[0106] It should be noted that the device embodiment in the present application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.
[0107] The following will be combined Fig. 9 An electronic device provided by the present application is described.
[0108] See also Fig. 9 Based on the above-mentioned audio processing method and device, the embodiment of the present application also provides another electronic device 200 that can execute the above-mentioned audio processing method. The electronic device 200 includes one or more (only one is shown in the figure) processors 202, a memory 204, a network module 206, a sensor module 208 and an audio acquisition device 210 that are coupled to each other. Among them, the memory 204 stores a program that can execute the content of the above-mentioned embodiment, and the processor 202 can execute the program stored in the memory 204.
[0109] Among them, the processor 202 may include one or more processing cores. The processor 202 uses various interfaces and lines to connect various parts of the entire electronic device 200, and executes various functions and processes data of the electronic device 200 by running or executing instructions, programs, code sets or instruction sets stored in the memory 204, and calling data stored in the memory 204. Optionally, the processor 202 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 202 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 may not be integrated into the processor 202, but may be implemented separately through a communication chip.
[0110] The memory 204 may include a random access memory (RAM) or a read-only memory (ROM). The memory 204 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 204 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.
[0111] The network module 206 is used to implement information exchange between the electronic device 200 and other devices, for example, transmission of device control instructions, operation request instructions, and status information acquisition instructions, etc. When the electronic device 200 is specifically a different device, the corresponding network module 206 may be different.
[0112] The sensor module 208 may include at least one sensor. Specifically, the sensor module 208 may include but is not limited to: a light sensor, a motion sensor, a pressure sensor, an infrared heat sensor, a distance sensor, an acceleration sensor, and other sensors.
[0113] Among them, the pressure sensor can be a sensor that detects the pressure generated by pressing on the electronic device 200. That is, the pressure sensor detects the pressure generated by the contact or pressing between the user and the electronic device, such as the pressure generated by the contact or pressing between the user's ear and the mobile terminal. Therefore, the pressure sensor can be used to determine whether contact or pressing occurs between the user and the electronic device 200, and the magnitude of the pressure.
[0114] Among them, the acceleration sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary, and can be used for applications that recognize the posture of the electronic device 200 (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc. In addition, the electronic device 200 can also be equipped with other sensors such as gyroscopes, barometers, hygrometers, thermometers, etc., which will not be repeated here.
[0115] The audio acquisition device 210 is used to collect audio signals. Optionally, the audio acquisition device 210 includes a plurality of audio acquisition devices. The audio acquisition device may be a microphone. For example, in one embodiment, the audio acquisition device 210 may include two microphones, in which one of the microphones may correspond to an analog-to-digital converter, and the other microphone may correspond to an analog-to-digital converter with two different analog gains. In another embodiment, the audio acquisition device 210 may include three microphones. In this embodiment, two of the microphones (e.g., a main microphone and a secondary microphone) may each correspond to an analog-to-digital converter, and the other microphone (e.g., a camera microphone) may correspond to an analog-to-digital converter with two different analog gains.
[0116] As a way, the network module of the electronic device 200 is a radio frequency module, which is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices. The radio frequency module may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity modules (SIM) cards, memories, etc. For example, the radio frequency module can exchange information with an external device through the electromagnetic waves sent or received, and then receive audio signals sent by the external device.
[0117] Furthermore, the electronic device 200 may also include an image acquisition device for image acquisition, for example, a video, a static picture or a dynamic picture may be taken by the image acquisition device.
[0118] Please refer to Fig.10 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0119] The computer readable storage medium 800 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 800 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.
[0120] The present application provides a memory page processing method, device, and electronic device, which can obtain the memory usage object to which the current memory page to be replaced belongs after starting to replace the memory page in response to a memory replacement instruction, and if the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, then the current memory page to be replaced will not be replaced, wherein the target memory usage object is a memory usage object whose operating performance is affected after the corresponding memory page is replaced during the historical memory page replacement process. Thus, in the above manner, in the process of replacing the memory page, the memory page corresponding to the target memory usage object may not be replaced, so as to avoid affecting the operating performance of the target memory usage object due to the memory page replacement operation.
[0121] Among them, by recording and analyzing the historical swapping behavior of memory usage objects, the present application can effectively identify those memory usage objects that may cause a large number of page errors and performance degradation after swapping. In the next swapping decision, the system will avoid replacing the memory pages corresponding to these memory usage objects, thereby improving the overall performance of the system.
[0122] This application can reduce unnecessary memory swaps by making intelligent decisions about memory swaps, thereby making more efficient use of memory resources and improving resource utilization. In addition, by reducing memory swaps that may cause a large number of page errors, the number of page errors that the system needs to handle will be reduced, thereby reducing system overhead. This application also takes into account the historical swapping behavior of memory usage objects, and can self-adjust and optimize according to changes in the system's operating status, with good adaptability. This application reduces system fluctuations caused by frequent swaps by intelligently selecting swap objects, thereby improving system stability.
[0123] In addition, when deciding whether to replace a memory page, the present application can take into account the historical performance impact information of the memory usage object and manage memory resources more carefully and intelligently. Furthermore, the present technical solution can be used as a part of the operating system's memory management to improve the performance and stability of the operating system. In addition, in mobile devices, due to limited resources, the optimization of memory management is particularly important. The present technical solution can be used to optimize the memory management of mobile devices and improve the performance and battery life of the device. In addition, in real-time systems, the execution time of tasks is very critical, and the optimization of memory management can improve the execution efficiency of tasks. The present technical solution can be used to optimize the memory management of real-time systems.
[0124] 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 page processing method, characterized in that: Applied to electronic equipment, the method comprises: In response to the memory replacement instruction, starting to replace the memory page; Get the memory usage object to which the current memory page to be replaced belongs; If the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, the current memory page to be replaced will not be replaced, wherein the target memory usage object is a memory usage object whose operating performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
2. The method according to claim 1, characterized in that If the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, then no replacement operation is performed on the current memory page to be replaced, including: If the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, obtaining the degree to which the running performance of the memory usage object to which the current memory page to be replaced belongs is affected; If the affected degree meets the target degree condition, no replacement operation is performed on the current memory page to be replaced.
3. The method according to claim 2, characterized in that The target degree condition includes at least one of the following conditions: The usage rate of the memory usage object to the processing device is lower than the usage rate threshold; The number of errors in the memory pages corresponding to the memory usage object is greater than the number threshold; as well as The time taken by the memory usage object to execute the task is greater than the time threshold.
4. The method according to claim 1, characterized in that If the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, then no replacement operation is performed on the current memory page to be replaced, including: If the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, and the occupancy degree of the target memory space by the memory usage object to which the current memory page to be replaced belongs is lower than the occupancy threshold, the current memory page to be replaced is not replaced.
5. The method according to claim 4, characterized in that The target memory space is the memory of the electronic device, or the target memory space is the available memory space configured by the electronic device for the memory usage object to which the current memory page to be replaced belongs.
6. The method according to claim 1, characterized in that If the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, then no replacement operation is performed on the current memory page to be replaced, including: If the memory usage object to which the current memory page to be replaced belongs is the target memory usage object, obtaining the memory space that has been replaced during this memory replacement process; If the memory space that has been replaced meets the replacement target requirement, no replacement operation is performed on the current memory page to be replaced.
7. The method according to claim 6, characterized in that The method further comprises: If the replaced memory space does not meet the replacement target requirement, and the number of remaining memory pages to be replaced is lower than the target page threshold, a replacement operation is performed on the current memory page to be replaced.
8. The method according to claim 1, characterized in that The method further comprises: If the memory usage object to which the current memory page to be replaced belongs is not the target memory usage object, a replacement operation is performed on the current memory page to be replaced.
9. The method according to claim 1, characterized in that: The memory usage object is an application program, or a program group, and the program group includes at least one application program.
10. A memory page processing device, characterized in that: Running on an electronic device, the device comprises: A replacement trigger unit, used to start replacing memory pages in response to a memory replacement instruction; An object acquisition unit, used to acquire a memory usage object to which the current memory page to be replaced belongs; A replacement processing unit is used for not performing a replacement operation on the current memory page to be replaced if the memory usage object to which the current memory page to be replaced belongs is a target memory usage object, wherein the target memory usage object is a memory usage object whose running performance is affected after the corresponding memory page is replaced during the historical memory page replacement process.
11. An electronic device, characterized in that: The method comprises one or more processors and a memory; one or more programs are stored in the memory and are configured so that the one or more processors execute any one of the methods of claims 1-9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is executed by a processor, the method according to any one of claims 1 to 9 is executed.