Memory monitoring method and device
By obtaining the resident physical memory RSS of the process and determining the PSS or USS according to the preset correction value, the problem of high memory monitoring resource overhead in the existing technology is solved, and the smooth operation of the terminal device is realized.
Patent Information
- Application Number
- CN202310187242.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2024-08-23
AI Technical Summary
Existing memory monitoring methods cause high resource overhead by frequently querying the PSS or USS of the process, causing problems such as freezing and heating of the terminal device.
By obtaining the resident physical memory RSS occupied by the process and determining the PSS or USS based on the preset correction value, resource overhead is reduced and the terminal device is guaranteed to run smoothly.
It achieves efficient determination of memory usage without directly obtaining PSS or USS, reduces resource overhead, and ensures smooth operation of terminal equipment.
Smart Images

Figure CN118535409A
Abstract
Description
Technical Field
[0001] The present application relates to the field of communications, and in particular to a memory monitoring method and device. Background Art
[0002] With the development of technology, OEMs pay more and more attention to the monitoring of process system resource usage. Among them, process memory, as an important member of process system resources, is monitored in real time to obtain real-time monitoring results. The real-time monitoring results can be used in scenarios such as system performance optimization, memory leak detection, and degradation repair. Real-time monitoring of process memory is obtained by frequently obtaining the size of the memory occupied by the process. The three common indicators for measuring the size of the memory occupied by the process are proportional physical memory (PSS), also known as the memory occupied by the proportional allocation shared library, the physical memory occupied by the process alone (USS), also known as the memory not including the shared library, and the resident physical memory (RSS), also known as the memory occupied by all shared libraries. Among these three indicators, PSS and USS are more suitable for memory monitoring scenarios. In monitoring scenarios, the PSS or USS of the process is usually polled regularly as the real-time monitoring result.
[0003] In the existing memory monitoring method, the query resource overhead of the PSS or USS of the polling process is large, which may cause problems such as freezing and heating of the terminal device. Summary of the invention
[0004] The present application provides a memory monitoring method and device, which has low resource overhead during monitoring and can ensure smooth operation of terminal devices.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a memory monitoring method is provided, the method comprising: obtaining a first resident physical memory RSS occupied by a process; and determining a first memory including a first PSS and / or a first USS according to the first RSS.
[0007] In the first aspect, the first resident physical memory RSS occupied by the process is first obtained, and then the first memory (first PSS and / or first USS) is determined based on the first RSS. The PSS or USS can be determined by obtaining the RSS without obtaining the PSS or USS. The required resource overhead is small, which can ensure the smooth operation of the terminal device.
[0008] In a possible implementation, determining the first memory according to the first RSS includes: determining the first memory according to the first RSS and a preset correction value corresponding to a memory type of the first memory.
[0009] In this implementation, the first memory is determined according to the first RSS and the preset correction value. The first memory can be efficiently determined by obtaining the RSS without obtaining the PSS or the USS.
[0010] In a possible implementation, obtaining a first RSS occupied by a process includes: obtaining the first RSS occupied by the process through a preset node.
[0011] In this implementation, the first RSS occupied by the process is obtained through a preset node, and the efficiency of obtaining the first RSS is relatively high.
[0012] In one possible implementation, the preset correction value includes a PSS correction value and / or a USS correction value, the PSS correction value is calculated based on the second RSS and the second PSS, and the USS correction value is calculated based on the second RSS and the second USS, wherein the second RSS, the second PSS, and the second USS are acquired before the first RSS occupied by the acquisition process.
[0013] In this implementation, the preset correction value is calculated using the second RSS, the second PSS, and the second USS obtained before obtaining the first RSS, which can ensure that the preset correction value in the same process has a high accuracy.
[0014] In a possible implementation, after determining the first memory according to the preset correction value and the first RSS, the method further includes: updating the preset correction value.
[0015] In this implementation, after the first memory is determined according to the first RSS and the preset correction value, the preset correction value is updated, which can ensure the accuracy of the preset correction value.
[0016] In a possible implementation, updating the preset correction value includes: updating the preset correction value according to a preset update frequency.
[0017] In this implementation, after the first memory is determined according to the first RSS and the preset correction value, the preset correction value is updated according to the preset update frequency, so that the accuracy of the preset correction value can be ensured.
[0018] In a possible implementation, the method also includes: when the first memory meets the preset memory exception condition, obtaining the second memory occupied by the process with the same memory type as the first memory; the second memory is obtained by accumulating the size of the number of pages of the virtual memory area linked list corresponding to the process; when the second memory does not meet the preset memory exception condition, adjusting the preset update frequency.
[0019] In this implementation, when the first memory meets the preset memory exception condition, the second memory occupied by the process is obtained, and when the second memory does not meet the preset memory exception condition, the preset update frequency of the preset correction value is adjusted, so as to ensure the accuracy of the preset correction value.
[0020] In a possible implementation, different software information processes correspond to different or the same preset update frequencies.
[0021] In this implementation, processes of different software information correspond to different or the same preset update frequencies, so that the update frequency of the preset correction value is suitable for the corresponding process, thereby ensuring the accuracy of the preset correction value.
[0022] In one possible implementation, updating the preset correction value includes: when the first memory meets the preset memory exception condition, executing the first operation for optimizing the memory occupied by the process; obtaining the third memory occupied by the process of the same memory type as the first memory; and updating the preset correction value when the difference between the third memory and the first memory does not meet the preset condition.
[0023] In this implementation, when the first memory meets the preset memory exception condition, the first operation for optimizing the memory occupied by the process is performed, and then the third memory occupied by the process is obtained, and when the difference between the third memory and the first memory does not meet the preset condition, the preset correction value is updated, thereby ensuring the accuracy of the preset correction value.
[0024] In a possible implementation, the method further includes: when the shared memory occupied by the process has not been completely allocated and the preset correction value needs to be updated, updating the preset correction value after a second preset time delay.
[0025] In this implementation, when the shared memory occupied by the process has not been allocated and the preset correction value needs to be updated, the updating of the preset correction value is delayed after a second preset time, thereby avoiding unnecessary updating of the preset correction value and saving terminal computing power.
[0026] In one possible implementation, obtaining the first RSS occupied by a process includes: obtaining the first RSS occupied by the process when the process is created; or obtaining the first RSS occupied by the process according to a first preset time; or obtaining the first RSS occupied by the process when the system memory meets a preset memory threshold; or obtaining the first RSS occupied by the process when a system component generates a memory acquisition request.
[0027] In this implementation, several possible opportunities for obtaining the first RSS are introduced, and the first RSS can be obtained in time based on the several possible opportunities.
[0028] In a second aspect, a memory monitoring device is provided, which may be a chip or a system on chip of a terminal device, and the device includes: a processing module, used to obtain a first resident physical memory RSS occupied by a process; the processing module is also used to determine a first memory based on the first RSS, the first memory including a first proportional physical memory PSS and / or a physical memory USS occupied solely by the first process.
[0029] In a possible implementation, the processing module is specifically configured to: determine the first memory according to the first RSS and a preset correction value, wherein the preset correction value corresponds to a memory type of the first memory.
[0030] In a possible implementation, the processing module is specifically configured to: obtain a first RSS occupied by a process through a preset node.
[0031] In one possible implementation, the preset correction value includes a PSS correction value and / or a USS correction value, the PSS correction value is calculated based on the second RSS and the second PSS, and the USS correction value is calculated based on the second RSS and the second USS, wherein the second RSS, the second PSS, and the second USS are acquired before the first RSS occupied by the acquisition process.
[0032] In a possible implementation, the processing module is further configured to: after determining the first memory according to the preset correction value and the first RSS, update the preset correction value.
[0033] In a possible implementation, the processing module is specifically configured to update the preset correction value according to a preset update frequency.
[0034] In a possible implementation, the processing module is also used to: when the first memory meets the preset memory exception condition, obtain the second memory occupied by the process, the second memory has the same memory type as the first memory; the second memory is obtained by accumulating the size of the number of pages of the virtual memory area linked list corresponding to the process; when the second memory does not meet the preset memory exception condition, adjust the preset update frequency.
[0035] In a possible implementation, different software information processes correspond to different or the same preset update frequencies.
[0036] In one possible implementation, the processing module is specifically used to: execute a first operation when a first memory meets a preset memory exception condition, and the first operation is used to optimize the memory occupied by the process; obtain a third memory occupied by the process, and the memory type of the third memory is the same as that of the first memory; and update a preset correction value when the difference between the third memory and the first memory does not meet the preset condition.
[0037] In a possible implementation, the processing module is further used to: when the shared memory occupied by the process has not been completely allocated and the preset correction value needs to be updated, update the preset correction value after a second preset time delay.
[0038] In one possible implementation, the processing module is specifically used to: obtain the first RSS occupied by the process when the process is created; or obtain the first RSS occupied by the process according to a first preset time; or obtain the first RSS occupied by the process when the system memory meets the preset memory threshold; or obtain the first RSS occupied by the process when the system component generates a memory acquisition request.
[0039] In a third aspect, the present application provides a memory monitoring device, the memory monitoring device includes a processor, the processor is used to support the memory monitoring device to execute the method of the first aspect. Further, the memory monitoring device may also include a memory, the memory stores computer instructions, and the processor can execute the computer instructions to execute the method of the first aspect.
[0040] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed, the method of the first aspect is executed.
[0041] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method of the first aspect.
[0042] In a sixth aspect, the present application provides a chip, comprising a processor, and the processor is used to support a memory monitoring device to execute the method of the first aspect.
[0043] Among them, the beneficial effects described in the second to sixth aspects of the present application can refer to the analysis of the beneficial effects of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 1 ;
[0045] Figure 2 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 2 ;
[0046] Figure 3 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 3 ;
[0047] Figure 4 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 4;
[0048] Figure 5 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 5 ;
[0049] Figure 6 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 6 ;
[0050] Figure 7 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 7 ;
[0051] Figure 8 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 8 ;
[0052] Fig. 9 A schematic diagram of a memory monitoring method provided in an embodiment of the present application Figure 9 ;
[0053] Fig.10 A schematic diagram of the structure of a memory monitoring device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0055] Before introducing the embodiments of the present application, some terms involved in the embodiments of the present application are explained.
[0056] PSS: The sum of the PSS occupied by all processes is exactly the memory usage of the entire machine, which is suitable for measuring memory size in most cases. When querying PSS, it is necessary to traverse the virtual memory area (vma) linked list and accumulate the number of pages corresponding to the process, which occupies more query resources and takes a long time.
[0057] USS: Because it does not contain other shared library content, it is suitable for detecting memory expansion, memory leaks and other problems. When querying USS, it is necessary to traverse the vma linked list and accumulate the corresponding number of pages, which occupies more query resources and takes a long time.
[0058] RSS: Directly add the number of file pages, anonymous pages, and shared memory pages corresponding to the process. When querying RSS, it takes up less query resources and takes less time.
[0059] The following is an example to explain PSS, USS, and RSS. Assume that a system has only two processes: process1 (independent memory usage is 5M), process2 (independent memory usage is 5M), and a shared library test.so (this file is 10M, 3M of which is loaded into memory). Taking process1 as an example, its occupied PSS, USS, and RSS are shown in Table 1:
[0060] Table 1
[0061]
[0062] In monitoring scenarios, the PSS or USS of a process is usually polled periodically as a real-time monitoring result. Taking the Android system as an example, the PSS or USS of a process is polled through the Android Application Profiler. Android Application Profiler is an Android native application memory information monitoring module that collects the PSS or USS occupied by a process through periodic queries. Specifically, the PSS / USS value of a process is queried through the proc / pid / smaps node. When querying the PSS or USS occupied by multiple processes, the query resource overhead is large, which can cause problems such as freezing and heating of the terminal device.
[0063] In order to solve the above technical problems, the embodiment of the present application provides a memory monitoring method, which obtains the RSS occupied by the process and determines the PSS or USS occupied by the process according to the preset correction value and RSS. Compared with directly collecting the PSS or USS occupied by the process, the resource overhead during monitoring is reduced, and the smooth operation of the terminal device can be ensured. The method provided by the embodiment of the present application is described below in conjunction with the drawings of the specification.
[0064] The execution subject of the memory monitoring method provided in the embodiment of the present application may be a terminal device (terminal equipment). The terminal device may be a user equipment (UE), a mobile station (MS) or a mobile terminal (MT), etc. Specifically, the terminal device may be a mobile phone, a tablet computer or a computer with a wireless transceiver function, or a virtual reality (VR) terminal, an augmented reality (AR) terminal, a wireless terminal in industrial control, a wireless terminal in unmanned driving, a wireless terminal in telemedicine, a wireless terminal in a smart grid, a wireless terminal in a smart city, a smart home, or a vehicle-mounted terminal, etc. In the embodiment of the present application, the device for realizing the function of the terminal device may be a terminal device, or may be a device that can support the terminal device to realize the function, such as a chip system, which may be installed in the terminal device or used in combination with the terminal device. The present application does not limit the execution subject of the memory monitoring method. The following describes the method provided in the embodiment of the present application by taking the device for realizing the function of the terminal device as a terminal device as an example.
[0065] Figure 1 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 1 .like Figure 1 As shown, the method may include the following steps:
[0066] S110, obtaining the first resident physical memory RSS occupied by the process.
[0067] Among them, the current RSS is obtained through the proc / pid / smaps node. The proc / pid / smaps node will perform vma traversal during collection, scan each vma node and accumulate the number of pages corresponding to the process to obtain RSS. This is an O(n) algorithm operation. The larger the process memory usage, the longer the collection time, which is very time-consuming. The embodiment of the present application directly obtains the first RSS from the kernel. Specifically, the number of file pages, anonymous pages, and shared memory pages belonging to the process is directly read, and the read contents are added to obtain the first RSS. The operation speed is the speed of the O(1) algorithm. No matter how large the process memory usage is, the collection time is a constant value, and the value is very small.
[0068] S120, determining a first memory according to the first RSS.
[0069] Among them, combined with the example of Table 1, it can be seen that in the same process, RSS, PSS, and USS have a numerical correspondence. Based on the numerical correspondence, the first memory including the first PSS and / or the first USS can be determined according to the first RSS. The specific memory type of the first memory can be pre-set according to the monitoring scene requirements, and can include the first PSS, the first USS, or the first PSS and the first USS.
[0070] The determined first memory can be viewed through system logs, kernel logs, systrace or kernel flame graphs. After testing, the current method of collecting RSS, PSS (or USS) through the proc / pid / smaps node and the method provided by the embodiment of the present application are simultaneously executed on the same process. After comparison, the RSS collected by the two methods is the same, and the PSS (or USS) determined respectively is generally different, but relatively close.
[0071] In an embodiment of the present application, the first resident physical memory RSS occupied by the process is first obtained, and then the first memory (first PSS and / or first USS) is determined based on the first RSS. The PSS or USS can be determined by obtaining the RSS without obtaining the PSS or USS. The required resource overhead is relatively small, and the smooth operation of the terminal device can be ensured.
[0072] In one embodiment, if Figure 2 As shown, Figure 2 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 2 , S110 may include: S210, obtaining a first RSS occupied by the process through a preset node.
[0073] The preset node may be a node dedicated to obtaining the first resident physical memory RSS occupied by the process, and is used to obtain the first RSS. The node may be set in the kernel in the form of a folder to read the file pages, anonymous pages, and shared memory pages belonging to the process, and add the read contents to obtain the first RSS. Exemplarily, it may be set to proc / pid / rss.
[0074] In the embodiment of the present application, the first RSS occupied by the process is obtained by using a preset node, and the efficiency of obtaining the first RSS is relatively high.
[0075] In one embodiment, the first RSS occupied by the process in S110 may be obtained at the following times:
[0076] The first RSS occupied by the process can be obtained when the process is created. When the process is created, it is necessary to monitor the PSS or USS, and then the first RSS can be obtained at this time to determine the first PSS or the first USS.
[0077] The first RSS occupied by the process can also be obtained regularly according to a first preset time, and the first preset time can be preset. The first preset time can be set specifically according to the software information corresponding to the process, and processes with different software information can correspond to different or the same first preset time. Exemplarily, the first preset time can be set to every 5 seconds.
[0078] You can also get the first RSS of the process when the system memory meets the preset memory threshold. This scenario generally corresponds to a scenario with high system memory pressure. For example, if the physical memory capacity of a mobile phone is 8G, when 7G is occupied, the system memory pressure is high and the system memory is considered to meet the preset memory threshold. The preset memory threshold can be flexibly customized according to the system memory capacity of the terminal.
[0079] In addition, when the system component generates a memory acquisition request, the first RSS occupied by the process can be acquired. During the operation of the system component, there may be a scenario where the first PSS or the first USS needs to be acquired. In this case, the system component will generate a memory acquisition request, which can request the first PSS, the first USS, or both the first PSS and the first USS.
[0080] In the embodiments of the present application, several possible opportunities for obtaining the first RSS are introduced, and the first RSS can be obtained in a timely manner based on the several possible opportunities.
[0081] In one embodiment, if Figure 3 As shown, Figure 3 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 3 S120: Determining the first memory according to the first RSS may include:
[0082] S310, determining a first memory according to a first RSS and a preset correction value.
[0083] The preset correction value corresponds to the memory type of the first memory. Exemplarily, if the first memory includes a first PSS, the preset correction value is a PSS correction value for correcting the PSS; if the first memory includes a first USS, the preset correction value is a USS correction value for correcting the USS; if the first memory includes a first PSS and a first USS, the preset correction value includes a PSS correction value and a USS correction value.
[0084] It can be seen from the example in Table 1 that the RSS, PSS and USS occupied by the process of the same software have a numerical correspondence, and the preset correction value can indicate the numerical correspondence, and the first memory can be determined based on the preset correction value and the first RSS. Exemplarily, the preset correction value can represent the difference between the first memory and the first RSS, and the PSS correction value corresponding to the first PSS is OFFSETpss, then the first PSS = first RSS-OFFSETpss; the USS correction value corresponding to the first USS is OFFSETuss, then the first USS = first RSS-OFFSETuss. For another example, the preset correction value can also represent the percentage of the first memory relative to the first RSS, and the PSS correction value corresponding to the first PSS is OFFSETpss, then the first PSS = first RSS×OFFSETpss; the USS correction value corresponding to the first USS is OFFSETuss, then the first USS = first RSS×OFFSETuss. For another example, the preset correction value can also represent the percentage of the first memory relative to the first RSS, and the PSS correction value corresponding to the first PSS is OFFSETpss, then the first PSS = first RSS×OFFSETpss; the USS correction value corresponding to the first USS is OFFSETuss, then the first USS = first RSS×OFFSETuss.
[0085] In the embodiment of the present application, the first memory is determined according to the first RSS and the preset correction value. The first memory can be efficiently determined by obtaining the RSS without obtaining the PSS or the USS.
[0086] In step S310, the role of the preset correction value in determining the first memory is introduced from the perspective of application. Before applying the preset correction value, the preset correction value needs to be determined first. The process of determining the preset correction value will be described below.
[0087] In one embodiment, when determining the first memory, a PSS correction value and / or a USS correction value needs to be applied, such as Figure 4 As shown, Figure 4 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 4 Before S110, the method may further include:
[0088] S410, obtaining a second RSS occupied by the process, and obtaining a second PSS and / or a second USS occupied by the process.
[0089] Among them, the process described in S410 is the same process as the process described in S110. Referring to the description of S210, the second RSS occupied by the process can be read through the customized kernel node proc / pid / rss. The second PSS and the second USS can be obtained through the proc / pid / smaps node. The difference between the second PSS and the first PSS (the second USS and the first USS) is that the acquisition (determination) time of the two is different, the former is earlier and the latter is later, and the former is actually read through the kernel node proc / pid / smaps (or proc / pid / rss), while the latter is determined by the preset correction value and the first RSS (which can be understood as estimated).
[0090] S420, calculating a PSS correction value according to the second RSS and the second PSS, and / or calculating a USS correction value according to the second RSS and the second USS.
[0091] Among them, it can be seen from the example in Table 1 that there is a numerical correspondence between the RSS, PSS and USS occupied by the process of the same software. Based on the numerical correspondence, the PSS correction value and the USS correction value can be determined. Using the example in the S310 description, the PSS correction value corresponding to the first PSS is OFFSETpss, then OFFSETpss = second RSS-second PSS; the USS correction value corresponding to the first USS is OFFSETuss, then OFFSETuss = second RSS-second USS.
[0092] In the embodiment of the present application, the preset correction value is calculated based on the second RSS, the second PSS, and the second USS obtained before obtaining the first RSS, which can ensure that the preset correction value in the same process has high accuracy.
[0093] In steps S410-S420, how to obtain the preset correction value is introduced from the perspective of generation. After the preset correction value is generated and applied in S310, as the process runs, the preset correction value generated at an earlier time may not accurately reflect the data correspondence between RSS, PSS, and USS at the current time. In order to improve the accuracy of the preset correction value, Figure 5 As shown, Figure 5 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 5 After S310, the embodiment of the present application may further include:
[0094] S510, updating the preset correction value.
[0095] Among them, the principle of updating the preset correction value can refer to the instructions for calculating the preset correction value introduced in S410-S420. The difference is that the time for taking RSS, PSS, and USS has changed. The specific calculation process is the same and will not be repeated.
[0096] Furthermore, the preset correction value can be updated according to a preset update frequency. The preset update frequency can be flexibly set for different software information, and different software information processes can correspond to different or the same preset update frequencies. The software information includes the software version and the system applicable to the software. The update frequency of the preset correction value is made applicable to the corresponding process, thereby ensuring the accuracy of the preset correction value.
[0097] Exemplarily, the preset update frequencies corresponding to Software A for Android, version 1.0 and Software B for Android, version 1.0 may be once every 5 minutes and once every 30 minutes respectively; the preset update frequencies corresponding to Software A for Android, version 1.0 and Software A for Android, version 2.0 may be once every 5 minutes and once every 6 minutes respectively; the preset update frequencies corresponding to Software A for Android, version 1.0 and Software A for Mac, version 1.0 may be once every 10 minutes and once every 6 minutes respectively.
[0098] In the embodiment of the present application, after the first memory is determined according to the first RSS and the preset correction value, the preset correction value is updated to ensure the accuracy of the preset correction value.
[0099] In one embodiment, in order to further improve the accuracy of the preset correction value, the update frequency of the preset correction value can also be adjusted. Figure 6 As shown, Figure 6 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 6 , the method may further include:
[0100] S610: When the first memory meets a preset memory abnormality condition, obtain a second memory occupied by the process.
[0101] Among them, the preset memory abnormality conditions may include that the memory of the process increases rapidly in a short period of time (memory leak) or accumulates little by little over a long period of time without self-recycling (memory expansion). The second memory has the same memory type as the first memory. For example, if the memory type of the first memory includes PSS, the memory type of the second memory also includes PSS; if the memory type of the first memory includes PSS and USS, the memory type of the second memory also includes PSS and USS. The second memory is obtained by accumulating the size of the vma linked list pages corresponding to the process, that is, the second memory is actually read.
[0102] S620: When the second memory does not meet the preset memory abnormality condition, adjust the preset update frequency.
[0103] Among them, the second memory is actually read, and its non-abnormality indicates that the memory is actually not abnormal, while the first memory meets the preset memory abnormality condition. This means that the first memory determined by the preset correction value is not accurate, and the preset update frequency of the original preset correction value may be low, resulting in low accuracy of the preset correction value. In this case, adjust the preset update frequency to ensure the accuracy of the preset correction value.
[0104] In an embodiment of the present application, when the first memory meets the preset memory exception condition, the second memory occupied by the process is obtained, and when the second memory does not meet the preset memory exception condition, the preset update frequency of the preset correction value is adjusted, so as to ensure the accuracy of the preset correction value.
[0105] In one embodiment, a strategy for triggering the update of the preset correction value is also provided. Figure 7 As shown, Figure 7 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 7 , S510 may include:
[0106] S710: Execute a first operation when the first memory meets a preset memory abnormality condition.
[0107] Among them, the first operation is used to optimize the memory occupied by the process. Optimizing the memory occupied by the process can clear the memory anomaly. For example, the first operation can start the process cleanup interface or restart the process, etc. Both can clear the process garbage to achieve the purpose of optimizing the memory occupied by the process.
[0108] S720, obtain the third memory occupied by the process.
[0109] The memory type of the third memory is the same as that of the first memory. For example, if the memory type of the first memory includes PSS, the memory type of the third memory also includes PSS; if the memory type of the first memory includes PSS and USS, the memory type of the third memory also includes PSS and USS. The third memory is obtained by accumulating the size of the vma linked list page number corresponding to the process, that is, the third memory is actually read.
[0110] S730: When the difference between the third memory and the first memory does not meet the preset condition, update the preset correction value.
[0111] Among them, if the memory is abnormal, after optimizing the memory occupied by the process, the memory occupied by the process is usually much different from the memory before optimization. If the accuracy of the preset correction value is high, the third memory obtained after optimizing the memory occupied by the process should also have a large difference with the first memory. The preset condition is used to determine whether the difference between the first memory and the third memory is "large enough". The preset condition can be flexibly set for different software information, and the processes of different software information can correspond to different or the same preset conditions. For example, when the process of a certain software A occupies more than 1000MB of memory during operation, the memory occupied can be reduced to about 800MB after optimizing the memory occupied by the process, then the preset condition can be set to be greater than 100MB. If the difference between the third memory and the first memory does not meet the preset condition, it means that the accuracy of the preset correction value is not enough, and the first memory determined by the preset correction value does not match the corresponding actual memory. In this case, update the preset correction value to ensure the accuracy of the preset correction value.
[0112] In an embodiment of the present application, when the first memory meets the preset memory exception condition, the first operation for optimizing the memory occupied by the process is performed, and then the third memory occupied by the process is obtained, and when the difference between the third memory and the first memory does not meet the preset condition, the preset correction value is updated, thereby ensuring the accuracy of the preset correction value.
[0113] In one embodiment, if Figure 8 As shown, Figure 8 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 8 , the embodiment of the present application may also include:
[0114] S810, when the shared memory occupied by the process has not been completely allocated and the preset correction value needs to be updated, execute S510 after a second preset time delay.
[0115] Among them, the shared memory occupied by the process has not been allocated to the end, for example, the process has just started, the priority (adjustment, adj) score of the process has been switched, etc. In this case, since the shared memory is allocated in real time, the memory occupied by the process fluctuates greatly, and the updated preset correction value has a poor matching degree for the memory after the shared memory allocation is completed. If the shared memory occupied by the process has not been allocated to the end and the preset correction value needs to be updated, the update of the preset correction value is executed after the second preset time is delayed, eliminating unnecessary updates of the preset correction value and saving terminal computing power. The second preset time can be flexibly set for different software information, and the processes of different software information can correspond to different or the same second preset time. For example, the time required for the shared memory occupied by the process of a certain software A to be allocated is generally about 20S, then the second preset time can be set to 30s.
[0116] In an embodiment of the present application, when the shared memory occupied by the process has not been allocated and the preset correction value needs to be updated, the updating of the preset correction value is delayed after a second preset time, thereby avoiding unnecessary updates of the preset correction value and saving terminal computing power.
[0117] In one embodiment, some or all of the parameters obtained and determined in the various embodiments of the present application (for example, the first RSS, the first memory, the preset correction value, the second RSS, the second PSS, and the second USS, etc.) can be used for big data analysis to adjust some or all of the adjustable parameters set in the embodiments of the present application (for example, the preset update frequency, the preset memory abnormality condition, the preset condition, the first preset time, and the second preset time, etc.) to improve the accuracy of the output first memory. When performing big data analysis, training can be performed with the help of a big data analysis model to adjust the adjustable parameters, such as a neural network model. Specifically, the adjustable parameters are used as model parameters, the parameters obtained in the various embodiments of the present application are used as label data, and the parameters determined in the various embodiments of the present application are used as training data, and iterative training is performed to adjust the adjustable parameters until the model converges. The adjustable parameters at this time are the adjusted adjustable parameters. The specific training method of the neural network model is relatively mature, and the corresponding prior art can be referred to, and no further description is given.
[0118] To help understanding, the above embodiments respectively introduce the memory monitoring method provided by the embodiments of the present application from different perspectives. To help further understanding, the following summarizes some of the processes in the above embodiments to provide a general description of the memory monitoring method provided by the embodiments of the present application. In each step of the general description, the specific description and corresponding beneficial effects can be referred to the description of the above embodiments, and will not be repeated here. Accordingly, in one embodiment, if Fig. 9 As shown, Fig. 9 The following is a schematic diagram showing the process of the memory monitoring method provided in the embodiment of the present application. Figure 9 , the method provided in the embodiment of the present application may also include:
[0119] S910: Generate a memory monitoring task for the process.
[0120] The scenario for generating the memory monitoring task of the process may be when the process is created, when the first preset time is met, when the system memory meets the preset memory threshold, when the system component generates a memory acquisition request, and the like.
[0121] S920, determining whether there is a preset correction value corresponding to the process.
[0122] If it exists, execute S930; if it does not exist, execute S940.
[0123] The preset correction value may be associated with the process and stored in the storage medium of the terminal.
[0124] S930: Determine whether the preset correction value needs to be updated.
[0125] If necessary, execute S940; if not necessary, execute S950.
[0126] S940, obtaining the RSS occupied by the process; and obtaining the PSS and / or USS; and calculating a PSS correction value based on the RSS and the PSS, and / or, calculating a USS correction value based on the RSS and the USS.
[0127] Among them, the specific description of S940 can refer to the description of calculating the preset correction value in S410-S420 in the embodiment of the present application.
[0128] S950, obtaining the RSS occupied by the process, and determining the PSS and / or USS according to a preset correction value.
[0129] Among them, the specific description of S950 can refer to the description of steps S110-S120, S130, etc. in the embodiments of the present application.
[0130] S960, output PSS and / or USS.
[0131] In the embodiments of the present application, means for outputting PSS and / or USS are designed for situations where a preset correction value corresponding to a process exists or does not exist, thereby ensuring stable output of PSS and / or USS.
[0132] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the execution process. It is understandable that in order to realize the above functions, the terminal device includes a hardware structure and / or software module corresponding to each function. Those skilled in the art should easily realize that, in combination with the algorithm steps of each example described in the embodiment disclosed in this article, the method of the embodiment of the present application can be implemented in the form of hardware, software, or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0133] The embodiment of the present application can divide the functional modules of the terminal device according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0134] In specific implementation, each network element shown in this application, such as: terminal equipment can be used Fig.10 The structure shown may include Fig.10 Parts shown. Fig.10 A structural schematic diagram of a memory monitoring device provided in an embodiment of the present application. When the memory monitoring device has the function of the terminal device described in the embodiment of the present application, the memory monitoring device can be a terminal device or a chip or system on chip in the terminal device.
[0135] like Fig.10 As shown, the memory monitoring device may include a processor 101, a communication line 102, a transceiver 103, and a memory 104. The processor 101, the memory 104, and the transceiver 103 may be connected via the communication line 102. In an example, the processor 101 may include one or more CPUs, such as Fig.10 CPU0 and CPU1 in.
[0136] As an optional implementation, the memory monitoring device includes multiple processors, for example, Fig.10 In addition to the processor 101, a processor 107 may also be included.
[0137] The processor 101 may be a central processing unit (CPU), a general-purpose processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 101 may also be other devices with processing functions, such as circuits, devices, or software modules.
[0138] The communication line 102 is used to transmit information between the components included in the memory monitoring device.
[0139] The transceiver 103 is used to communicate with other devices or other communication networks. The other communication networks may be Ethernet, radio access network (RAN), wireless local area network (WLAN), etc. The transceiver 103 may be an interface circuit, a pin, a radio frequency module, a transceiver or any device capable of achieving communication.
[0140] Furthermore, the memory monitoring device may also include a memory 104. The memory 104 is used to store instructions, wherein the instructions may be computer programs.
[0141] Among them, the memory 104 can be a read-only memory (ROM) or other types of static storage devices that can store static information and / or instructions, or a random access memory (RAM) or other types of dynamic storage devices that can store information and / or instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage, magnetic disk storage media or other magnetic storage devices, and the optical disc storage includes a compressed optical disc, a laser disc, an optical disc, a digital versatile disc, or a Blu-ray disc, etc.
[0142] It should be noted that the memory 104 can exist independently of the processor 101, or can be integrated with the processor 101. The memory 104 can be used to store instructions or program codes or some data, etc. The memory 104 can be located in the memory monitoring device, or can be located outside the memory monitoring device, without limitation. When the processor 101 executes the instructions stored in the memory 104, the method provided in the embodiment of the present application can be implemented.
[0143] As an optional implementation, the memory monitoring apparatus further includes an output device 105 and an input device 106. Exemplarily, the input device 106 is a touch panel, a microphone, and the like, and the output device 105 is a display screen, a speaker, and the like.
[0144] It should be noted that the memory monitoring device can be a desktop computer, a portable computer, a network server, a mobile phone, a tablet computer, a wireless terminal, an embedded device, a chip system or a Fig.10 In addition, Fig.10 The composition structure shown in the figure does not constitute a limitation on the memory monitoring device, except Fig.10 In addition to the components shown, the memory monitoring device may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0145] In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.
[0146] The embodiment of the present application also provides a memory monitoring device, which is applied to a terminal device. Each module in the memory monitoring device has the function of implementing the corresponding steps in the embodiment of the method of the present application, and can achieve its corresponding technical effect. The corresponding beneficial effects of the execution steps of each module can refer to the description of the corresponding steps in the embodiment of the method of the present application, and will not be repeated here. The function can be implemented by hardware, or by hardware executing the corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The memory monitoring device can be a terminal device or a chip or system on chip in the terminal device. For example, the memory monitoring device includes:
[0147] The processing module is used to obtain the first resident physical memory RSS occupied by the process; the processing module is also used to determine the first memory according to the first RSS, and the first memory includes the first proportional physical memory PSS and / or the physical memory USS occupied by the first process alone.
[0148] In one embodiment, the processing module is specifically used to: determine the first memory according to the first RSS and a preset correction value, wherein the preset correction value corresponds to the memory type of the first memory.
[0149] In one embodiment, the processing module is specifically used to: obtain the first RSS occupied by the process through a preset node.
[0150] In one embodiment, the preset correction value includes a PSS correction value and / or a USS correction value, the PSS correction value is calculated based on the second RSS and the second PSS, and the USS correction value is calculated based on the second RSS and the second USS, wherein the second RSS, the second PSS, and the second USS are acquired before the first RSS occupied by the acquisition process.
[0151] In one embodiment, the processing module is further used to: after determining the first memory according to the preset correction value and the first RSS, update the preset correction value.
[0152] In one embodiment, the processing module is specifically configured to update the preset correction value according to a preset update frequency.
[0153] In one embodiment, the processing module is also used to: when the first memory meets the preset memory exception condition, obtain the second memory occupied by the process, the second memory has the same memory type as the first memory; the second memory is obtained by accumulating the size of the vma linked list pages corresponding to the process; when the second memory does not meet the preset memory exception condition, adjust the preset update frequency.
[0154] In one embodiment, different software information processes correspond to different or the same preset update frequencies.
[0155] In one embodiment, the processing module is specifically used to: execute a first operation when a first memory meets a preset memory exception condition, and the first operation is used to optimize the memory occupied by the process; obtain a third memory occupied by the process, and the memory type of the third memory is the same as that of the first memory; and update a preset correction value when the difference between the third memory and the first memory does not meet the preset condition.
[0156] In one embodiment, the processing module is further used to: when the shared memory occupied by the process has not been completely allocated and the preset correction value needs to be updated, update the preset correction value after a second preset time delay.
[0157] In one embodiment, the processing module is specifically used to: obtain the first RSS occupied by the process when the process is created; or obtain the first RSS occupied by the process according to a first preset time; or obtain the first RSS occupied by the process when the system memory meets the preset memory threshold; or obtain the first RSS occupied by the process when the system component generates a memory acquisition request.
[0158] The embodiment of the present application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be completed by a computer program to instruct the relevant hardware, and the program can be stored in the above computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The computer-readable storage medium can be a terminal device of any of the above embodiments, such as: an internal storage unit including a data sending end and / or a data receiving end, such as a hard disk or memory of a terminal device. The above computer-readable storage medium can also be an external storage device of the above terminal device, such as a plug-in hard disk equipped on the above terminal device, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. Further, the above computer-readable storage medium can also include both an internal storage unit of the above terminal device and an external storage device. The above computer-readable storage medium is used to store the above computer program and other programs and data required by the above terminal device. The above computer-readable storage medium can also be used to temporarily store data that has been output or is to be output.
[0159] The present application also provides a computer instruction. All or part of the process in the above method embodiment can be completed by computer instructions to instruct related hardware (such as computers, processors, network devices, and terminals, etc.). The program can be stored in the above computer-readable storage medium.
[0160] The present application also provides a chip system. The chip system may be composed of a chip, or may include a chip and other discrete devices, without limitation. The chip system includes a processor, and all or part of the processes in the above method embodiment may be completed by the chip system, such as the chip system may be used to implement the functions performed by the terminal device in the above method embodiment.
[0161] In one possible design, the above-mentioned chip system also includes a memory, which is used to store program instructions and / or data. When the chip system is running, the processor executes the program instructions stored in the memory so that the chip system performs the functions performed by the terminal device in the above-mentioned method embodiment.
[0162] In the embodiments of the present application, the processor may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0163] In the embodiment of the present application, the memory may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), etc., or a volatile memory (volatile memory), such as a random-access memory (RAM). The memory is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory in the embodiment of the present application may also be a circuit or any other device that can implement a storage function, for storing instructions and / or data.
[0164] It should be noted that the terms "first" and "second" in the specification, claims and drawings of the present application are used to distinguish different objects rather than to describe a specific order. 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 device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.
[0165] It should be understood that in the embodiments of the present application, "at least one (item)" refers to one or more, "multiple" refers to two or more, "at least two (items)" refers to two or three and more than three, and "and / or" is used to describe the association relationship of the associated objects, indicating that there can be three relationships. For example, "A and / or B" can represent: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following (items)" or similar expressions refers to any combination of these items, including any combination of single items (items) or plural items (items). For example, at least one of a, b or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple. It should be understood that in the embodiments of the present application, "B corresponding to A" means that B is associated with A. For example, B can be determined based on A. It should also be understood that determining B based on A does not mean determining B based only on A, but B can also be determined based on A and / or other information. In addition, the "connection" in the embodiments of the present application refers to various connection modes such as direct connection or indirect connection to achieve communication between devices, and the embodiments of the present application do not impose any limitation on this.
[0166] Unless otherwise specified, the "transmission" (transmit / transmission) appearing in the embodiments of the present application refers to bidirectional transmission, including sending and / or receiving actions. Specifically, the "transmission" in the embodiments of the present application includes the sending of data, the receiving of data, or the sending of data and the receiving of data. In other words, the data transmission here includes uplink and / or downlink data transmission. Data may include channels and / or signals, uplink data transmission is uplink channel and / or uplink signal transmission, and downlink data transmission is downlink channel and / or downlink signal transmission. The "network" and "system" appearing in the embodiments of the present application express the same concept, and the communication system is the communication network.
[0167] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0168] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0169] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0170] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device, such as: a single-chip microcomputer, a chip, etc., or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, disks, or optical disks.
[0171] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A memory monitoring method, characterized in that: include: Get the first resident physical memory RSS occupied by the process; A first memory is determined according to the first RSS, where the first memory includes a first proportion of physical memory PSS and / or a physical memory USS solely occupied by the first process.
2. The memory monitoring method according to claim 1, characterized in that: The determining the first memory according to the first RSS comprises: A first memory is determined according to the first RSS and a preset correction value, wherein the preset correction value corresponds to a memory type of the first memory.
3. The memory monitoring method according to claim 1 or 2, characterized in that: The first RSS occupied by the acquisition process includes: Get the first RSS occupied by the process through the preset node.
4. The memory monitoring method according to claim 2, characterized in that: The preset correction value includes a PSS correction value and / or a USS correction value, the PSS correction value is calculated based on the second RSS and the second PSS, and the USS correction value is calculated based on the second RSS and the second USS, wherein the second RSS, the second PSS, and the second USS are acquired before the first RSS occupied by the acquisition process.
5. The memory monitoring method according to claim 2 or 4, characterized in that: After determining the first memory according to the preset correction value and the first RSS, the method further includes: The preset correction value is updated.
6. The memory monitoring method according to claim 5, characterized in that: The updating of the preset correction value comprises: The preset correction value is updated according to a preset update frequency.
7. The memory monitoring method according to claim 6, characterized in that: The method further comprises: When the first memory meets the preset memory abnormality condition, obtaining the second memory occupied by the process, where the second memory has the same memory type as the first memory; the second memory is obtained by accumulating the size of the number of pages of the virtual memory area linked list corresponding to the process; When the second memory does not meet the preset memory abnormality condition, the preset update frequency is adjusted.
8. The memory monitoring method according to claim 6 or 7, characterized in that: The processes of different software information correspond to different or the same preset update frequencies.
9. The memory monitoring method according to any one of claims 5 to 8, characterized in that: The updating of the preset correction value comprises: When the first memory meets a preset memory abnormality condition, executing a first operation, wherein the first operation is used to optimize the memory occupied by the process; Acquire a third memory occupied by the process, where the memory type of the third memory is the same as that of the first memory; When the difference between the third memory and the first memory does not meet the preset condition, the preset correction value is updated.
10. The memory monitoring method according to any one of claims 5 to 9, characterized in that: The method further comprises: In the case that the shared memory occupied by the process has not been completely allocated and the preset correction value needs to be updated, the updating of the preset correction value is executed after a second preset time delay.
11. The memory monitoring method according to any one of claims 1 to 10, characterized in that: The first RSS occupied by the acquisition process includes: When the process is created, obtaining the first RSS occupied by the process; Alternatively, the first RSS occupied by the process is obtained regularly according to a first preset time; Alternatively, when the system memory meets a preset memory threshold, obtaining the first RSS occupied by the process; Alternatively, when a system component generates a memory acquisition request, the first RSS occupied by the process is acquired.
12. A memory monitoring device, characterized in that: include: A processing module, used for obtaining the first resident physical memory RSS occupied by the process; The processing module is further used to determine a first memory according to the first RSS, where the first memory includes a first proportion of physical memory PSS and / or a physical memory USS occupied solely by the first process.
13. The memory monitoring device according to claim 12, characterized in that: The processing module is specifically used for: A first memory is determined according to the first RSS and a preset correction value, wherein the preset correction value corresponds to a memory type of the first memory.
14. The memory monitoring device according to claim 12 or 13, characterized in that: The processing module is specifically used for: Get the first RSS occupied by the process through the preset node.
15. The memory monitoring device according to claim 13, characterized in that: The preset correction value includes a PSS correction value and / or a USS correction value, the PSS correction value is calculated based on the second RSS and the second PSS, and the USS correction value is calculated based on the second RSS and the second USS, wherein the second RSS, the second PSS, and the second USS are acquired before the first RSS occupied by the acquisition process.
16. The memory monitoring device according to claim 13 or 15, characterized in that: The processing module is further used for: After determining the first memory according to the preset correction value and the first RSS, the preset correction value is updated.
17. The memory monitoring device according to claim 16, characterized in that: Processing module, specifically used for: The preset correction value is updated according to a preset update frequency.
18. The memory monitoring device according to claim 17, characterized in that: The processing module is further used for: When the first memory meets the preset memory abnormality condition, obtaining a second memory occupied by the process, where the second memory has the same memory type as the first memory; The second memory is obtained by accumulating the size of the number of pages of the virtual memory area linked list corresponding to the process; When the second memory does not meet the preset memory abnormality condition, the preset update frequency is adjusted.
19. The memory monitoring device according to claim 17 or 18, characterized in that: The processes of different software information correspond to different or the same preset update frequencies.
20. The memory monitoring device according to any one of claims 16 to 19, characterized in that: The processing module is specifically used for: When the first memory meets a preset memory abnormality condition, executing a first operation, wherein the first operation is used to optimize the memory occupied by the process; Acquire a third memory occupied by the process, where the memory type of the third memory is the same as that of the first memory; When the difference between the third memory and the first memory does not meet the preset condition, the preset correction value is updated.
21. The memory monitoring device according to any one of claims 16 to 20, characterized in that: The processing module is further used for: In the case that the shared memory occupied by the process has not been completely allocated and the preset correction value needs to be updated, the updating of the preset correction value is executed after a second preset time delay.
22. The memory monitoring device according to any one of claims 12 to 21, characterized in that: The processing module is specifically used for: When the process is created, obtaining the first RSS occupied by the process; Alternatively, the first RSS occupied by the process is obtained regularly according to a first preset time; Alternatively, when the system memory meets a preset memory threshold, obtaining the first RSS occupied by the process; Alternatively, when a system component generates a memory acquisition request, the first RSS occupied by the process is acquired.
23. A memory monitoring device, characterized in that: The memory monitoring device includes a processor, and the processor is used to support the memory monitoring device to execute the method according to any one of claims 1-11.
24. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed, the method according to any one of claims 1 to 11 is executed.
Citation Information
Cited By
Memory monitoring method and apparatus
EP4647918A1
Memory monitoring method and apparatus
WO2024174729A1
