CN111090536A - Method, device, medium and electronic equipment for acquiring memory leakage information - Google Patents

Method, device, medium and electronic equipment for acquiring memory leakage information Download PDF

Info

Publication number
CN111090536A
CN111090536A CN201911133763.2A CN201911133763A CN111090536A CN 111090536 A CN111090536 A CN 111090536A CN 201911133763 A CN201911133763 A CN 201911133763A CN 111090536 A CN111090536 A CN 111090536A
Authority
CN
China
Prior art keywords
information
memory
memory state
main process
state 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.)
Granted
Application number
CN201911133763.2A
Other languages
Chinese (zh)
Other versions
CN111090536B (en
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201911133763.2A priority Critical patent/CN111090536B/en
Publication of CN111090536A publication Critical patent/CN111090536A/en
Application granted granted Critical
Publication of CN111090536B publication Critical patent/CN111090536B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/073Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in a memory management context, e.g. virtual memory or cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Abstract

The disclosure provides a method, a device, a medium and an electronic device for obtaining memory leak information. The method comprises the following steps: the main process acquires the abnormal crash information of the main process; based on the triggering of the abnormal crash information, the main process creates and operates an emergency sub-process; the emergency sub-process acquires the memory state information shared by the main process and stores the memory state information into a memory state data set; when the main process operates again, acquiring the memory state information from the memory state data set; and when the memory state information meets the memory abnormal condition, generating memory leakage information by the main process. According to the method and the device, the size information of the virtual memory is directly obtained, so that the memory leakage information is quickly positioned, the memory leakage information is accurately aggregated, and the efficiency of positioning program faults is improved. And a copy-on-write sub-process is created, so that the interference of other threads and/or processes is reduced, the abnormal processing flow is prevented from being interrupted, and the success rate and the stability of acquiring abnormal information are improved.

Description

Method, device, medium and electronic equipment for acquiring memory leakage information
Technical Field
The present disclosure relates to the field of locating process anomalies, and in particular, to a method, an apparatus, a medium, and an electronic device for obtaining memory leak information.
Background
The C language is a general programming language facing to the process and abstraction and is widely applied to the bottom development. The C language has the characteristics of high efficiency, flexibility, rich functions, strong expression, high portability and the like, and is favored in program design. C language compilers are ubiquitous in a variety of different operating systems, such as Microsoft Windows, macOS, Linux, Unix, and the like. The design of the C language leverages numerous later programming languages, such as C + +, Objective-C, Java, C #, and so on.
C + + was originally referred to as the C language containing classes. The computer program design language is an object-oriented computer program design language, is a general program design language which is used for static data type inspection and supports multiple programming paradigms, and supports various program design styles such as procedural program design, data abstraction, object-oriented program design, extensive program design and the like.
C + + is the inheritance of the C language, further expands and perfects the C language, and becomes an object-oriented programming language.
The C/C + + language is widely applied to software development of computer systems due to its high efficiency. However, it also has obvious defects, such as wild pointer, memory leak, etc. which are always troubling developers.
The wild pointer is a pointer pointing to a deleted object or an object that does not apply for access to a restricted memory area. Unlike NULL pointers, wild pointers cannot be avoided by simply determining whether they are NULL, but can only be reduced in an effort by developing good programming habits. Operating the wild pointer can easily cause program errors.
Memory leaks (memory leaks) are spaces dynamically created by the memory allocation function that are not released after use, resulting in the memory unit being occupied until the end of the program. Memory leaks are errors that are difficult to locate and track. Code that leaks out of memory will only occur under certain circumstances or operating procedures.
The memory leakage problem often causes various exceptions. In the traditional memory leak monitoring scheme, the memory leak information condition is obtained through the aggregation of an abnormal call stack, and the efficiency of monitoring the memory leak through the call stack is low because the memory leak reason is not directly associated with the call stack.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The present disclosure is directed to a method, an apparatus, a medium, and an electronic device for obtaining memory leak information, which can solve at least one of the above-mentioned technical problems. The specific scheme is as follows:
according to a specific implementation manner of the present disclosure, in a first aspect, the present disclosure provides a method for obtaining memory leak information, including:
the main process acquires the abnormal crash information of the main process;
based on the triggering of the abnormal crash information, the main process creates and operates an emergency sub-process;
the emergency sub-process acquires the memory state information shared by the main process and stores the memory state information into a memory state data set;
when the main process operates again, acquiring the memory state information from the memory state data set;
and when the memory state information meets the memory abnormal condition, generating memory leakage information by the main process.
According to a second aspect of the present disclosure, an apparatus for obtaining memory leak information includes:
an abnormal crash information obtaining unit, which is used for the main process to obtain the abnormal crash information;
an emergency subprocess creating unit used for creating and operating an emergency subprocess by the main process based on the triggering of the abnormal crash information;
a memory state information storing unit, configured to acquire, by the emergency subprocess, memory state information shared by the host process, and store the memory state information in a memory state data set;
the memory state information obtaining unit is used for obtaining memory state information from the memory state data set when the main process operates again;
and the memory leak information generating unit is used for generating the memory leak information by the main process when the memory state information meets the memory abnormal condition.
According to a third aspect, there is provided a computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the method for obtaining memory leak information according to any one of the first aspect.
According to a fourth aspect thereof, the present disclosure provides an electronic device, comprising: one or more processors; a storage device, configured to store one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the method for obtaining memory leak information according to any one of the first aspect.
Compared with the prior art, the scheme of the embodiment of the disclosure at least has the following beneficial effects:
the disclosure provides a method, a device, a medium and an electronic device for obtaining memory leak information. The method comprises the following steps: the main process acquires the abnormal crash information of the main process; based on the triggering of the abnormal crash information, the main process creates and operates an emergency sub-process; the emergency sub-process acquires the memory state information shared by the main process and stores the memory state information into a memory state data set; when the main process operates again, acquiring the memory state information from the memory state data set; and when the memory state information meets the memory abnormal condition, generating memory leakage information by the main process. According to the method and the device, the size information of the virtual memory is directly obtained, so that the memory leakage information is quickly positioned, the memory leakage information is accurately aggregated, and the efficiency of positioning program faults is improved. And a copy-on-write sub-process is created, so that the interference of other threads and/or processes is reduced, the abnormal processing flow is prevented from being interrupted, and the success rate and the stability of acquiring abnormal information are improved.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
fig. 1 shows a flowchart of a method for obtaining memory leak information according to an embodiment of the present disclosure;
fig. 2 is a diagram illustrating a memory resource relationship between a copy-on-write sub-process and a main process according to the method for acquiring memory leak information in the embodiment of the present disclosure;
FIG. 3 shows a block diagram of elements of an apparatus for obtaining memory leak information according to an embodiment of the present disclosure;
fig. 4 shows an electronic device connection structure schematic according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Alternative embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
A first embodiment provided by the present disclosure is an embodiment of a method for acquiring memory leak information.
The following describes an embodiment of the present disclosure in detail with reference to fig. 1 and fig. 2, where fig. 1 is a flowchart of a method for obtaining memory leak information according to an embodiment of the present disclosure; fig. 2 is a diagram illustrating a memory resource relationship between a copy-on-write sub-process and a main process according to the method for acquiring memory leak information in the embodiment of the present disclosure.
Step S101, the main process obtains the abnormal crash information.
In the programming stage, due to the unreasonable design in the program, the program process may crash during the running process or even suddenly interrupt the running process, that is, the program process crashes abnormally. There are many reasons for the abnormal crash of the program process, such as memory leak, buffer overflow, stack overflow, illegal pointer, data type conduction error and dead loop. It is an object of embodiments of the present disclosure to quickly locate the cause of an exception crash.
When a Process crashes or exits, a special event is triggered in the Process, which is called an EPR event (hereinafter referred to as an Exit Process).
The main process in the disclosed embodiment is the process that is being monitored. The main process is the entry of program execution, i.e. the main function.
And the host process acquires the abnormal crash information of the host process, namely the host process intercepts the EPR event.
And S102, based on the triggering of the abnormal crash information, the main process creates and operates an emergency sub-process.
A child process is a process created by a parent process. In the embodiment of the disclosure, the host process creates an emergency sub-process, and therefore, the emergency sub-process is a sub-process of the host process, and the host process is a parent process of the emergency sub-process.
And the triggering based on the abnormal crash information is used for creating and operating the emergency subprocess by the main process, namely after the EPR event is intercepted by the main process, the main process creates and operates the emergency subprocess before the main process quits the operation.
Optionally, the emergency sub-process is a copy-on-write sub-process.
Referring to FIG. 2, the copy-on-write sub-process is a replica of the host process, which inherits the address space of the entire process from the host process: including process context (static description of the overall process of process execution activity), process stack, open file descriptor, signal control settings, process priority, process group number, etc. The only information unique to the copy-on-write sub-process is its process number and timer.
Indeed, more precisely, copy-on-write (english-language full name) is a technique that can defer or even avoid copying data. At this point, the kernel does not replicate the entire process' address space, but rather allows the host process and the copy-on-write sub-process to share the same address space. The address space is only copied when a write is needed, so that the host process and the copy-on-write sub-process have respective address spaces. That is, the resource is copied only when a write is needed, and is shared only in a read-only manner before that. The copy-on-write sub-process reduces the interference of other threads and/or processes, avoids interrupting an exception handling process, and improves the success rate and stability of obtaining exception information. For example, in a Linux system, a primary process creates a copy-on-write sub-process through a fork function.
Step S103, the emergency sub-process obtains the memory state information shared by the main process and stores the memory state information into a memory state data set.
The data set of the embodiment of the disclosure comprises: a data table of a database, a text file, a configuration file, and/or a spreadsheet. For example, the memory state data set is a text file of "status.txt", and the emergency sub-process saves the acquired memory state information in the text file of "status.txt".
Optionally, the acquiring, by the emergency sub-process, the memory state information shared by the main process includes the following steps:
step S103-1, the emergency sub-process acquires the memory state information of the main process from the real-time memory state file shared with the main process.
Wherein the memory state information includes virtual memory size information.
For example, the real-time memory status file is a "status" file under the directory "/proc/self/" associated with the host process; the virtual memory size information is information stored in the VmSize field of the "status" file. The virtual memory size information of the main process can be obtained by directly reading the information of the 'VmSize' field in the 'status' file.
And step S104, when the main process operates again, acquiring the memory state information from the memory state data set.
That is, when the main process exits from operation due to abnormal crash and is started again, the main process acquires the memory state information from the memory state data set.
For example, continuing with the above example, the host process may obtain memory state information from a "status.
Step S105, when the memory state information satisfies the memory abnormal condition, the main process generates memory leak information.
Memory leak (OOM) is a phenomenon that a program writer cannot be reused and a computer Memory is exhausted because a program writer uses a Memory improperly, for example, the released Memory resource is not released.
Optionally, the step of enabling the memory state information to satisfy the memory exception condition includes:
step S105-1, the size information of the virtual memory is larger than a preset process memory threshold value.
The predetermined process memory threshold is an empirical value.
For example, continuing with the above example, if the maximum size of a virtual memory is 100 megabytes, the preset process memory threshold is set to 95 megabytes, and when the host process obtains 96 megabytes of information for the "VmSize" field from the "status.
According to the embodiment of the disclosure, the size information of the virtual memory is directly obtained, so that the memory leakage information is quickly positioned.
When a program relating to the main process is released, there will be thousands of machines using the program. In order to find the problem of the program in time and avoid influencing the user experience. The embodiment of the disclosure also provides a function of automatically classifying and aggregating program problems, so that developers can find the problems in time and solve the problems.
Optionally, after the main process creates and runs the emergency sub-process, the method further includes the following steps:
step S102-1, the main process obtains call stack information and stores the call stack information in a call stack data set.
That is, before the main process is quitted due to abnormal crash, the call stack information is also obtained.
Call stack (Call stack, abbreviated as "stack" in english), also called: an execution stack (execution stack), a control stack (control stack), a run-time stack (run-time stack), or a machine stack (machine stack) is a stack in computer science that stores information about a subroutine that is running. But not necessarily only subroutine messages are stored in the stack. Almost all computer programs rely on a call stack, while high-level languages generally hide the details of the call stack to the background.
The call stack is most often used to deposit the return address of the subroutine. When any subprogram is called, the main program must temporarily store the address to which the subprogram should be returned after the subprogram is completely run. Therefore, if the called subroutine calls another subroutine, its own return address must be stored in the call stack and retrieved after it has been run. In a recursive program, each level of recursion must add an address to the call stack, so if the program appears to recurse indefinitely (or only a plethora of recursive levels), the call stack will produce stack overflow.
Optionally, after the main process generates the memory leak information, the method further includes the following steps:
and step S106, the main process acquires call stack information from the call stack data set.
And step S107, sending the memory leakage information, the call stack information and the memory state information to an abnormality analysis server.
The memory leakage information, the call stack information and the memory state information are collectively called debugging information.
After the abnormity analysis server acquires the debugging information, the debugging information is classified and aggregated, so that the positioning information of the program abnormity breakdown can be quickly acquired, and the efficiency of analyzing the abnormity breakdown is improved.
According to the embodiment of the disclosure, the size information of the virtual memory is directly obtained, so that the memory leakage information is quickly positioned, the memory leakage information is accurately aggregated, and the efficiency of positioning program faults is improved. And a copy-on-write sub-process is created, so that the interference of other threads and/or processes is reduced, the abnormal processing flow is prevented from being interrupted, and the success rate and the stability of acquiring abnormal information are improved.
Corresponding to the first embodiment provided by the present disclosure, the present disclosure also provides a second embodiment, that is, an apparatus for obtaining memory leak information. Since the second embodiment is basically similar to the first embodiment, the description is simple, and the relevant portions should be referred to the corresponding description of the first embodiment. The device embodiments described below are merely illustrative.
Fig. 3 shows an embodiment of an apparatus for acquiring memory leak information provided by the present disclosure. Fig. 3 is a block diagram of units of an apparatus for obtaining memory leak information according to an embodiment of the present disclosure.
Referring to fig. 3, the present disclosure provides an apparatus for obtaining memory leak information, including: an acquire exception crash information unit 301, a create emergency subprocess unit 302, a save memory state information unit 303, an acquire memory state information unit 304, and a generate memory leak information unit 305.
An acquire abnormal crash information unit 301, configured to acquire abnormal crash information of the host process;
an emergency subprocess creating unit 302, configured to create and run an emergency subprocess by the host process based on the triggering of the abnormal crash information;
a memory state information storing unit 303, configured to obtain, by the emergency subprocess, memory state information shared by the host process, and store the memory state information in a memory state data set;
an obtaining memory state information unit 304, configured to obtain memory state information from the memory state data set when the host process operates again;
a memory leak information generating unit 305, configured to generate memory leak information by the host process when the memory state information satisfies a memory exception condition.
Optionally, the unit 303 for saving memory state information includes:
and the emergency subprocess acquires the memory state information of the main process from the real-time memory state file shared with the main process.
Optionally, the memory state information includes size information of a virtual memory;
the unit 305 for generating memory leak information includes:
and the sub-unit for judging the size information of the virtual memory is used for judging that the size information of the virtual memory is larger than a preset process memory threshold value.
Optionally, the emergency sub-process is a copy-on-write sub-process.
Optionally, the creating emergency subprocess unit 302 further includes:
and the call stack information saving subunit is used for acquiring the call stack information by the main process and saving the call stack information into a call stack data set.
Optionally, the apparatus further comprises:
a call stack information acquiring unit, configured to acquire, by a host process, call stack information from the call stack data set;
and the reporting unit is used for sending the memory leakage information, the call stack information and the memory state information to an abnormality analysis server.
Optionally, the real-time memory state file is a "status" file under a directory "/proc/self/" associated with the main process;
the virtual memory size information is information stored in the "VmSize" field of the "status" file.
According to the embodiment of the disclosure, the size information of the virtual memory is directly obtained, so that the memory leakage information is quickly positioned, the memory leakage information is accurately aggregated, and the efficiency of positioning program faults is improved. And a copy-on-write sub-process is created, so that the interference of other threads and/or processes is reduced, the abnormal processing flow is prevented from being interrupted, and the success rate and the stability of acquiring abnormal information are improved.
The embodiment of the present disclosure provides a third embodiment, that is, an electronic device, where the electronic device is used in a method for acquiring memory leak information, and the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of obtaining memory leak information as described in the first embodiment.
The present disclosure provides a fourth embodiment, that is, a computer storage medium for acquiring memory leak information, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions may execute the method for acquiring memory leak information as described in the first embodiment.
Referring now to FIG. 4, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, the electronic device may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage means 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 4 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 409, or from the storage device 408, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (10)

1. A method for obtaining memory leak information is characterized by comprising the following steps:
the main process acquires the abnormal crash information of the main process;
based on the triggering of the abnormal crash information, the main process creates and operates an emergency sub-process;
the emergency sub-process acquires the memory state information shared by the main process and stores the memory state information into a memory state data set;
when the main process operates again, acquiring the memory state information from the memory state data set;
and when the memory state information meets the memory abnormal condition, generating memory leakage information by the main process.
2. The method of claim 1, wherein the acquiring, by the emergency sub-process, the memory state information shared by the host process comprises:
and acquiring the memory state information of the main process by the emergency subprocess from the real-time memory state file shared with the main process.
3. The method of claim 2, wherein the memory state information comprises virtual memory size information;
the memory state information satisfies a memory exception condition, including:
the virtual memory size information is greater than a preset process memory threshold.
4. The method of claim 1, wherein the conforming sub-process is a copy-on-write sub-process.
5. The method of claim 1, after the host process creates and runs an emergency sub-process, further comprising:
and the main process acquires the call stack information and stores the call stack information into a call stack data set.
6. The method of claim 1, wherein after the host process generates the memory leak information, the method further comprises:
the main process acquires call stack information from the call stack data set;
and sending the memory leakage information, the call stack information and the memory state information to an anomaly analysis server.
7. The method of claim 3, wherein the real-time memory state file is a "status" file under the directory "/proc/self/" associated with the host process;
the virtual memory size information is information stored in the "VmSize" field of the "status" file.
8. An apparatus for obtaining memory leak information, comprising:
an abnormal crash information obtaining unit, which is used for the main process to obtain the abnormal crash information;
an emergency subprocess creating unit used for creating and operating an emergency subprocess by the main process based on the triggering of the abnormal crash information;
a memory state information storing unit, configured to acquire, by the emergency subprocess, memory state information shared by the host process, and store the memory state information in a memory state data set;
the memory state information obtaining unit is used for obtaining memory state information from the memory state data set when the main process operates again;
and the memory leak information generating unit is used for generating the memory leak information by the main process when the memory state information meets the memory abnormal condition.
9. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
10. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out the method of any one of claims 1 to 7.
CN201911133763.2A 2019-11-19 2019-11-19 Method, device, medium and electronic equipment for acquiring memory leakage information Active CN111090536B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911133763.2A CN111090536B (en) 2019-11-19 2019-11-19 Method, device, medium and electronic equipment for acquiring memory leakage information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911133763.2A CN111090536B (en) 2019-11-19 2019-11-19 Method, device, medium and electronic equipment for acquiring memory leakage information

Publications (2)

Publication Number Publication Date
CN111090536A true CN111090536A (en) 2020-05-01
CN111090536B CN111090536B (en) 2021-11-16

Family

ID=70393962

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911133763.2A Active CN111090536B (en) 2019-11-19 2019-11-19 Method, device, medium and electronic equipment for acquiring memory leakage information

Country Status (1)

Country Link
CN (1) CN111090536B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111638952A (en) * 2020-05-09 2020-09-08 北京达佳互联信息技术有限公司 Memory dump method and device and electronic equipment
CN111694747A (en) * 2020-06-17 2020-09-22 北京字节跳动网络技术有限公司 Thread detection method, device, equipment and computer readable medium
CN111813666A (en) * 2020-06-30 2020-10-23 北京字节跳动网络技术有限公司 Memory leak positioning method, device, medium and electronic equipment
CN111984496A (en) * 2020-07-16 2020-11-24 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for monitoring stack memory leakage
CN112035314A (en) * 2020-07-31 2020-12-04 北京达佳互联信息技术有限公司 Memory leakage monitoring method and device and electronic equipment
CN112084024A (en) * 2020-08-31 2020-12-15 北京字节跳动网络技术有限公司 Memory monitoring method, device, medium and electronic equipment
CN112286773A (en) * 2020-10-19 2021-01-29 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for collecting crash information
CN113157477A (en) * 2021-04-14 2021-07-23 北京字节跳动网络技术有限公司 Memory leak attribution method and device, electronic equipment and storage medium
CN113886774A (en) * 2021-12-07 2022-01-04 北京微步在线科技有限公司 Anti-debugging method and device
CN114860347A (en) * 2022-05-27 2022-08-05 上海联影医疗科技股份有限公司 Twin process restarting method, equipment, medical system and storage medium
WO2022262530A1 (en) * 2021-06-16 2022-12-22 荣耀终端有限公司 Memory management method and electronic device
CN112035314B (en) * 2020-07-31 2024-04-30 北京达佳互联信息技术有限公司 Memory leakage monitoring method and device and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677456A (en) * 2015-12-30 2016-06-15 广东欧珀移动通信有限公司 Process information writing method and user device
CN108763050A (en) * 2018-04-03 2018-11-06 北京奇艺世纪科技有限公司 A kind of detection method and device of application memory leakage
CN109240809A (en) * 2017-07-11 2019-01-18 阿里巴巴集团控股有限公司 Process maintenance management method, container maintaining method, device and operating system
CN109656779A (en) * 2018-12-07 2019-04-19 广州市百果园信息技术有限公司 Internal memory monitoring method, device, terminal and storage medium
US10289446B1 (en) * 2015-09-15 2019-05-14 Amazon Technologies, Inc. Preserving web browser child processes by substituting a parent process with a stub process

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10289446B1 (en) * 2015-09-15 2019-05-14 Amazon Technologies, Inc. Preserving web browser child processes by substituting a parent process with a stub process
CN105677456A (en) * 2015-12-30 2016-06-15 广东欧珀移动通信有限公司 Process information writing method and user device
CN109240809A (en) * 2017-07-11 2019-01-18 阿里巴巴集团控股有限公司 Process maintenance management method, container maintaining method, device and operating system
CN108763050A (en) * 2018-04-03 2018-11-06 北京奇艺世纪科技有限公司 A kind of detection method and device of application memory leakage
CN109656779A (en) * 2018-12-07 2019-04-19 广州市百果园信息技术有限公司 Internal memory monitoring method, device, terminal and storage medium

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111638952A (en) * 2020-05-09 2020-09-08 北京达佳互联信息技术有限公司 Memory dump method and device and electronic equipment
CN111694747B (en) * 2020-06-17 2023-03-28 抖音视界有限公司 Thread detection method, device, equipment and computer readable medium
CN111694747A (en) * 2020-06-17 2020-09-22 北京字节跳动网络技术有限公司 Thread detection method, device, equipment and computer readable medium
CN111813666A (en) * 2020-06-30 2020-10-23 北京字节跳动网络技术有限公司 Memory leak positioning method, device, medium and electronic equipment
CN111813666B (en) * 2020-06-30 2023-10-27 北京字节跳动网络技术有限公司 Memory leakage positioning method, device, medium and electronic equipment
CN111984496A (en) * 2020-07-16 2020-11-24 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for monitoring stack memory leakage
CN111984496B (en) * 2020-07-16 2024-04-16 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for monitoring stack memory leakage
CN112035314A (en) * 2020-07-31 2020-12-04 北京达佳互联信息技术有限公司 Memory leakage monitoring method and device and electronic equipment
CN112035314B (en) * 2020-07-31 2024-04-30 北京达佳互联信息技术有限公司 Memory leakage monitoring method and device and electronic equipment
CN112084024B (en) * 2020-08-31 2024-02-02 北京字节跳动网络技术有限公司 Memory monitoring method, device, medium and electronic equipment
CN112084024A (en) * 2020-08-31 2020-12-15 北京字节跳动网络技术有限公司 Memory monitoring method, device, medium and electronic equipment
CN112286773A (en) * 2020-10-19 2021-01-29 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for collecting crash information
CN113157477A (en) * 2021-04-14 2021-07-23 北京字节跳动网络技术有限公司 Memory leak attribution method and device, electronic equipment and storage medium
CN113157477B (en) * 2021-04-14 2024-02-06 北京字节跳动网络技术有限公司 Memory leakage attribution method, device, electronic equipment and storage medium
WO2022262530A1 (en) * 2021-06-16 2022-12-22 荣耀终端有限公司 Memory management method and electronic device
CN113886774A (en) * 2021-12-07 2022-01-04 北京微步在线科技有限公司 Anti-debugging method and device
CN113886774B (en) * 2021-12-07 2022-02-11 北京微步在线科技有限公司 Anti-debugging method and device
CN114860347A (en) * 2022-05-27 2022-08-05 上海联影医疗科技股份有限公司 Twin process restarting method, equipment, medical system and storage medium

Also Published As

Publication number Publication date
CN111090536B (en) 2021-11-16

Similar Documents

Publication Publication Date Title
CN111090536B (en) Method, device, medium and electronic equipment for acquiring memory leakage information
JP5737783B2 (en) Debug program, debug system, and method
CN110851204B (en) Application starting method and device and application packaging method and device
CN111611145B (en) Breakdown information collection method and device, storage medium and electronic equipment
CN107644075B (en) Method and device for collecting page information
CN113835992A (en) Memory leak processing method and device, electronic equipment and computer storage medium
CN113407165B (en) SDK generation and self-upgrade method, device, readable medium and equipment
US20140082428A1 (en) Dynamic Hardware Watchpoint
CN113050984A (en) Resource calling method and device, electronic equipment and storage medium
CN112905220A (en) Thermal restoration method, device, equipment and storage medium
CN112084024A (en) Memory monitoring method, device, medium and electronic equipment
CN111240801A (en) Method, device, medium and electronic equipment for generating heap memory snapshot file
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112506781B (en) Test monitoring method, device, electronic equipment, storage medium and program product
CN116051031A (en) Project scheduling system, medium and electronic equipment
US8819494B2 (en) Automatically changing parts in response to tests
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN115705294A (en) Method, device, electronic equipment and medium for acquiring function call information
CN112306683A (en) Function hijacking method, device, medium and electronic equipment
CN114398233B (en) Load abnormality detection method and device, server and storage medium
CN111984496A (en) Method, device, medium and electronic equipment for monitoring stack memory leakage
CN113448602A (en) Version updating method and device
CN111209225B (en) Method, device, medium and electronic equipment for acquiring real address
CN111782410B (en) Lock jam monitoring method and device, electronic equipment and computer readable medium
CN110647405A (en) System message processing method, electronic device, and computer-readable 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
GR01 Patent grant
GR01 Patent grant