CN115952088A - Memory leak detection method, device, equipment and storage medium - Google Patents

Memory leak detection method, device, equipment and storage medium Download PDF

Info

Publication number
CN115952088A
CN115952088A CN202211667119.5A CN202211667119A CN115952088A CN 115952088 A CN115952088 A CN 115952088A CN 202211667119 A CN202211667119 A CN 202211667119A CN 115952088 A CN115952088 A CN 115952088A
Authority
CN
China
Prior art keywords
memory
operation task
information
memory information
set operation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211667119.5A
Other languages
Chinese (zh)
Inventor
朱勇富
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao 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 Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202211667119.5A priority Critical patent/CN115952088A/en
Publication of CN115952088A publication Critical patent/CN115952088A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure provides a method, a device, equipment and a storage medium for detecting memory leakage. The method comprises the following steps: controlling the target equipment to periodically execute a set operation task; the set operation task is used for simulating the operation behavior of a user on the terminal; reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set; determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak. According to the embodiment of the disclosure, the accuracy of the memory leak detection can be improved by acquiring the memory information set after the target device periodically executes the set operation task and determining the memory leak result corresponding to the set operation task based on the memory information set.

Description

Memory leak detection method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for detecting memory leakage.
Background
The memory leak refers to that the dynamically allocated memory in the program is not released or cannot be released for some reason, which causes waste of the system memory, thereby causing serious consequences such as slow program running speed and even system running. Therefore, it is important to detect the memory leak.
In the related art, the existing tool is used for detecting the memory leak, and the mode cannot accurately detect the change condition of the memory. Or, the codes of the program operation are detected, only the memory leakage of the code layer can be detected, and the memory leakage of the system layer cannot be detected, so that the method is not accurate enough.
Disclosure of Invention
The embodiment of the disclosure provides a method, a device, equipment and a storage medium for detecting memory leakage, which can improve the accuracy of memory leakage detection.
In a first aspect, an embodiment of the present disclosure provides a method for detecting memory leak, including:
controlling the target equipment to periodically execute a set operation task; the set operation task is used for simulating the operation behavior of a user on the terminal;
reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set;
determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
In a second aspect, an embodiment of the present disclosure further provides a device for detecting memory leak, including:
the setting operation task execution module is used for controlling the target equipment to periodically execute the setting operation task; the set operation task is used for simulating the operation behavior of a user on the terminal;
the memory information reading module is used for reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set;
the memory leakage result determining module is used for determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device to store one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting a memory leak according to the embodiment of the present disclosure.
In a fourth aspect, the present disclosure further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are used to perform the method for detecting memory leaks according to the present disclosure.
According to the technical scheme of the embodiment of the disclosure, the operation task is set by controlling the target equipment to periodically execute; the set operation task is used for simulating the operation behavior of a user on the terminal; reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set; determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak. According to the embodiment of the disclosure, the accuracy of the memory leak detection can be improved by acquiring the memory information set after the target device periodically executes the set operation task and determining the memory leak result corresponding to the set operation task based on the memory information set.
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.
Fig. 1 is a schematic diagram illustrating a detection process of memory leakage according to an embodiment of the disclosure;
fig. 2 is a schematic structural diagram of a device for detecting memory leakage according to an embodiment of the disclosure;
fig. 3 is a schematic structural diagram of an electronic device 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 should 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 complete and thorough 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.
It is understood that before the technical solutions disclosed in the embodiments of the present disclosure are used, the type, the use range, the use scene, etc. of the personal information related to the present disclosure should be informed to the user and obtain the authorization of the user through a proper manner according to the relevant laws and regulations.
For example, in response to receiving an active request from a user, a prompt message is sent to the user to explicitly prompt the user that the requested operation to be performed would require the acquisition and use of personal information to the user. Thus, the user can autonomously select whether to provide personal information to software or hardware such as an electronic device, an application program, a server, or a storage medium that performs the operations of the disclosed technical solution, according to the prompt information.
As an alternative but non-limiting implementation manner, in response to receiving an active request from the user, the manner of sending the prompt information to the user may be, for example, a pop-up window manner, and the prompt information may be presented in a text manner in the pop-up window. In addition, a selection control for providing personal information to the electronic device by the user's selection of "agreeing" or "disagreeing" can be carried in the pop-up window.
It is understood that the above notification and user authorization process is only illustrative and is not intended to limit the implementation of the present disclosure, and other ways of satisfying the relevant laws and regulations may be applied to the implementation of the present disclosure.
It will be appreciated that the data referred to in this disclosure, including but not limited to the data itself, the acquisition or use of the data, should comply with the requirements of the applicable laws and regulations and related regulations.
Fig. 1 is a schematic diagram of a detection flow of memory leak provided in an embodiment of the present disclosure, where the embodiment of the present disclosure is applicable to a situation of detecting memory leak, and the method may be executed by a detection apparatus of memory leak, where the apparatus may be implemented in a form of software and/or hardware, and optionally implemented by an electronic device, where the electronic device may be a mobile terminal, a PC terminal, or a server.
As shown in fig. 1, the method includes:
and S110, controlling the target equipment to periodically execute a setting operation task.
The target device may be understood as a target terminal, and the target terminal may be a mobile terminal of any operating system, for example, a mobile phone terminal of an Android operating system. And setting an operation task for simulating the operation behavior of the user on the terminal. Taking an Application (APP) simulating a user to operate the mobile terminal as an example, the setting operation tasks corresponding to different applications are different, and if an image processing Application is taken as an example, the setting operation task may be an operation behavior of processing an original image by using various beauty special effect functions.
Specifically, a memory leak detection script program may be set in advance at the PC, the PC is connected to the target device, and the memory leak detection script program is executed at the PC, so that the target device is controlled, and the target device is controlled to periodically execute the operation task according to a preset cycle number or an execution duration. The memory leak detection script program may be understood as a program code simulating a user operating a target device.
Optionally, the manner of periodically executing the setting operation task by the control target device may be: configuring cycle times or execution duration; the control target device executes a set operation task periodically based on the cycle number; or the control target device periodically executes the setting operation task within the execution duration.
The number of cycles may be any number of times, and may be, for example, 100 times, 300 times, 500 times, or the like. The execution time length may be any time length, and for example, may be N times, such as 100 times, 300 times, 500 times, etc., of the time length required for executing the setting operation task of one cycle. According to the embodiment, whether the memory leak exists during the execution of the set operation task can be effectively detected by periodically executing the set operation task based on the cycle number or the execution duration of the set operation task, and the accuracy of detecting the memory leak is improved.
Optionally, the setting operation task includes a plurality of sub-tasks, and the manner for the control target device to periodically execute the setting operation task may be: determining the interval duration of every two adjacent subtasks in the plurality of subtasks; and in the execution period of each set operation task, after the target terminal completes one subtask, pausing the interval duration and continuing to execute the next subtask.
The interval duration is determined by the response duration of the target terminal to the previous subtask. It should be noted that, since the set operation task includes a plurality of subtasks, the target terminal needs a corresponding response time after each subtask is executed. Therefore, the interval duration of every two adjacent subtasks in the multiple subtasks can be predetermined, so that when the subtasks are actually executed, after the target terminal completes one subtask, the next subtask is executed after the interval duration elapses, that is, the next subtask is executed again after the interval duration elapses before the next subtask is executed. In this embodiment, each subtask may be characterized by a screen coordinate, that is, in the current subtask, the target device is controlled by triggering a position corresponding to the screen coordinate.
In the embodiment, in the execution period of each set operation task, after the target terminal completes one subtask, after the interval duration elapses, the next subtask is executed again, and the response duration required by the target device after each execution of the subtask is considered, so that the manner of controlling the target device to periodically execute a plurality of subtasks better meets the actual situation, and further, whether memory leakage exists in the subsequent subtasks or not is conveniently detected.
And S120, reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set.
The memory information may be a memory space occupied by the currently detected application program after the setting operation task of one cycle is executed, for example, the memory information may be 64125 kilobytes. Correspondingly, the memory information set may be a set of memory information occupied by the currently detected application program after the set operation task is periodically executed. For example, if the setting operation task is executed in three cycles, the corresponding memory information sets may be 64125 kbytes, 64273 kbytes, and 64501 kbytes.
Optionally, the manner of reading the memory information of the target device after the execution of the set operation task is completed and obtaining the memory information set may be: and in the process of periodically executing the set operation task by the target equipment, reading the memory information of the target equipment every first set time length to obtain a memory information set.
Specifically, in the process of periodically executing the setting operation task, the memory information of the target device may be periodically (every first set time length) read and recorded. The reading period of the memory information is greater than the execution period of the set operation task, that is, the first set duration is greater than the execution period of the set operation task. For example, if it takes 2 seconds to execute the setting operation task of one cycle, the read cycle of the memory information may be 2.5 seconds. In addition, the memory information can be read and recorded before the setting operation task of the first period is executed. The recording and storing mode of the memory information can be to record the memory information after executing the set operation task according to the row or the column and store the memory information in the form of a file, so as to facilitate the subsequent extraction and operation of the memory information set and facilitate the positioning of whether the set operation task has memory leakage.
In this embodiment, in the process of periodically executing the setting operation task, the memory information of the target device is read every first set duration, so that the memory information corresponding to the execution of the setting operation task can be accurately read.
And S130, determining a memory leakage result corresponding to the set operation task based on the memory information set.
Wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak. In this embodiment, the memory leakage result corresponding to the set operation task may be determined by counting the memory information in the memory information set and determining whether the counted memory information exceeds the set threshold, or the memory leakage amount may be counted according to the memory information set, and the ratio of the memory leakage amount to the total time length for executing the set operation task is calculated, that is, the memory leakage result corresponding to the set operation task is determined by calculating the memory leakage rate.
Optionally, the mode of determining the memory leak result corresponding to the set operation task based on the memory information set may be: extracting the memory information with the set quantity which is ranked in the memory information set in the front as a first memory information subset; extracting the memory information with the set quantity which is ranked backwards in the memory information set as a second memory information subset; and determining a memory leakage result corresponding to the set operation task based on the first memory information subset and the second memory information subset.
It should be noted that the memory information in the memory information set is stored in rows or columns according to the order of executing the set operation task, so that the memory information in the memory information set with the set number ordered in the top may be extracted row by row or column by column according to a pre-stored manner, and used as the first memory information subset. And extracting the memory information with the set quantity which is arranged at the back in the memory information set row by row or column by column, and taking the memory information as a second memory information subset. The set number may be 10 or 20, which is not limited in this embodiment. For example, if the execution cycle is 100, the set number is 10, and the storage manner by row is taken as an example, the memory information corresponding to the set operation task executed in the first 10 cycles may be extracted by row as the first memory information subset, and the memory information corresponding to the set operation task executed in the last 10 cycles may be extracted by row as the second memory information subset.
In this embodiment, by extracting the first memory information subset and the second memory information subset, and determining the memory leak result corresponding to the set operation task based on the first memory information subset and the second memory information subset, the efficiency and accuracy for detecting whether the set operation task has a memory leak can be improved.
Optionally, the manner of determining the memory leakage result corresponding to the set operation task based on the first memory information subset and the second memory information subset may be: extracting first memory statistical information in the first memory information subset and second memory statistical information in the second memory information subset; determining the memory leakage amount according to the second memory statistical information and the first memory statistical information; if the memory leakage amount is larger than or equal to a first set threshold value, setting that the memory leakage exists in the operation task; and if the memory leakage amount is smaller than a first set threshold value, setting that the operation task has no memory leakage.
The memory statistical information includes maximum memory information, minimum memory information or average memory information. Specifically, memory statistics may be performed on the first memory information subset and the second memory information subset, and correspondingly, the first memory statistical information and the second memory statistical information may be obtained correspondingly. The memory statistics may be maximum memory statistics, minimum memory statistics, average memory statistics, and the like. After the first memory statistical information and the second memory statistical information are obtained, taking the difference between the second memory statistical information and the first memory statistical information as the memory leakage amount, comparing the memory leakage amount with a first set threshold value, and if the memory leakage amount is greater than or equal to the first set threshold value, setting that the memory leakage exists in the operation task; and if the memory leakage amount is smaller than a first set threshold value, setting that the operation task has no memory leakage. The first set threshold may be any value, and may be, for example, 10 megabits, 12 megabits, or the like.
In this embodiment, the memory leakage amount is determined according to the second memory statistical information and the first memory statistical information, and whether the memory leakage exists in the set operation task is determined by judging whether the memory leakage amount exceeds the first set threshold, so that whether the memory leakage exists in the set operation task can be effectively and accurately detected, and the accuracy of detecting the memory leakage is improved.
Optionally, the manner of determining the memory leakage result corresponding to the set operation task based on the first memory information subset and the second memory information subset may be: acquiring the total execution time of a set operation task; determining the memory leakage rate based on the memory leakage amount and the total execution time; if the memory leakage rate is larger than or equal to a second set threshold value, setting that the memory leakage exists in the operation task; and if the memory leak rate is smaller than a second set threshold, setting that the memory leak does not exist in the operation task.
The total execution time length may be a preset execution time length, and is used for periodically executing the set operation task in the total execution time length. The memory leakage amount may be a memory leakage amount corresponding to the set operation task executed periodically within the total execution duration, and the memory leakage rate may be: memory leak amount/total length of execution time. The second set threshold may be any value, but this embodiment is not limited to this, and may be, for example, 5 million per hour, 10 million per hour, or the like. For example, if the total execution time is 24 hours, the memory leak amount is 100 megabytes, and the memory leak rate is: and 100 Mm/24 hours, the second set threshold value is 5 Mm per hour, and the memory leak rate is smaller than the second set threshold value, so that the memory leak of the operation task is set. If the total execution time is 1 hour, the memory leakage amount is 100 megabytes, and the memory leakage rate is as follows: and 100 Mm/1 hour, the second set threshold value is 5 Mm per hour, and the memory leak rate is greater than the second set threshold value, so that the memory leak of the operation task is set.
In this embodiment, whether the memory leak exists in the set operation task is determined by the memory leak rate, so that whether the memory leak exists in the set operation task can be further accurately detected, and the accuracy of detecting the memory leak is improved.
Optionally, after determining, based on the memory information set, a memory leak result corresponding to the set operation task, the method further includes: if the memory leakage exists in the set operation task, controlling the target equipment to periodically execute a plurality of subtasks respectively; reading the memory information of the target equipment after the execution of the subtask is finished, and obtaining a subtank memory information set; and determining a memory leakage result corresponding to the subtask based on the sub memory information set.
Specifically, when memory leakage exists in the set operation task, the target device is controlled to periodically execute a plurality of subtasks, the memory information of the target device is read every set time length in the periodic execution of the subtasks by the target device, a memory information set is obtained, and a memory leakage result corresponding to the subtasks is determined according to the memory information set. In this embodiment, a manner of periodically executing the subtask by the control target device is consistent with a manner of periodically executing the set operation task by the control target device in the above embodiment, a manner of obtaining the sub memory information set and a manner of determining the memory leakage result corresponding to the subtask based on the sub memory information set are consistent with a manner of reading the memory information of the target device after the execution of the set operation task is completed, a manner of obtaining the memory information set and a manner of determining the memory leakage result corresponding to the set operation task based on the memory information set in the above embodiment, and details are not described here.
In this embodiment, when there is memory leak in the set operation task, the target device is controlled to periodically execute a plurality of subtasks, respectively, the memory information of the target device after the execution of the subtasks is completed is read, a subtank information set is obtained, and a memory leak result corresponding to the subtask is determined based on the subtank information set, so that whether there is memory leak in each subtask in the set operation task can be more accurately detected, and the accuracy of detecting the memory leak can be further improved.
According to the technical scheme of the embodiment of the disclosure, the operation tasks are set by controlling the target equipment to periodically execute; the set operation task is used for simulating the operation behavior of a user on the terminal; reading the memory information of the target equipment after the execution of the set operation task is finished, and acquiring a memory information set; determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak. According to the embodiment of the disclosure, the accuracy of the memory leak detection can be improved by acquiring the memory information set after the target device periodically executes the set operation task and determining the memory leak result corresponding to the set operation task based on the memory information set.
Fig. 2 is a schematic structural diagram of a device for detecting memory leakage according to an embodiment of the present disclosure, and as shown in fig. 2, the device includes: a setting operation task executing module 210, a memory information reading module 220, and a memory leakage result determining module 230.
A setting operation task execution module 210, configured to control the target device to periodically execute the setting operation task; the set operation task is used for simulating the operation behavior of a user on the terminal;
a memory information reading module 220, configured to read the memory information of the target device after the execution of the set operation task is completed, and obtain a memory information set;
a memory leak result determining module 230, configured to determine, based on the memory information set, a memory leak result corresponding to the set operation task; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
According to the technical scheme of the embodiment of the disclosure, the setting operation task execution module controls the target equipment to periodically execute the setting operation task; the set operation task is used for simulating the operation behavior of a user on the terminal; reading the memory information of the target equipment after the execution of the set operation task is finished through a memory information reading module to obtain a memory information set; determining a memory leakage result corresponding to the set operation task based on the memory information set through a memory leakage result determination module; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak. According to the embodiment of the disclosure, the accuracy of the memory leak detection can be improved by acquiring the memory information set after the target device periodically executes the set operation task and determining the memory leak result corresponding to the set operation task based on the memory information set.
Optionally, the setting operation task execution module is specifically configured to: configuring cycle times or execution duration; the control target device periodically executes a set operation task based on the cycle number; or the control target device periodically executes the set operation task in the execution duration.
Optionally, the memory information reading module is specifically configured to: in the process of periodically executing a set operation task by target equipment, reading memory information of the target equipment every first set time length to obtain a memory information set; and the first set duration is longer than the execution period of the set operation task.
Optionally, the memory leak result determining module is specifically configured to: extracting a set amount of memory information which is ranked in the memory information set in the front as a first memory information subset; extracting a set amount of memory information ranked backwards in the memory information set as a second memory information subset; and determining a memory leak result corresponding to the set operation task based on the first memory information subset and the second memory information subset.
Optionally, the memory leak result determining module is further configured to: extracting first memory statistical information in the first memory information subset and second memory statistical information in the second memory information subset; the memory statistical information comprises maximum memory information, minimum memory information or average memory information; determining memory leakage amount according to the second memory statistical information and the first memory statistical information; if the memory leak amount is larger than or equal to a first set threshold value, the set operation task has memory leak; and if the memory leak amount is smaller than a first set threshold value, the set operation task has no memory leak.
Optionally, the memory leak result determining module is further configured to: acquiring the total execution time of the set operation task; determining a memory leak rate based on the memory leak amount and the total execution duration; if the memory leak rate is greater than or equal to a second set threshold, the set operation task has memory leak; and if the memory leak rate is smaller than a second set threshold, the set operation task has no memory leak.
Optionally, the setting operation task includes multiple subtasks, and the setting operation task execution module is specifically configured to: determining the interval duration of every two adjacent subtasks in the plurality of subtasks; the interval duration is determined by the response duration of the target terminal to the previous subtask; and in the execution period of each set operation task, after the target terminal completes one subtask, pausing the interval duration and continuing to execute the next subtask.
Optionally, the memory leak result determining module is further configured to: if the memory leakage exists in the set operation task, controlling the target equipment to periodically execute the plurality of subtasks respectively; reading the memory information of the target equipment after the execution of the subtask is finished, and obtaining a subtask memory information set; and determining a memory leakage result corresponding to the subtask based on the sub memory information set.
The device for detecting memory leak provided by the embodiment of the disclosure can execute the method for detecting memory leak provided by any embodiment of the disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the embodiments of the present disclosure.
Fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure. Referring now to fig. 3, a schematic diagram of an electronic device (e.g., the terminal device or the server in fig. 3) 500 suitable for implementing embodiments of the present disclosure is shown. 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 fixed 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, electronic device 500 may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the electronic apparatus 500 are also stored. The processing device 501, the ROM502, and the RAM503 are connected to each other through a bus 504. An editing/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 509. The communication means 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 illustrates an electronic device 500 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 means 509, or installed from the storage means 508, or installed from the ROM 502. 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 501.
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.
The electronic device provided by the embodiment of the present disclosure and the method for detecting memory leak provided by the above embodiment belong to the same inventive concept, and technical details that are not described in detail in the embodiment may refer to the above embodiment, and the embodiment and the above embodiment have the same beneficial effects.
The embodiment of the present disclosure provides a computer storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for detecting memory leak provided by the above embodiment is implemented.
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.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: controlling the target equipment to periodically execute a set operation task; the set operation task is used for simulating the operation behavior of a user on the terminal;
reading the memory information of the target equipment after the execution of the set operation task is finished, and acquiring a memory information set;
determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
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 a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".
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 compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, a method for detecting memory leak is disclosed, including: controlling the target equipment to periodically execute a set operation task; the set operation task is used for simulating the operation behavior of a user on the terminal; reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set; determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
Further, the control target device periodically executes the setting operation task, including: configuring cycle times or execution duration; the control target device periodically executes a set operation task based on the cycle number; or the control target device periodically executes the set operation task in the execution duration.
Further, reading the memory information of the target device after the execution of the set operation task is completed, and obtaining a memory information set, including: in the process of periodically executing a set operation task by target equipment, reading memory information of the target equipment every first set time length to obtain a memory information set; and the first set duration is longer than the execution period of the set operation task.
Further, determining a memory leakage result corresponding to the set operation task based on the memory information set includes: extracting a set amount of memory information which is ranked in the memory information set in the front as a first memory information subset; extracting a set amount of memory information ranked backwards in the memory information set as a second memory information subset; and determining a memory leakage result corresponding to the set operation task based on the first memory information subset and the second memory information subset.
Further, determining a memory leakage result corresponding to the set operation task based on the first memory information subset and the second memory information subset includes: extracting first memory statistical information in the first memory information subset and second memory statistical information in the second memory information subset; the memory statistical information comprises maximum memory information, minimum memory information or average memory information; determining the memory leakage amount according to the second memory statistical information and the first memory statistical information; if the memory leakage amount is larger than or equal to a first set threshold value, the memory leakage exists in the set operation task; and if the memory leak amount is smaller than a first set threshold value, the set operation task has no memory leak.
Further, determining a memory leak result corresponding to the set operation task based on the first memory information subset and the second memory information subset includes: acquiring the total execution time of the set operation task; determining a memory leak rate based on the memory leak amount and the total execution duration; if the memory leak rate is larger than or equal to a second set threshold, the set operation task has memory leak; and if the memory leak rate is smaller than a second set threshold, the set operation task has no memory leak.
Further, the setting operation task includes a plurality of sub-tasks, and the controlling target device periodically executes the setting operation task, including: determining the interval duration of every two adjacent subtasks in the plurality of subtasks; the interval duration is determined by the response duration of the target terminal to the previous subtask; and in the execution period of each set operation task, after the target terminal completes one subtask, pausing the interval duration and continuing to execute the next subtask.
Further, after determining the memory leak result corresponding to the set operation task based on the memory information set, the method further includes: if the memory leakage exists in the set operation task, controlling the target equipment to periodically execute the plurality of subtasks respectively; reading the memory information of the target equipment after the execution of the subtask is finished, and obtaining a subtask information set; and determining a memory leakage result corresponding to the subtask based on the sub memory information set.
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 (11)

1. A method for detecting memory leak is characterized by comprising the following steps:
controlling the target equipment to periodically execute a set operation task; the set operation task is used for simulating the operation behavior of a user on the terminal;
reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set;
determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
2. The method according to claim 1, wherein the control target device periodically performs the setting operation task, including:
configuring cycle times or execution duration;
the control target device periodically executes a set operation task based on the cycle number; or the control target device periodically executes the set operation task in the execution duration.
3. The method according to claim 1, wherein reading the memory information of the target device after the execution of the set operation task is completed to obtain a memory information set, comprises:
reading the memory information of the target equipment every a first set time length in the process of periodically executing the set operation task by the target equipment to obtain a memory information set; and the first set duration is longer than the execution period of the set operation task.
4. The method of claim 1, wherein determining the memory leakage result corresponding to the set operation task based on the memory information set comprises:
extracting a set amount of memory information which is ranked in the front in the memory information set as a first memory information subset;
extracting a set amount of memory information ranked backwards in the memory information set as a second memory information subset;
and determining a memory leak result corresponding to the set operation task based on the first memory information subset and the second memory information subset.
5. The method of claim 4, wherein determining the memory leak result corresponding to the set operation task based on the first subset of memory information and the second subset of memory information comprises:
extracting first memory statistical information in the first memory information subset and second memory statistical information in the second memory information subset; the memory statistical information comprises maximum memory information, minimum memory information or average memory information;
determining memory leakage amount according to the second memory statistical information and the first memory statistical information;
if the memory leakage amount is larger than or equal to a first set threshold value, the memory leakage exists in the set operation task; and if the memory leakage amount is smaller than a first set threshold value, the set operation task has no memory leakage.
6. The method of claim 5, wherein determining the memory leak result corresponding to the set operation task based on the first subset of memory information and the second subset of memory information comprises:
acquiring the total execution time of the set operation task;
determining a memory leak rate based on the memory leak amount and the total execution duration;
if the memory leak rate is greater than or equal to a second set threshold, the set operation task has memory leak; and if the memory leak rate is smaller than a second set threshold, the set operation task has no memory leak.
7. The method according to claim 1, wherein the setting operation task comprises a plurality of sub-tasks, and the controlling target device periodically executes the setting operation task, including:
determining the interval duration of every two adjacent subtasks in the plurality of subtasks; the interval duration is determined by the response duration of the target terminal to the previous subtask;
and in the execution period of each set operation task, after the target terminal completes one subtask, pausing the interval duration and continuing to execute the next subtask.
8. The method according to claim 7, further comprising, after determining a memory leakage result corresponding to the set operation task based on the memory information set:
if the memory leakage exists in the set operation task, controlling the target equipment to periodically execute the plurality of subtasks respectively;
reading the memory information of the target equipment after the execution of the subtask is finished, and obtaining a subtask information set;
and determining a memory leakage result corresponding to the subtask based on the sub memory information set.
9. A memory leak detection apparatus, comprising:
the setting operation task execution module is used for controlling the target equipment to periodically execute the setting operation task; the set operation task is used for simulating the operation behavior of a user on the terminal;
the memory information reading module is used for reading the memory information of the target equipment after the execution of the set operation task is finished, and obtaining a memory information set;
the memory leakage result determining module is used for determining a memory leakage result corresponding to the set operation task based on the memory information set; wherein the memory leak result includes the existence of a memory leak or the absence of a memory leak.
10. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device to store one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method for detecting a memory leak of any one of claims 1-8.
11. A storage medium containing computer-executable instructions for performing the method of detecting a memory leak of any one of claims 1-8 when executed by a computer processor.
CN202211667119.5A 2022-12-22 2022-12-22 Memory leak detection method, device, equipment and storage medium Pending CN115952088A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211667119.5A CN115952088A (en) 2022-12-22 2022-12-22 Memory leak detection method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211667119.5A CN115952088A (en) 2022-12-22 2022-12-22 Memory leak detection method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115952088A true CN115952088A (en) 2023-04-11

Family

ID=87290723

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211667119.5A Pending CN115952088A (en) 2022-12-22 2022-12-22 Memory leak detection method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115952088A (en)

Similar Documents

Publication Publication Date Title
CN111372130B (en) User online time counting method and device, electronic equipment and storage medium
CN113395572A (en) Video processing method and device, storage medium and electronic equipment
CN108509348B (en) System aging test method and mobile terminal
CN110618928A (en) Memory leak detection method and device, terminal equipment and medium
CN111163336B (en) Video resource pushing method and device, electronic equipment and computer readable medium
CN111625456A (en) Stuck positioning method and device
CN110673986A (en) Memory operation abnormity capturing method, device, terminal and storage medium
CN110633434A (en) Page caching method and device, electronic equipment and storage medium
CN111949511A (en) Application program pause processing method and device, terminal and storage medium
CN111309496A (en) Method, system, device, equipment and storage medium for realizing delay task
CN111225255B (en) Target video push playing method and device, electronic equipment and storage medium
CN111949512A (en) Application program jamming detection method and device, terminal and medium
CN115952088A (en) Memory leak detection method, device, equipment and storage medium
CN111949528A (en) Memory leak detection method and device, electronic equipment and storage medium
CN113407344A (en) Method and device for processing stuck
CN112860439A (en) Application starting method and device, terminal and storage medium
CN113138883A (en) Message processing method and device, storage medium and electronic equipment
CN111538721A (en) Account processing method and device, electronic equipment and computer readable storage medium
CN110991312A (en) Method, apparatus, electronic device, and medium for generating detection information
CN112882857B (en) Performance problem positioning method, device, electronic equipment and storage medium
CN111259174B (en) Multimedia transmission method, device, electronic equipment and medium
CN117667247A (en) Preloading method, device, equipment and storage medium
CN115291982A (en) Page display method, device, equipment and storage medium
CN118331718A (en) Data analysis method, device, readable medium and electronic equipment
CN115080143A (en) Page resource preloading 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