CN111984496A - Method, device, medium and electronic equipment for monitoring stack memory leakage - Google Patents

Method, device, medium and electronic equipment for monitoring stack memory leakage Download PDF

Info

Publication number
CN111984496A
CN111984496A CN202010686327.4A CN202010686327A CN111984496A CN 111984496 A CN111984496 A CN 111984496A CN 202010686327 A CN202010686327 A CN 202010686327A CN 111984496 A CN111984496 A CN 111984496A
Authority
CN
China
Prior art keywords
thread
information
stack memory
exit
state
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
CN202010686327.4A
Other languages
Chinese (zh)
Other versions
CN111984496B (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 CN202010686327.4A priority Critical patent/CN111984496B/en
Publication of CN111984496A publication Critical patent/CN111984496A/en
Application granted granted Critical
Publication of CN111984496B publication Critical patent/CN111984496B/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/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/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs

Abstract

The disclosure provides a method, a device, a medium and an electronic device for monitoring stack memory leakage. The method comprises the following steps: acquiring a current exit state in the hijacked instant exit function of the first thread; when the current quitting state is a connection state, inquiring whether waiting quitting information corresponding to the first thread exists in the current application; and when the quit waiting information does not exist, determining that the stack memory leakage of the first thread is abnormal. The method monitors the stack memory leakage condition of the thread from the instant exit function by hijacking the instant exit function, and prompts the stack memory leakage information when the processing mode of releasing the stack memory information does not accord with the grammar rule. The problem of unreasonable program writing lead to stack memory leakage, and then the application crashes is solved.

Description

Method, device, medium and electronic equipment for monitoring stack memory leakage
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and an electronic device for monitoring stack memory leakage.
Background
In computer technology, tasks include various actions and corresponding response events when a user operates a computer. For example, a mouse click, right click, open a dialog box, close a file, start a program. In summary, a task is a broad concept that can be accomplished by many processes interacting with each other.
The thread, a term used in the operating system technology, is the smallest unit that the operating system can perform operation scheduling, is included in a process, and is the actual operation unit in the process. One thread is a single sequential control flow in a process, and multiple threads can be executed in parallel in one process, and each thread executes different tasks in parallel.
In the software development process, complex and heavy tasks are generally completed by one or more independent threads. Therefore, a corresponding relationship exists between the task and the thread.
However, due to the unreasonable application to the program, the stack memory leaks, and finally the program crashes. The stack memory leakage problem is difficult to be found in a crash field, so that the troubleshooting is very difficult.
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 monitoring stack memory leakage, 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 monitoring stack memory leakage, including:
acquiring a current exit state in the hijacked instant exit function of the first thread;
when the current quitting state is a connection state, inquiring whether waiting quitting information corresponding to the first thread exists in the current application;
and when the quit waiting information does not exist, determining that the stack memory leakage of the first thread is abnormal.
According to a second aspect of the present disclosure, there is provided an apparatus for monitoring stack memory leakage, including:
the obtaining unit is used for obtaining the current quit state in the hijacked instant quit function of the first thread;
the query unit is used for querying whether the waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is the connection state;
a determining unit, configured to determine that a stack memory leak of the first thread is abnormal when the wait for exit information does not exist.
According to a third aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method for monitoring stack memory leaks according to any of the first aspect.
According to a fourth aspect thereof, the present disclosure provides 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 implement the method of monitoring stack memory leaks of any of the first aspects.
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 monitoring stack memory leakage. The method monitors the stack memory leakage condition of the thread from the instant exit function by hijacking the instant exit function, and prompts the stack memory leakage information when the processing mode of releasing the stack memory information does not accord with the grammar rule. The problem of unreasonable program writing lead to stack memory leakage, and then the application crashes is solved.
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 flow diagram of a method of monitoring stack memory leaks in accordance with an embodiment of the present disclosure;
FIG. 2 shows a block diagram of elements of an apparatus for monitoring stack memory leaks, according to an embodiment of the present disclosure;
fig. 3 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 monitoring stack memory leakage.
The embodiments of the present disclosure are described in detail below with reference to fig. 1.
Step S101, in the instant exit function of the first thread being hijacked, the current exit state is obtained.
The thread, a term used in the operating system technology, is the smallest unit that the operating system can perform operation scheduling, is included in an application, and is the actual operation unit in the application. One thread is a single sequential control flow in an application, and multiple threads can be executed in parallel in an application, each thread executing a different task in parallel.
The instant exit function is applied to the thread, and the role of the instant exit function is to immediately exit the thread calling the instant exit function.
In a UNIX-like (UNIX, Linux, android) operating system, the instant exit function is denoted pthread _ exit and the create thread function is denoted pthread _ create. When a thread is created by applying the pthread _ create function, a corresponding stack memory is also created in the memory for the thread. Different ways of releasing the stack memory need to be adopted according to two different exit states. When the exiting state of the current application is the separation state (namely PTHREAD _ CREATE _ DETACHED), the corresponding stack memory can be released in the thread through the PTHREAD _ exit function; when the exit state of the current application is the connection state (i.e., PTHREAD _ CREATE _ join), the stack memory of the specified thread needs to be released by calling the wait exit function (i.e., PTHREAD _ join function) by other threads. The pthread _ join function waits in a blocking manner for the specified thread to end. When the waited thread returns, the stack memory of the waited thread is reclaimed by the pthread _ join function. If the waited thread has finished, the pthread _ join function will immediately reclaim the stack memory of the waited thread.
However, many developers often neglect the application rules described above, resulting in stack memory leaks.
The embodiment of the disclosure hijacks the instant exit function through a hook technology so as to monitor whether stack memory leakage is safe or not.
The pthread _ exit function is hijacked because the pthread _ exit function is a system function whose specific code is not open to the outside. Hijacking the pthread _ exit function may be followed by adding to the hijacking function the functionality that the developer wishes to add to the pthread _ exit function. The disclosed embodiment is intended to add a function for monitoring leakage of a stack memory leak to a pthread _ exit function.
The exit state includes a connected state and a disconnected state. The system defaults to the connected state, which may be set to the disconnected state by an exit state setting function (i.e., pthread _ attr _ setdatchstate).
Step S102, when the current quit state is the connection state, whether the waiting quit information corresponding to the first thread exists in the current application is inquired.
And waiting for quitting information, namely whether the information of the function waiting for quitting corresponding to the first thread exists in the current application.
Optionally, the querying whether the waiting exit information corresponding to the first thread exists in the current application includes the following steps:
and step S102-1, obtaining the unique thread identity information of the first thread.
That is, in the instant exit function of the first thread being hijacked, the unique thread identity information of the first thread is obtained. When creating threads, each thread obtains a unique thread identity information to distinguish the work of different threads. In a UNIX-like operating system, the pthread _ create function generates a unique thread identity after the thread is created. However, the pthread _ exit function executes in the current thread, without passing the unique thread identity information parameter of the current thread. The function of acquiring the current unique thread identity information (namely pthread _ self function) can acquire the unique thread identity information of the current thread in the hijacking instant exit function.
And step S102-2, inquiring whether corresponding exit waiting information exists in the exit state information set of the current application or not based on the unique thread identity information.
The exit state information set may be: a text file, a configuration file, a data table, or a spreadsheet. The exit state information set is used for storing information of whether each thread in the application has a corresponding function waiting for exit. Each record of the exit state information set includes unique thread identity information for a thread and wait for exit information for the corresponding thread. For example, in the exit state information set, the wait for exit information indicates that there is a pthread _ join function for the corresponding thread in the application using the character "Y".
Optionally, in order to obtain the exit state information set, before obtaining the current exit state, the method further includes the following steps:
and step S100-1, in the hijacked function waiting for quit, acquiring the unique thread identity information of the first thread from the output parameter of the thread creating function.
The pthread _ join function is hijacked because the pthread _ join function is a system function whose specific code is not open to the outside. Hijacking the pthread _ join function may add to the hijacking function the functions that the developer wishes to add to the pthread _ join function. The disclosed embodiment is intended to add a monitoring function to the pthread _ join function.
Since the pthread _ join function is set in other threads than the first thread, the unique thread identity information of the first thread cannot be obtained by the pthread _ self function. However, the pthread _ join function is to clear the stack memory of the first thread, and one of the input parameters is the unique thread identity information of the first thread. The input parameter values are derived from the output parameters of the pthread _ create function. For example, the format of creating a threading function is: pthread _ create (& thid, NULL, first _ thread, NULL); wherein first _ thread represents the first thread, and thread id represents the unique thread identity information of the first thread.
And S100-2, storing the unique thread identity information and the quit waiting information into the quit state information set.
Each record of the exit state information set includes unique thread identity information for a thread and wait for exit information for the corresponding thread. For example, in the exit state information set, the wait for exit information indicates that there is a pthread _ join function for the corresponding thread in the application using the character "Y".
Optionally, after the current exit state is obtained, the method further includes the following steps:
step S102a, when the current exit state is the detached state, determining that the stack memory of the first thread is normal.
I.e. there is no leakage problem in the stack memory.
Step S103, when the quit waiting information does not exist, determining that the stack memory leak of the first thread is abnormal.
The current exit state is a connected state indicating that there should be a wait for exit function for the first thread in the programming. And when the function waiting for quitting is hijacked, the corresponding information waiting for quitting is recorded. If the quit waiting information does not exist, determining that a quit waiting function corresponding to the first thread is not set in a program, and determining that the stack memory leakage of the first thread is abnormal.
After determining that the stack memory of the first thread leaks abnormally, returning an error and alarming, wherein the method at least comprises the following alarming steps:
step S103a-1, acquiring and storing the stack memory information, and generating corresponding prompt information;
step S103b-1, forcibly quitting the current application;
step S103c-1, the exit state information set of the current application is printed.
Stack memory information is saved and prompted to facilitate a developer in analyzing stack memory leakage information.
And forcibly exiting the current application, and immediately stopping running of the current application so as to remind a developer of the problem of stack memory leakage and immediately start debugging.
Printing the exiting state information set of the current application is beneficial to helping the developer check the lost function waiting for exiting.
When the current quitting state is a connection state, after inquiring whether the waiting quitting information corresponding to the first thread exists in the current application, the method further comprises the following steps:
and step S104, when the quit waiting information exists, determining that the stack memory of the first thread is normal and generating corresponding prompt information.
I.e. there is no leakage problem in the stack memory.
The method and the device for releasing the stack memory information prompt the stack memory to leak the information when the processing mode of releasing the stack memory information does not accord with the grammar rule by hijacking the instant exit function and monitoring the stack memory leakage condition of the thread from the instant exit function. The problem of unreasonable program writing lead to stack memory leakage, and then the application crashes is solved.
Corresponding to the first embodiment provided by the present disclosure, the present disclosure also provides a second embodiment, that is, an apparatus for monitoring stack memory leakage. 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. 2 illustrates an embodiment of an apparatus for monitoring stack memory leakage provided by the present disclosure.
Referring to fig. 2, the present disclosure provides an apparatus for monitoring stack memory leakage, including:
an obtaining unit 201, configured to obtain a current exit state in an instant exit function in which the first thread is hijacked;
a querying unit 202, configured to query whether there is exit waiting information corresponding to the first thread in a current application when the current exit state is a connection state;
a determining unit 203, configured to determine that the stack memory leak of the first thread is abnormal when the wait for exit information does not exist.
Optionally, in the querying unit 202, the method includes:
the sub-unit for obtaining the unique thread identity information is used for obtaining the unique thread identity information of the first thread;
and the query waiting exit information subunit is used for querying whether the exit state information set of the current application has corresponding waiting exit information or not based on the unique thread identity information.
Optionally, the apparatus further includes: a recording unit;
in the recording unit, comprising:
an obtaining output parameter subunit, configured to, before obtaining the current exit state, obtain, in a hijacked function waiting for exit, unique thread identity information of the first thread from an output parameter of a function creating thread;
and the saving subunit is used for saving the unique thread identity information and the quitting waiting information into the quitting state information set.
Optionally, the apparatus further includes:
and the first normal prompt unit is used for determining that the stack memory of the first thread is normal when the current exit state is the separation state after the current exit state is acquired.
Optionally, the apparatus further includes:
and the second normal prompt unit is used for determining that the stack memory of the first thread is normal and generating corresponding prompt information when the quit waiting information exists.
Optionally, the apparatus further includes:
and the stack memory information saving unit is used for acquiring and saving the stack memory information and generating corresponding prompt information after determining that the stack memory of the first thread is abnormal in leakage.
Optionally, the apparatus further includes:
and the exit current application unit is used for forcibly exiting the current application after the stack memory leak abnormity of the first thread is determined.
The method and the device for releasing the stack memory information prompt the stack memory to leak the information when the processing mode of releasing the stack memory information does not accord with the grammar rule by hijacking the instant exit function and monitoring the stack memory leakage condition of the thread from the instant exit function. The problem of unreasonable program writing lead to stack memory leakage, and then the application crashes is solved.
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 monitoring stack memory leakage, 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 one processor to cause the at least one processor to perform the method of monitoring stack memory leaks of the first embodiment.
The fourth embodiment provides a computer storage medium for monitoring stack memory leakage, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions may execute the method for monitoring stack memory leakage described in the first embodiment.
Referring now to FIG. 3, 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. 3 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. 3, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage device 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 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 through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
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 interconnect 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 monitoring stack memory leaks, comprising:
acquiring a current exit state in the hijacked instant exit function of the first thread;
when the current quitting state is a connection state, inquiring whether waiting quitting information corresponding to the first thread exists in the current application;
and when the quit waiting information does not exist, determining that the stack memory leakage of the first thread is abnormal.
2. The method of claim 1, wherein said querying whether exit waiting information corresponding to the first thread exists in the current application comprises:
acquiring unique thread identity information of the first thread;
and inquiring whether corresponding quit waiting information exists in the quit state information set of the current application or not based on the unique thread identity information.
3. The method of claim 2, further comprising, prior to said obtaining a current exit state:
in the hijacked function waiting for quitting, acquiring the unique thread identity information of the first thread from the output parameter of the function creating thread;
and storing the unique thread identity information and the quit waiting information into the quit state information set.
4. The method of claim 1, further comprising, after said obtaining a current exit status:
and when the current exit state is the separation state, determining that the stack memory of the first thread is normal.
5. The method according to claim 1, wherein after querying whether there is exiting waiting information corresponding to the first thread in the current application when the current exiting state is the connection state, the method further comprises:
and when the quit waiting information exists, determining that the stack memory of the first thread is normal and generating corresponding prompt information.
6. The method of claim 1, after said determining that the stack memory leak of the first thread is abnormal, further comprising:
and acquiring and storing the stack memory information, and generating corresponding prompt information.
7. The method of claim 1, further comprising, after determining that the stack memory leak of the first thread is abnormal, at least one of:
inquiring and printing an exit state information set of the current application based on the unique thread identity information;
outputting the stack memory information;
and forcibly exiting the current application.
8. An apparatus for monitoring stack memory leaks, comprising:
the obtaining unit is used for obtaining the current quit state in the hijacked instant quit function of the first thread;
the query unit is used for querying whether the waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is the connection state;
a determining unit, configured to determine that a stack memory leak of the first thread is abnormal when the wait for exit information does not exist.
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.
CN202010686327.4A 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage Active CN111984496B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010686327.4A CN111984496B (en) 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010686327.4A CN111984496B (en) 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage

Publications (2)

Publication Number Publication Date
CN111984496A true CN111984496A (en) 2020-11-24
CN111984496B CN111984496B (en) 2024-04-16

Family

ID=73439248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010686327.4A Active CN111984496B (en) 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage

Country Status (1)

Country Link
CN (1) CN111984496B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342431A (en) * 2021-06-29 2021-09-03 苏州科达科技股份有限公司 Function call stack backtracking and program exception handling method, device, equipment and medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763305A (en) * 2009-12-29 2010-06-30 青岛海信宽带多媒体技术有限公司 Method for detecting memory leak of embedded system
CN101908018A (en) * 2010-07-20 2010-12-08 北京海泰方圆科技有限公司 System and method for judging memory leak
CN103404082A (en) * 2011-03-15 2013-11-20 欧姆龙株式会社 Connection abnormality detection method, network system, and master device
CN106502880A (en) * 2016-09-20 2017-03-15 东软集团股份有限公司 A kind of memory overflow adjustment method and device
CN106802861A (en) * 2015-11-26 2017-06-06 大唐移动通信设备有限公司 A kind of method and apparatus for detecting RAM leakage
CN109918897A (en) * 2019-02-27 2019-06-21 苏州浪潮智能科技有限公司 A kind of password authentification test method and system based on AEP memory
CN110633190A (en) * 2019-09-26 2019-12-31 北京博睿宏远数据科技股份有限公司 Application program memory monitoring method, device, equipment and storage medium
CN110704217A (en) * 2019-08-27 2020-01-17 努比亚技术有限公司 Memory leak detection method, terminal and computer readable storage medium
CN111090536A (en) * 2019-11-19 2020-05-01 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring memory leakage information

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763305A (en) * 2009-12-29 2010-06-30 青岛海信宽带多媒体技术有限公司 Method for detecting memory leak of embedded system
CN101908018A (en) * 2010-07-20 2010-12-08 北京海泰方圆科技有限公司 System and method for judging memory leak
CN103404082A (en) * 2011-03-15 2013-11-20 欧姆龙株式会社 Connection abnormality detection method, network system, and master device
CN106802861A (en) * 2015-11-26 2017-06-06 大唐移动通信设备有限公司 A kind of method and apparatus for detecting RAM leakage
CN106502880A (en) * 2016-09-20 2017-03-15 东软集团股份有限公司 A kind of memory overflow adjustment method and device
CN109918897A (en) * 2019-02-27 2019-06-21 苏州浪潮智能科技有限公司 A kind of password authentification test method and system based on AEP memory
CN110704217A (en) * 2019-08-27 2020-01-17 努比亚技术有限公司 Memory leak detection method, terminal and computer readable storage medium
CN110633190A (en) * 2019-09-26 2019-12-31 北京博睿宏远数据科技股份有限公司 Application program memory monitoring method, device, equipment and storage medium
CN111090536A (en) * 2019-11-19 2020-05-01 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring memory leakage information

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WSYGZYR: "pthread_join pthread_exit pthread_detach", Retrieved from the Internet <URL:https://blog.csdn.net/wsygzyr/article/details/6240176> *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342431A (en) * 2021-06-29 2021-09-03 苏州科达科技股份有限公司 Function call stack backtracking and program exception handling method, device, equipment and medium
CN113342431B (en) * 2021-06-29 2023-02-07 苏州科达科技股份有限公司 Function call stack backtracking and program exception handling method, device, equipment and medium

Also Published As

Publication number Publication date
CN111984496B (en) 2024-04-16

Similar Documents

Publication Publication Date Title
CN111090536B (en) Method, device, medium and electronic equipment for acquiring memory leakage information
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN110377341B (en) Method, device, medium and electronic equipment for monitoring no-response exception
CN110727566B (en) Method, device, medium and electronic equipment for acquiring process crash information
CN110618928A (en) Memory leak detection method and device, terminal equipment and medium
CN111984496B (en) Method, device, medium and electronic equipment for monitoring stack memory leakage
CN112084024A (en) Memory monitoring method, device, medium and electronic equipment
CN111240801A (en) Method, device, medium and electronic equipment for generating heap memory snapshot file
CN111538717B (en) Data processing method, device, electronic equipment and computer readable medium
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN112817701A (en) Timer processing method and device, electronic equipment and computer readable medium
CN112506781A (en) Test monitoring method, test monitoring device, electronic device, storage medium, and program product
CN111367590A (en) Interrupt event processing method and device
CN117155994B (en) Service registration management method, device, equipment and readable storage medium
CN111782410B (en) Lock jam monitoring method and device, electronic equipment and computer readable medium
CN116149822A (en) Task execution method, device, electronic equipment and storage medium
CN116302142A (en) Lifecycle event management method, lifecycle event management device, storage medium, and electronic apparatus
CN113722206A (en) Data annotation method and device, electronic equipment and computer readable medium
CN116776396A (en) Data processing method, device, equipment, vehicle and storage medium
CN116701013A (en) Message consumption method, device, electronic equipment and computer readable medium
CN116166528A (en) Automatic testing method and device for user information card system function and electronic equipment
CN115373998A (en) Application program optimization method, device, equipment and medium
CN113760590A (en) Fault processing method and device, electronic equipment and computer readable medium
CN115408230A (en) Application management device, method, vehicle, and storage medium
CN116501597A (en) Code detection method, device, equipment 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
GR01 Patent grant