CN113468020A - Memory monitoring method and device, electronic equipment and computer readable storage medium - Google Patents

Memory monitoring method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN113468020A
CN113468020A CN202110722049.8A CN202110722049A CN113468020A CN 113468020 A CN113468020 A CN 113468020A CN 202110722049 A CN202110722049 A CN 202110722049A CN 113468020 A CN113468020 A CN 113468020A
Authority
CN
China
Prior art keywords
memory
target terminal
stack
stack code
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110722049.8A
Other languages
Chinese (zh)
Inventor
卢松林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN202110722049.8A priority Critical patent/CN113468020A/en
Publication of CN113468020A publication Critical patent/CN113468020A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3055Monitoring arrangements for monitoring the status of the computing system or of the computing system component, e.g. monitoring if the computing system is on, off, available, not available

Abstract

The application discloses a memory monitoring method, a memory monitoring device, electronic equipment and a computer readable storage medium, wherein the memory monitoring method comprises the following steps: monitoring a process memory of a target terminal; judging whether the process memory of the target terminal meets a preset condition or not; if yes, saving the stack code information of the target terminal to a local disk; judging whether the memory is exhausted when the application program in the target terminal is started; and if so, sending the stack code information of the target terminal to a background server for analysis so as to determine an application program corresponding to the memory exhaustion in the target terminal. By the scheme, the working efficiency of determining the cause of the memory exhaustion can be effectively improved.

Description

Memory monitoring method and device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a memory monitoring method and apparatus, an electronic device, and a computer-readable storage medium.
Background
The OOM (Out Of Memory) is divided into two types, i.e., a form Out Of Memory and a boum Out Of Memory, and obviously, the former has more obvious perception for users, so the user experience is more damaged. FOOM is more likely to occur for heavy users, i.e. users with longer usage time, and the damage to the user experience in this part causes more loss of service if the user is lost.
The data on a plurality of product lines such as the head bar, the tremble and the like all show that FOOM magnitude is more than that of common collapse, and problems are overlooked for a long time due to the lack of effective monitoring and treatment means in the past. The probability that the memory occupation is too high, even if the memory occupation does not cause the FOOM, can cause the BOOM of other applications to be increased, and once the user finds that the WeChat is switched to the target App for use, and then the WeChat is switched back to the chat page of the previous WeChat and is restarted, the experience is very bad for the user. Therefore, it is necessary to establish an on-line monitoring means for the FOOM-generated breakdown problem.
Disclosure of Invention
The technical problem mainly solved by the application is to provide a memory monitoring method, a memory monitoring device, an electronic device and a computer-readable storage medium, which can effectively improve the work efficiency of determining the cause of memory exhaustion.
In order to solve the above problem, a first aspect of the present application provides a memory monitoring method, including: monitoring a process memory of a target terminal; judging whether the process memory of the target terminal meets a preset condition or not; if yes, saving the stack code information of the target terminal to a local disk; judging whether the memory is exhausted when the application program in the target terminal is started; and if so, sending the stack code information of the target terminal to a background server for analysis so as to determine an application program corresponding to the memory exhaustion in the target terminal.
Wherein the preset condition comprises at least one of the following: periodically analyzing whether the total memory exceeds a threshold value, exceeds a single large memory application threshold value or receives a system memory warning.
Wherein the saving the stack code information of the target terminal to a local disk includes: acquiring stack code information of the target terminal; and generating a Dump file according to the stack code information of the target terminal, and storing the Dump file to a local disk.
Wherein, the Dump file is stored in an MMAP mode.
Wherein the acquiring the stack code information of the target terminal includes: acquiring current accumulated memory allocation information of the target terminal; performing stack backtracking according to the accumulated memory allocation information to obtain a stack code block of the target terminal; and optimizing the stack code block to obtain the stack code information of the target terminal.
The obtaining of the current accumulated memory allocation information of the target terminal includes: and acquiring allocation and release methods of the heap memory and the VM memory by using a HOOK technology, tracking and recording memory allocation information of each application program in the process of the target terminal, and calculating to obtain the current accumulated memory allocation information of the target terminal.
The accumulated memory allocation information comprises allocation stacks, accumulated allocation times and accumulated allocated memory.
The optimizing the stack code block to obtain the stack code information of the target terminal includes: and clustering and de-duplicating the stack code blocks by using a preset shift algorithm to obtain the stack code blocks after data compression, and processing the stack code blocks after data compression by using a preset fault-tolerant strategy to obtain the stack code information of the target terminal.
In order to solve the above problem, a second aspect of the present application provides a memory monitoring device, including: the memory monitoring module is used for monitoring the process memory of the target terminal; the first judgment module is used for judging whether the process memory of the target terminal meets a preset condition or not; the information acquisition module is used for storing stack code information of the target terminal to a local disk under the condition that a process memory of the target terminal meets a preset condition; the second judgment module is used for judging whether the memory is exhausted when the application program in the target terminal is started; and the information uploading module is used for sending stack code information of the target terminal to a background server for analysis under the condition that the memory is exhausted when the application program in the target terminal is started so as to determine the application program corresponding to the exhausted memory in the target terminal.
Wherein, the memory monitoring device further comprises: the system comprises a memory allocation stack monitoring module, a memory allocation stack monitoring module and a control module, wherein the memory allocation stack monitoring module is used for acquiring stack code information of a target terminal.
In order to solve the above problem, a third aspect of the present application provides an electronic device, which includes a storage and a processor coupled to each other, where the processor is configured to execute program instructions stored in the storage to implement the memory monitoring method of the first aspect.
In order to solve the above problem, a fourth aspect of the present application provides a computer-readable storage medium, on which program instructions are stored, the program instructions, when executed by a processor, implement the memory monitoring method of the first aspect.
The invention has the beneficial effects that: different from the situation of the prior art, the memory monitoring method of the application judges whether the process memory of the target terminal meets the preset condition by monitoring the process memory of the target terminal; under the condition that the process memory of the target terminal meets the preset condition, stack code information of the target terminal is stored in a local disk, and then whether the memory is exhausted when an application program in the target terminal is started is further judged; under the condition that the memory is exhausted when the application program in the target terminal is started, the stack code information of the target terminal is sent to the background server for analysis, so that the application program corresponding to the exhausted memory in the target terminal can be determined, the application program can be helped to monitor and analyze the reason of OOM, and the problem of reducing the occurrence probability of OOM is solved.
Drawings
Fig. 1 is a schematic flowchart illustrating an embodiment of a memory monitoring method according to the present application;
FIG. 2 is a flowchart illustrating an embodiment of step S13 in FIG. 1;
FIG. 3 is a flowchart illustrating an embodiment of step S131 in FIG. 2;
FIGS. 4a and 4b are schematic display diagrams of monitoring OOM in an application scenario;
FIG. 5 is a block diagram of an embodiment of a memory monitoring device according to the present application;
FIG. 6 is a block diagram of another embodiment of a memory monitoring device according to the present application;
FIG. 7 is a block diagram of an embodiment of an electronic device of the present application;
FIG. 8 is a block diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The following describes in detail the embodiments of the present application with reference to the drawings attached hereto.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, interfaces, techniques, etc. in order to provide a thorough understanding of the present application.
The terms "system" and "network" are often used interchangeably herein. The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship. Further, the term "plurality" herein means two or more than two.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a memory monitoring method according to an embodiment of the present application.
Specifically, the memory monitoring method in this embodiment may include the following steps:
step S11: and monitoring the process memory of the target terminal.
The memory is a bridge communicating with a Central Processing Unit (CPU) in the terminal, and all programs in the terminal are run in the memory, so that the performance of the memory has a great influence on the terminal. The memory is mainly used for temporarily storing operation data in the CPU and data exchanged with an external memory such as a hard disk. As long as the terminal is in operation, the CPU transfers data to be operated to the memory for operation, and after the operation is finished, the CPU transmits the result, and the use state of the memory also determines the stable operation of the computer.
For the target terminal, when the application program applies for the memory, the memory allocation function can be called, the data type of the applied memory can be analyzed through the type analysis interface, then the memory application interface is called to allocate the memory, the memory allocation result is returned to the application program, the size of the corresponding applied memory is updated according to the applied memory amount corresponding to the memory application, and the total amount of all allocated memories is updated, so that the process memory of the target terminal can be monitored in real time.
Step S12: and judging whether the process memory of the target terminal meets a preset condition. If the process memory of the target terminal meets the preset condition, executing step S13; and if the process memory of the target terminal does not meet the preset condition, continuing monitoring the process memory of the target terminal.
Step S13: and saving the stack code information of the target terminal to a local disk.
The stack code information of the target terminal records an execution state in the running process of the application program, for example, program running related information such as a memory, a stack, a handle, a thread and the like associated with the application program. It can be understood that, in the process of monitoring the process memory of the target terminal in real time, whether the process memory meets the preset condition can be judged; if the process memory of the target terminal meets the preset condition, the situation that the memory touches the top is shown, so that the memory is exhausted possibly, and then the stack code information of the target terminal needs to be stored in a local disk, so that a large amount of memory is consumed by analyzing the code occupation of the target terminal according to the stack code information; and if the process memory of the target terminal does not meet the preset condition, continuing monitoring the process memory of the target terminal. The file stored in the local disk is the file in the terminal, the information stored in the local disk is not affected by power failure, and the disk has large capacity and can store a large amount of information.
Specifically, the preset condition includes at least one of: periodically analyzing whether the total memory exceeds a threshold value, exceeds a single large memory application threshold value or receives a system memory warning. It can be understood that, in the process of monitoring the process memory of the target terminal, the total memory may be analyzed at regular time, and if the total memory exceeds the threshold in the process of the regular analysis at a certain time, or the amount of the applied memory in a certain memory application exceeds the threshold of a single large memory application, or if a system memory warning is received, it indicates that the current memory is occupied too much, and stack code information of the target terminal needs to be stored in the local disk.
Step S14: and judging whether the memory is exhausted when the application program in the target terminal is started. If the memory exhaustion occurs, go to step S15; if no memory exhaustion occurs, no analysis of the stack code information is required.
Step S15: and sending the stack code information of the target terminal to a background server for analysis so as to determine an application program corresponding to the exhaustion of the memory in the target terminal.
It can be understood that if the memory is exhausted when the application program in the target terminal is started, the stack code information before the memory is exhausted can be reported to the background server for analysis, so that the position where the code occupies a large amount of memory can be analyzed according to the stack code information, and the OOM crash of the system is finally caused, thereby effectively improving the working efficiency of a developer for inquiring the abnormal reason of the program.
Specifically, the system platform of the target terminal is an ios platform.
According to the scheme, whether the process memory of the target terminal meets the preset condition is judged by monitoring the process memory of the target terminal; under the condition that the process memory of the target terminal meets the preset condition, stack code information of the target terminal is stored in a local disk, and then whether the memory is exhausted when an application program in the target terminal is started is further judged; under the condition that the memory is exhausted when the application program in the target terminal is started, the stack code information of the target terminal is sent to the background server for analysis, so that the application program corresponding to the exhausted memory in the target terminal can be determined, the application program can be helped to monitor and analyze the reason of OOM, and the problem of reducing the occurrence probability of OOM is solved.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating an embodiment of step S13 in fig. 1. In an embodiment, the step S13 may specifically include:
step S131: and acquiring stack code information of the target terminal.
And in the development test process, a development tester can determine the possible reason of the program abnormality through the code line corresponding to the stack information.
Further, referring to fig. 3, fig. 3 is a schematic flowchart illustrating an embodiment of step S131 in fig. 2, and in an embodiment, the step S131 may specifically include:
step S1311: and acquiring the current accumulated memory allocation information of the target terminal.
For each process, loading the memory monitoring dynamic link library and executing functions thereof when the process is started, starting to monitor memory allocation information when the process is started, and still executing the loaded memory monitoring dynamic link library to monitor the memory allocation information after the process is exited when the process is exited, and for the target terminal, each process runs and monitors the memory allocation information, so that the current accumulated memory allocation information of the target terminal can be obtained.
In an embodiment, the step S1331 may specifically include: and acquiring allocation and release methods of the heap memory and the VM memory by using a HOOK technology, tracking and recording memory allocation information of each application program in the process of the target terminal, and calculating to obtain the current accumulated memory allocation information of the target terminal.
In order to obtain the memory space data used in real time in the target terminal, a distribution method and a release method related to the memory in the target terminal can be obtained through a HOOK (HOOK) technology, and the real-time use condition of the memory is counted to obtain the memory space data. In practical applications, an application program may occupy any available memory space, such as a heap memory and a virtual memory, of a device during a running process. Where heap memory (heap) is another memory area distinct from the stack area, the global data area, and the code area, the heap allows a program to dynamically apply for a certain size of memory space at runtime. Specifically, in order to obtain heap memory space data and virtual memory space data in the memory space data, a distribution method and a release method of a heap memory in the target terminal may be obtained through a HOOK technology, respectively, and the heap memory space data is obtained based on the distribution method and the release method of the heap memory; the method comprises the steps of obtaining a Virtual Machine (VM) memory allocation method and a VM memory release method in a target terminal through a HOOK technology, and obtaining Virtual memory space data based on the VM memory allocation method and the VM memory release method. And tracking and recording the memory allocation information of each application program in the process of the target terminal, and calculating to obtain the current accumulated memory allocation information of the target terminal.
The allocation method of the heap memory may include any method related to allocation of the heap memory, the release method of the heap memory may include any method related to release of the heap memory, the content specifically included in the allocation method and the release method of the heap memory may also be set by a user according to a requirement, the allocation method of the VM memory may include any method related to allocation of the VM memory, the release method of the VM memory may include any method related to release of the VM memory, and the content specifically included in the allocation method and the release method of the VM memory may also be set by a user according to a requirement, which is not limited in this embodiment of the present application.
Further, the accumulated memory allocation information may include allocation stack, accumulated allocation times, and accumulated allocated memory. Specifically, the memory allocation information may include a memory allocation address, a memory allocation size, and a memory allocated function stack, or a memory allocation size and a memory allocated function stack, or a memory allocation address and a memory allocation size, and the memory allocation information is accumulated to obtain accumulated memory allocation information such as an allocation stack, an accumulated allocation number, an accumulated allocated memory, and the like.
Step S1312: and performing stack backtracking according to the accumulated memory allocation information to obtain a stack code block of the target terminal.
By using a preset stack backtracking method, such as a stack frame backtracking method, an instruction analysis method or an unwender backtracking method, the stack code blocks of all the applications when applying for the memory can be backtracked according to the accumulated memory allocation information, and then the stack code blocks can be analyzed to determine the application corresponding to the memory exhaustion in the target terminal.
Step S1313: and optimizing the stack code block to obtain the stack code information of the target terminal.
It can be understood that the stack code block obtained by performing the stack trace back may have duplication or errors, and therefore, the stack code block needs to be optimized so as to obtain accurate stack code information of the target terminal. Specifically, clustering and deduplication are performed on the stack code blocks by using a preset shift algorithm, and then data compression is performed to obtain the stack code blocks after data compression. The preset shift algorithm may be a binary shift algorithm or MD5 (information summarization algorithm 5), and taking the binary shift algorithm as an example, after the stack code block is obtained, the data stream is encrypted by a binary shift algorithm, and for the data streams with the same content, the data values generated after encryption are the same, so that the same data stream can be clustered, and the deduplication processing can be implemented for the data streams classified into the same class. It can be understood that abnormal data (data error or data null) may still exist in the stack code block after data compression, and therefore a preset fault-tolerant policy needs to be set, for example, a processing scheme for setting a boundary condition is set, or abnormal data is manually processed, and then the stack code block after data compression is processed by using the preset fault-tolerant policy, so that accurate stack code information of the target terminal can be obtained.
Step S132: and generating a Dump file according to the stack code information of the target terminal, and storing the Dump file to a local disk.
The Dump file is a memory mirror image file of an associated process of a corresponding application program, and is used for storing an execution state in the running process of the application program, such as program running related information of a memory, a stack, a handle, a thread and the like associated with the application program, and the Dump file is a memory data file used for debugging the program for development and test personnel. Generating a Dump file according to stack code information of a target terminal, storing the Dump file to a local disk, and sending the Dump file to a background server for analysis when memory is exhausted when an application program in the target terminal is started; specifically, the Dump file is opened and analyzed, so that an abnormal address, an abnormal number and an abnormal thread are obtained from the Dump file, a stack of the abnormal thread and stacks of other threads are obtained, and information obtained from the Dump file is output, so that an application program corresponding to the exhaustion of the memory in the target terminal can be determined.
Specifically, the Dump file is stored in an MMAP manner. MMAP is a high-performance memory mapping data storage method, memory mapping refers to mapping a memory message to a file, for example, the memory mapping is a shared memory, i.e., both process A and process B map the page to their own address space, when process A accesses the data in the page for the first time, it generates a page missing terminal, the kernel reads the page into the memory and updates the page table to point to it, and later, when process B accesses the same page and the page missing interruption occurs, the page is already in the memory, and the kernel only needs to point the page table entry of process B to the next page. In the embodiment, the shared memory is realized by adopting an MMAP mode, the MMAP enables processes to realize the shared memory by mapping the same common file, and after the common file is mapped to the process address space, the processes can access the file as accessing the common memory without calling read, write and other operations, so that high-frequency reading and writing of the Dump file are supported, high-efficiency storage of the large file is supported, and the storage of the Dump file in a local disk and uploading to a background server are facilitated.
As shown in fig. 4a and 4b, fig. 4a and 4b are schematic display diagrams of monitoring an OOM in an application scenario, where fig. 4a shows an OOM list page and fig. 4b shows an OOM detail page, in the memory monitoring method of the present application, stack code information of a target terminal is sent to a background server for analysis, so as to determine an application program corresponding to the exhaustion of a memory in the target terminal, and then record an event of the OOM occurring at each terminal, so as to help a development tester monitor the application program and analyze the reason of the occurrence of the OOM, thereby achieving a problem of reducing the occurrence probability of the OOM.
Referring to fig. 5, fig. 5 is a schematic diagram of a memory monitoring device according to an embodiment of the present application. The memory monitoring device 50 includes: the memory monitoring module 500, the memory monitoring module 500 is used for monitoring the process memory of the target terminal; a first determining module 502, where the first determining module 502 is configured to determine whether a process memory of the target terminal meets a preset condition; an information obtaining module 504, where the information obtaining module 504 is configured to store stack code information of the target terminal to a local disk when a process memory of the target terminal meets a preset condition; a second determining module 506, where the second determining module 506 is configured to determine whether memory exhaustion occurs when an application program in the target terminal is started; an information reporting module 508, where the information reporting module 508 is configured to send stack code information of the target terminal to a background server for analysis when the memory is exhausted when the application program in the target terminal is started, so as to determine the application program corresponding to the exhausted memory in the target terminal.
In some embodiments, the preset condition comprises at least one of: periodically analyzing whether the total memory exceeds a threshold value, exceeds a single large memory application threshold value or receives a system memory warning.
Referring to fig. 6, fig. 6 is a schematic diagram of a frame of another embodiment of the memory monitoring device of the present application, in some embodiments, the memory monitoring device 50 further includes a memory allocation stack monitoring module 501, and the memory allocation stack monitoring module 501 is configured to obtain stack code information of a target terminal.
In some embodiments, the information obtaining module 504 is specifically configured to generate a Dump file according to the stack code information of the target terminal, and store the Dump file to a local disk.
In some embodiments, the memory allocation stack monitoring module 501 performs the steps of obtaining the stack code information of the target terminal, including: acquiring current accumulated memory allocation information of the target terminal; performing stack backtracking according to the accumulated memory allocation information to obtain a stack code block of the target terminal; and optimizing the stack code block to obtain the stack code information of the target terminal.
In some embodiments, the memory allocation stack monitoring module 501 performs the step of obtaining the current accumulated memory allocation information of the target terminal, including: and acquiring allocation and release methods of the heap memory and the VM memory by using a HOOK technology, tracking and recording memory allocation information of each application program in the process of the target terminal, and calculating to obtain the current accumulated memory allocation information of the target terminal.
In some embodiments, the step of performing, by the memory allocation stack monitoring module 501, optimization processing on the stack code block to obtain the stack code information of the target terminal includes: and clustering and de-duplicating the stack code blocks by using a preset shift algorithm to obtain the stack code blocks after data compression, and processing the stack code blocks after data compression by using a preset fault-tolerant strategy to obtain the stack code information of the target terminal.
Referring to fig. 7, fig. 7 is a schematic diagram of a frame of an electronic device according to an embodiment of the present application. The electronic device 70 includes a storage 701 and a processor 702 coupled to each other, and the processor 702 is configured to execute program instructions stored in the storage 701 to implement the steps of any of the embodiments of the memory monitoring method described above. In one particular implementation scenario, the electronic device 70 may include, but is not limited to: microcomputer, server.
Specifically, the processor 702 is configured to control itself and the storage 701 to implement the steps of any of the above-described embodiments of the memory monitoring method. Processor 702 may also be referred to as a CPU (Central Processing Unit). The processor 702 may be an integrated circuit chip having signal processing capabilities. The Processor 702 may also be a general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, the processor 702 may be collectively implemented by an integrated circuit chip.
Referring to fig. 8, fig. 8 is a block diagram illustrating an embodiment of a computer-readable storage medium according to the present application. The computer readable storage medium 80 stores program instructions 800 executable by the processor, where the program instructions 800 are for implementing the steps of any of the above-described embodiments of the memory monitoring method.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely one type of logical division, and an actual implementation may have another division, for example, a unit or a component may be combined or integrated with another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on network elements. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

Claims (12)

1. A memory monitoring method is characterized by comprising the following steps:
monitoring a process memory of a target terminal;
judging whether the process memory of the target terminal meets a preset condition or not;
if yes, saving the stack code information of the target terminal to a local disk;
judging whether the memory is exhausted when the application program in the target terminal is started;
and if so, sending the stack code information of the target terminal to a background server for analysis so as to determine an application program corresponding to the memory exhaustion in the target terminal.
2. The memory monitoring method according to claim 1, wherein the preset condition comprises at least one of: periodically analyzing whether the total memory exceeds a threshold value, exceeds a single large memory application threshold value or receives a system memory warning.
3. The memory monitoring method according to claim 2, wherein the saving stack code information of the target terminal to a local disk includes:
acquiring stack code information of the target terminal;
and generating a Dump file according to the stack code information of the target terminal, and storing the Dump file to a local disk.
4. The memory monitoring method according to claim 3, wherein the Dump file is stored in an MMAP manner.
5. The memory monitoring method according to claim 3, wherein the obtaining stack code information of the target terminal includes:
acquiring current accumulated memory allocation information of the target terminal;
performing stack backtracking according to the accumulated memory allocation information to obtain a stack code block of the target terminal;
and optimizing the stack code block to obtain the stack code information of the target terminal.
6. The memory monitoring method according to claim 5, wherein the obtaining of the current accumulated memory allocation information of the target terminal includes:
and acquiring allocation and release methods of the heap memory and the VM memory by using a HOOK technology, tracking and recording memory allocation information of each application program in the process of the target terminal, and calculating to obtain the current accumulated memory allocation information of the target terminal.
7. The memory monitoring method according to claim 6, wherein the accumulated memory allocation information comprises allocation stack, accumulated allocation times, accumulated allocated memory.
8. The memory monitoring method according to claim 5, wherein the optimizing the stack code block to obtain the stack code information of the target terminal includes:
and clustering and de-duplicating the stack code blocks by using a preset shift algorithm to obtain the stack code blocks after data compression, and processing the stack code blocks after data compression by using a preset fault-tolerant strategy to obtain the stack code information of the target terminal.
9. A memory monitoring device, comprising:
the memory monitoring module is used for monitoring the process memory of the target terminal;
the first judgment module is used for judging whether the process memory of the target terminal meets a preset condition or not;
the information acquisition module is used for storing stack code information of the target terminal to a local disk under the condition that a process memory of the target terminal meets a preset condition;
the second judgment module is used for judging whether the memory is exhausted when the application program in the target terminal is started;
and the information uploading module is used for sending stack code information of the target terminal to a background server for analysis under the condition that the memory is exhausted when the application program in the target terminal is started so as to determine the application program corresponding to the exhausted memory in the target terminal.
10. The memory monitoring device of claim 9, further comprising:
the system comprises a memory allocation stack monitoring module, a memory allocation stack monitoring module and a control module, wherein the memory allocation stack monitoring module is used for acquiring stack code information of a target terminal.
11. An electronic device comprising a memory and a processor coupled to each other, the processor being configured to execute program instructions stored in the memory to implement the memory monitoring method of any one of claims 1 to 8.
12. A computer readable storage medium having stored thereon program instructions which, when executed by a processor, implement the memory monitoring method of any one of claims 1 to 8.
CN202110722049.8A 2021-06-28 2021-06-28 Memory monitoring method and device, electronic equipment and computer readable storage medium Pending CN113468020A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110722049.8A CN113468020A (en) 2021-06-28 2021-06-28 Memory monitoring method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110722049.8A CN113468020A (en) 2021-06-28 2021-06-28 Memory monitoring method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN113468020A true CN113468020A (en) 2021-10-01

Family

ID=77873417

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110722049.8A Pending CN113468020A (en) 2021-06-28 2021-06-28 Memory monitoring method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113468020A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453446A (en) * 2023-12-15 2024-01-26 荣耀终端有限公司 Auxiliary information acquisition method for memory leakage positioning and electronic equipment
CN117453446B (en) * 2023-12-15 2024-04-26 荣耀终端有限公司 Auxiliary information acquisition method for memory leakage positioning and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102279797A (en) * 2011-08-30 2011-12-14 深圳宝德科技集团股份有限公司 Method and system for detecting memory leakage
CN103631661A (en) * 2013-11-27 2014-03-12 青岛海信电器股份有限公司 Internal storage management method and device
CN111984401A (en) * 2020-07-24 2020-11-24 五八有限公司 Memory overflow management method and device, electronic equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102279797A (en) * 2011-08-30 2011-12-14 深圳宝德科技集团股份有限公司 Method and system for detecting memory leakage
CN103631661A (en) * 2013-11-27 2014-03-12 青岛海信电器股份有限公司 Internal storage management method and device
CN111984401A (en) * 2020-07-24 2020-11-24 五八有限公司 Memory overflow management method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453446A (en) * 2023-12-15 2024-01-26 荣耀终端有限公司 Auxiliary information acquisition method for memory leakage positioning and electronic equipment
CN117453446B (en) * 2023-12-15 2024-04-26 荣耀终端有限公司 Auxiliary information acquisition method for memory leakage positioning and electronic equipment

Similar Documents

Publication Publication Date Title
EP2329371B1 (en) Evaluating effectiveness of memory management techniques selectively using mitigations to reduce errors
CN103109276B (en) System detection method
US20080276129A1 (en) Software tracing
CN109614276A (en) Fault handling method, device, distributed memory system and storage medium
US20230384932A1 (en) Electronic storage system
CN104685474A (en) Notification of address range including non-correctable error
EP3274839B1 (en) Technologies for root cause identification of use-after-free memory corruption bugs
EP2329384B1 (en) Memory management techniques selectively using mitigations to reduce errors
CN114675791B (en) Disk processing method and system and electronic equipment
US20230214286A1 (en) Information recording method, apparatus, and device, and readable storage medium
CN116414661B (en) Processing method and device for solid state disk of distributed storage
CN113468020A (en) Memory monitoring method and device, electronic equipment and computer readable storage medium
CN113986599A (en) Application processing method, terminal, server, equipment and storage medium
CN111240898A (en) Hypervisor-based black box implementation method and system
US20200097395A1 (en) Exception handling in wireless access points
CN113722142B (en) Method and device for analyzing reasons of insufficient memory, electronic equipment and storage medium
CN111190781A (en) Test self-check method of server system
CN112073519B (en) Processing method and device of operation request
CN116414722B (en) Fuzzy test processing method and device, fuzzy test system and storage medium
CN116483641B (en) Method, system and medium for abnormal power failure detection of hard disk
CN113094221B (en) Fault injection method, device, computer equipment and readable storage medium
CN115495291A (en) Method and apparatus for facilitating recording of system fatal errors
CN117591327A (en) core file generation method and device, electronic equipment and storage medium
CN111767182A (en) SSD failure analysis method and device, computer equipment and storage medium
CN113778952A (en) Log output method, device, setting and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination