CN107145447B - Method and device for detecting memory leakage and electronic equipment - Google Patents

Method and device for detecting memory leakage and electronic equipment Download PDF

Info

Publication number
CN107145447B
CN107145447B CN201710321657.1A CN201710321657A CN107145447B CN 107145447 B CN107145447 B CN 107145447B CN 201710321657 A CN201710321657 A CN 201710321657A CN 107145447 B CN107145447 B CN 107145447B
Authority
CN
China
Prior art keywords
user interface
memory
client
tested
request
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.)
Active
Application number
CN201710321657.1A
Other languages
Chinese (zh)
Other versions
CN107145447A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201710321657.1A priority Critical patent/CN107145447B/en
Publication of CN107145447A publication Critical patent/CN107145447A/en
Application granted granted Critical
Publication of CN107145447B publication Critical patent/CN107145447B/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/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a method, a device and an electronic device for detecting memory leakage, wherein the method comprises the following steps: acquiring an identifier of a user interface to be tested; circularly sending a request for simulating a player to open and close the user interface to a client of the tested software according to the identification so as to enable the client to execute the operation of opening and closing the user interface; acquiring memory snapshots of the client when the user interface is opened and closed each time; and evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot. The technical scheme of the application can quickly detect whether the memory leakage problem exists in the user interface in the software.

Description

Method and device for detecting memory leakage and electronic equipment
Technical Field
The present disclosure relates to the field of software testing technologies, and in particular, to a method and an apparatus for detecting memory leakage, and an electronic device.
Background
A memory leak is a failure of a program to release memory that is no longer used due to an error or negligence in the program. Memory leaks can reduce the performance of a computer by reducing the amount of available memory. Eventually, in the worst case, too much available memory is allocated causing all or part of the device to stop working properly, or the application to crash.
In some software, there may be many user interfaces, and since the user interfaces usually load some graphics and special effects, when the code of the program is written out of specification, memory leakage is easy to occur. For example, in a large mobile phone game, there are usually many user interfaces, and the player frequently opens and closes the user interfaces during the game playing process. When the time of playing the game is long and the interface is opened and closed frequently, the total amount of the leaked memory is increased, so that the game has the risk of flash back due to insufficient memory.
The current common mode for detecting the memory leakage is to obtain the utilization information of the memory by observing the change curve of the memory when the game runs, and when the memory utilization curve is continuously increased, the problem of the memory leakage in the game can be considered. For example, the memory footprint curve in fig. 1 is a significant memory leakage problem.
However, this method is very inefficient and inconvenient, for example, hundreds of user interfaces are usually available in a game, when there are many user interfaces, the manual detection method is time-consuming and labor-consuming, and many user interfaces are hidden deeply, and test omission is easy to occur.
Disclosure of Invention
The application discloses a method for detecting memory leakage, which is used for quickly detecting whether a memory leakage problem exists in a user interface in software.
Additional features and advantages of the invention will be set forth in the detailed description which follows, or may be learned by practice of the invention.
According to a first aspect of the present invention, there is provided a method for detecting a memory leak, comprising:
acquiring an identifier of a user interface to be tested;
circularly sending a request for simulating a player to open and close the user interface to a client of the tested software according to the identification so as to enable the client to execute the operation of opening and closing the user interface;
acquiring memory snapshots of the client when the user interface is opened and closed each time;
and evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot.
According to some embodiments, cyclically sending a request to a client of the software under test to simulate a player opening and closing the user interface based on the identification comprises: and circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification through the script code.
According to some embodiments, cyclically sending a request to a client of the software under test to simulate a player opening and closing the user interface based on the identification comprises: and circularly sending a remote procedure call request for simulating the opening and closing of the user interface by a player to the client of the software to be tested according to the identification.
According to some embodiments, circularly sending a remote procedure call request for simulating a player to open and close the user interface to a client of the software under test according to the identification comprises: and circularly sending a remote procedure call request for simulating a player to open and close the user interface to the client of the tested software according to the identification by using the websocket or the socket.
According to some embodiments, the identification of the user interface comprises a name of the user interface and a reference path of the user interface.
According to some embodiments, evaluating whether the user interface has a memory leak according to the difference in the amount of memory in the memory snapshot includes:
and counting the difference of the memory quantity on the memory snapshot, and evaluating whether the memory of the user interface is leaked according to the counting result.
According to some embodiments, before obtaining the identifier of the user interface to be tested, the method further includes: and traversing the user interface of the software to be tested, and taking the user interface obtained by traversing as the user interface to be tested in sequence.
According to a second aspect of the present invention, there is provided an apparatus for detecting memory leak, comprising:
the identification acquisition unit is used for acquiring an identification of the user interface to be detected;
the simulation request unit is used for circularly sending a request for simulating a player to open and close the user interface to a client of the software to be tested according to the identification so as to enable the client to execute the operation of opening and closing the user interface;
the memory snapshot obtaining unit is used for obtaining a memory snapshot when the client opens and closes the user interface each time;
and the leakage evaluation unit is used for evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot.
According to some embodiments, the emulation request unit is to: and circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification through the script code.
According to some embodiments, the emulation request unit is to: and circularly sending a remote procedure call request for simulating the opening and closing of the user interface by a player to the client of the software to be tested according to the identification.
According to some embodiments, the emulation request unit is to: and circularly sending a remote procedure call request for simulating a player to open and close the user interface to the client of the tested software according to the identification by using the websocket or the socket.
According to some embodiments, the identification of the user interface comprises a name of the user interface and a reference path of the user interface.
According to some embodiments, the leak assessment unit is to:
and counting the difference of the memory quantity on the memory snapshot, and evaluating whether the memory of the user interface is leaked according to the counting result.
According to some embodiments, the device further includes a traversing unit, configured to traverse the user interface of the software to be tested before acquiring the identifier of the user interface to be tested, and sequentially use the user interface obtained through traversal as the user interface to be tested.
According to a third aspect of the present invention, there is provided an electronic apparatus comprising: a processor; a memory storing instructions for the processor to control the operation as described in the first aspect.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
firstly, when the memory curve continuously rises, only the problem of memory leakage can be known, but the memory leakage can not be located where the memory leakage occurs; secondly, generally, each UI occupies relatively little memory, which is about several hundred K, and it is not obvious to independently check whether there is memory leakage in a certain user interface, and it is usually necessary to open and close many times before the obvious memory change can be seen; in addition, there are typically hundreds of user interfaces in a game, which is time consuming and laborious and prone to test omissions if automated methods cannot be used.
According to the technical scheme provided by the embodiment, the request for simulating the opening and closing of the user interface by a player is circularly sent to the client side of the software to be tested according to the identification of the user interface to be tested, so that the memory snapshot is obtained after the client side performs the operation of opening and closing the user interface, whether the memory of the user interface is leaked or not is evaluated according to the difference of the memory quantity of the memory snapshot, the user interface with the memory leakage can be accurately positioned, the testing efficiency of the memory leakage can be improved, and the test omission can be avoided.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Drawings
The above and other features and advantages of the present invention will become more apparent by describing in detail exemplary embodiments thereof with reference to the attached drawings.
FIG. 1 is a diagram illustrating a memory footprint curve when a memory leak problem exists;
FIG. 2 illustrates a method of detecting memory leaks according to an embodiment of the invention;
FIG. 3 illustrates a method of detecting a memory leak according to another embodiment of the invention;
FIG. 4 is a block diagram illustrating an architecture for detecting memory leaks according to another embodiment of the present invention;
FIG. 5 is a block diagram illustrating an apparatus for detecting a memory leak according to another embodiment of the present invention;
fig. 6 shows an electronic device according to an embodiment of the invention.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The same reference numerals denote the same or similar parts in the drawings, and thus, a repetitive description thereof will be omitted.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to provide a thorough understanding of embodiments of the invention. One skilled in the relevant art will recognize, however, that the invention may be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations or operations have not been shown or described in detail to avoid obscuring aspects of the invention.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
Fig. 2 illustrates a method for detecting a memory leak according to an embodiment of the present invention, which is applicable to a case of detecting whether a memory leak exists in a user interface in software including the user interface, and as shown in fig. 2, the method for detecting a memory leak according to the embodiment includes:
in step S210, an identifier of the user interface to be tested is obtained.
The identifier of the user interface is used for distinguishing the user interface to be tested in the software to be tested, and may be, for example, a name of the user interface or a reference path of the user interface.
In step S220, a request for simulating a player to open and close the user interface is sent to the client of the software under test in a loop according to the identifier, so that the client performs an operation of opening and closing the user interface.
And circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification, wherein the request can be realized by a specific script code.
The request may be a remote procedure call request, for example, communication of the remote procedure call may be accomplished using a websocket or socket.
It should be noted that the user interface to be tested in step S210 refers to the user interface from the software to be tested in this step. According to the method of the embodiment, part or all of the user interfaces in the software to be tested can be respectively used as the user interfaces to be tested one by one.
In step S230, a memory snapshot when the client opens and closes the user interface each time is obtained.
In step S240, whether the memory of the user interface is leaked is evaluated according to the difference between the memory amounts in the memory snapshots.
For example, the difference of the memory quantity on the memory snapshot may be counted, and whether the memory of the user interface is leaked is evaluated according to the statistical result.
It should be noted that the identification of the user interface to be tested can be obtained by traversing the user interface of the software to be tested, and the user interfaces obtained by traversing are sequentially used as the user interface to be tested.
According to the technical scheme provided by the embodiment, the request for simulating the opening and closing of the user interface by a player is circularly sent to the client side of the software to be tested according to the identification of the user interface to be tested, so that the memory snapshot is obtained after the client side performs the operation of opening and closing the user interface, whether the memory of the user interface is leaked or not is evaluated according to the difference of the memory quantity of the memory snapshot, the user interface with the memory leakage can be accurately positioned, the testing efficiency of the memory leakage can be improved, and the test omission can be avoided.
Fig. 3 shows a method for detecting a memory leak according to another embodiment of the present invention, and as shown in fig. 3, the method for detecting a memory leak according to this embodiment includes:
in step S310, traversing the user interface of the software under test, and sequentially using the user interface obtained through traversal as the user interface under test.
For example, all user interfaces within the game are traversed, resulting in names and reference paths for all user interfaces. For example, names or reference paths of all user interfaces in the game are acquired from the game item, so that the next circulation of all the user interfaces is performed to simulate the operation of opening and closing the user interfaces by a player. Since different items organize the user interfaces differently, there is no general technical solution for this step, such as the way all user interfaces can be exported as the following key-value pairs to facilitate access by external scripts, where "key" is the name of a user interface and "value" is the reference path of the user interface in the game:
LOGIN="login.login.Login"
LOGIN_WINDOWS="login.login_windows.LoginWINDOWS"
LOGIN_GONGGAO="login.gonggao.GonggaoLogin"
GONGGAO="login.gonggao.Gonggao"
JOYSTICK="dungeon.player_joystick.PlayerJoyStick"
PC_SKILL_PANEL="skills.skill_panel_pc.SkillPanelPC"
SKILL_PANEL="skills.skill_panel_new.SkillPanel"
JUMP_PANEL="jump_panel.jump_panel.JumpPanel"
in step S320, an identifier of the user interface to be tested is obtained.
In step S330, a request for simulating a player to open and close the user interface is sent to the client of the software under test in a loop according to the identifier, so that the client performs an operation of opening and closing the user interface.
Writing a test script, traversing all the obtained user interface names, circularly sending Remote Procedure Call (RPC) requests to the game client, and simulating the operation of opening and closing the game user interface by a player. And after receiving the request, the game client acquires the reference path of the corresponding user interface through the name, and performs the operation of opening and closing the user interface.
For example, an external script is written, all the derived user interfaces are circularly traversed, and an operation instruction for opening and closing the user interfaces is sent to the game client so as to simulate the operation of opening and closing the user interfaces by a player.
The difficulty of directly sending the instruction to the game client is high, for example, the communication format, the encryption mode and the like of the game client need to be known. Therefore, the RPC request is received by embedding the RPC client in the game client, dependence on the communication protocol and encryption of the game is avoided, and the request is sent to the RPC client through the RPC server. The implementation modes of the RPC server and the RPC client are not particularly limited, communication can be achieved by directly using a socket, communication can also be achieved by using a websocket, the RPC communication is achieved by using the websocket when the RPC server and the RPC client are achieved, and core Python codes of related implementation are as follows:
Figure BDA0001289969400000071
in the game client, a client embedded with an RPC receives the sent instruction, and starts the actual user interface opening and closing operation in the game, and the core Python code is as follows:
Figure BDA0001289969400000072
Figure BDA0001289969400000081
through the steps, the operation of automatically opening and closing the user interface can be realized, and then the objgraph is needed to be used for judging whether the memory leakage exists in the user interface after the user interface is opened and closed for many times. In an implementation manner, each time the user interface is closed, the object graph.typestats () function needs to be used to obtain the state of the current memory object, that is, the memory snapshot, so that the logic for closing the user interface in the game needs to be modified, and the core code is as follows:
Figure BDA0001289969400000091
in step S340, a memory snapshot when the client opens and closes the user interface each time is obtained.
In a user interface manager of a game client, collecting memory use data by using an obj graph, specifically:
a) and calling a gc () function once when the user interface is opened and closed, wherein the gc function clears unused memory objects. Then, an obj graph.typestats () function is called, which collects object data that is not cleaned up by the GC, and the obtained result can be regarded as a memory snapshot after the current operation (the operation of opening and closing the user interface).
b) By opening and closing the user interface for multiple times, memory snapshot data under each operation can be obtained. And calculating the difference of the Python object between every two memory snapshots by comparison, and when the difference is greater than 0, indicating that the memory leak exists.
In step S350, whether the memory of the user interface is leaked is evaluated according to the difference between the memory amounts in the memory snapshots, and the process returns to step S320.
For example, each user interface may be opened and closed 5 times, and the average value may be used as an assessment of memory leak severity.
After the user interfaces are opened and closed, whether memory leakage occurs in each user interface or not can be counted by counting the difference of the memory quantity in the memory snapshot, and the result is written into a temporary file. By combining the steps 1, 2 and 3, the automatic detection of the memory leakage of the user interface in the game is realized, and a test report is generated. Such as the sample test results where the left string indicates the path on which the user interface is opened and closed and the following number indicates the amount of memory that is leaked. Because the memory recovery will have a certain time delay, the number of partially leaked memories is still larger than 0, and thus the memory needs to be tested (opened and closed) for many times to check the average condition. For example, once the average value of the leaked memory amount exceeds two digits, that is, the average value is between 10 and 20, a program is started to check, but this case cannot be completely determined as a memory leakage problem, and only when the average value of the memory leakage amounts tested for many times is 20 times larger, the memory leakage is determined. The threshold value of the average value can be set to 10, which can be specifically set according to requirements, and the disclosure is not limited thereto, and is less than 10, i.e. negligible, and more than 10, further detection is needed.
For example, the following sample test results indicate that there is no memory leak condition at the interface:
set(['action.action_panel.ActionFloat'])0
set(['action.action_panel.ActionFloat'])0
set(['action.action_panel.ActionFloat'])4
set(['action.action_panel.ActionFloat'])0
set(['task.all_tasks_panel.AllTaskPanel'])1
set(['task.all_tasks_panel.AllTaskPanel'])4
set(['task.all_tasks_panel.AllTaskPanel'])0
set(['task.all_tasks_panel.AllTaskPanel'])0
for another example, the following sample test result indicates that the interface has a memory leak condition, and needs to be checked and repaired.
set(['equip.equip_dazao.EquipDaZao'])529
set(['equip.equip_dazao.EquipDaZao'])536
set(['equip.equip_dazao.EquipDaZao'])537
set(['equip.equip_dazao.EquipDaZao'])530
set(['bag.auto_food_setting.AutoFoodSetting'])692
set(['bag.auto_food_setting.AutoFoodSetting'])692
set(['bag.auto_food_setting.AutoFoodSetting'])689
set(['bag.auto_food_setting.AutoFoodSetting'])692
The technical scheme of the embodiment can accurately position the user interface with the memory leakage, improve the testing efficiency of the memory leakage and avoid the test omission.
Fig. 5 is a block diagram illustrating an apparatus for detecting a memory leak according to an embodiment of the present invention, and as shown in fig. 5, the apparatus for detecting a memory leak according to the embodiment includes an identifier obtaining unit 510, a simulation requesting unit 520, a memory snapshot obtaining unit 530, and a leak evaluating unit 540.
The identifier acquiring unit 510 is configured to acquire an identifier of a user interface to be tested;
the simulation request unit 520 is configured to send a request for simulating a player to open and close the user interface to a client of the software under test according to the identification, so that the client performs an operation of opening and closing the user interface;
the memory snapshot obtaining unit 530 is configured to obtain a memory snapshot when the client opens and closes the user interface each time;
the leak evaluation unit 540 is configured to evaluate whether the user interface has a memory leak according to the difference of the memory amount in the memory snapshot.
According to some embodiments, the emulation request unit 520 is configured to: and circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification through the script code.
According to some embodiments, the emulation request unit 520 is configured to: and circularly sending a remote procedure call request for simulating the opening and closing of the user interface by a player to the client of the software to be tested according to the identification.
According to some embodiments, the emulation request unit 520 is configured to: and circularly sending a remote procedure call request for simulating a player to open and close the user interface to the client of the tested software according to the identification by using the websocket or the socket.
According to some embodiments, the identification of the user interface comprises a name of the user interface and a reference path of the user interface.
According to some embodiments, the leak assessment unit 540 is configured to:
and counting the difference of the memory quantity on the memory snapshot, and evaluating whether the memory of the user interface is leaked according to the counting result.
According to some embodiments, the apparatus further includes a traversing unit (not shown in fig. 5), configured to traverse the user interface of the software under test before acquiring the identifier of the user interface to be tested, and sequentially use the user interface obtained through traversal as the user interface to be tested.
With regard to the apparatus in the above-described embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment related to the method, and will not be described in detail here.
The apparatus for detecting memory leakage provided by this embodiment can execute the method for detecting memory leakage provided by the method embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 6 illustrates an electronic device according to an embodiment of the invention, and as shown in fig. 6, the electronic device 600 may include a processor 610, a memory 620, a transmitter 630, and a receiver 640.
The memory 620 may store instructions for the processor 610 to control the processing of operations. The memory 620 may include volatile or nonvolatile memory, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), and the like, which is not limited in this respect.
The processor 610 may call instructions stored in the memory 620 to control related operations. According to an embodiment, the memory 620 stores instructions for the processor 610 to control:
acquiring an identifier of a user interface to be tested;
circularly sending a request for simulating a player to open and close the user interface to a client of the tested software according to the identification so as to enable the client to execute the operation of opening and closing the user interface;
acquiring memory snapshots of the client when the user interface is opened and closed each time;
and evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot.
It will be readily appreciated that the memory 620 may also store instructions for the processor 610 to control other operations according to embodiments of the present invention, which will not be described in detail herein.
The processor 610 may also control the transmitter 630 and the receiver 640 to transceive signals, etc.
Those skilled in the art will readily appreciate from the foregoing detailed description that the systems and methods according to embodiments of the present invention have one or more of the following advantages.
According to an embodiment of the present invention, circularly sending a request for simulating a player to open and close the user interface to a client of the software under test according to the identification comprises: and circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification through the script code.
According to some embodiments of the invention, circularly sending a request for simulating a player to open and close the user interface to a client of the software under test according to the identification comprises: and circularly sending a remote procedure call request for simulating the opening and closing of the user interface by a player to the client of the software to be tested according to the identification.
The present invention also provides, according to some embodiments, a non-transitory computer-readable storage medium, such as a memory, including instructions executable by a processor of an apparatus to perform the above-described method. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like. The instructions in the storage medium, when executed by a processor of the terminal, enable the terminal to perform the method of: acquiring an identifier of a user interface to be tested; circularly sending a request for simulating a player to open and close the user interface to a client of the tested software according to the identification so as to enable the client to execute the operation of opening and closing the user interface; acquiring memory snapshots of the client when the user interface is opened and closed each time; and evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot.
It will be appreciated by those skilled in the art that the drawings are merely schematic representations of exemplary embodiments, and that the blocks or flow charts in the drawings are not necessarily required to practice the present invention and are, therefore, not intended to limit the scope of the present invention.
Those skilled in the art will appreciate that the modules described above may be distributed in the apparatus according to the description of the embodiments, or may be modified accordingly in one or more apparatuses unique from the embodiments. The modules of the above embodiments may be combined into one module, or further split into multiple sub-modules.
Exemplary embodiments of the present invention are specifically illustrated and described above. It is to be understood that the invention is not to be limited to the disclosed embodiments, but on the contrary, is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (9)

1. A method for detecting a memory leak, comprising:
traversing the user interface of the tested software, and taking the user interface obtained by traversing as the user interface to be tested in sequence;
acquiring the identifier of the user interface to be tested;
circularly sending a request for simulating a player to open and close the user interface to a client of the tested software according to the identification so as to enable the client to execute the operation of opening and closing the user interface; embedding an RPC client in the client to realize the reception of the RPC request;
acquiring memory snapshots of the client when the user interface is opened and closed each time;
and evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot.
2. The method of claim 1, wherein cyclically sending a request to a client of software under test to simulate a player opening and closing the user interface based on the identification comprises: and circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification through the script code.
3. The method of claim 1, wherein cyclically sending a request to a client of software under test to simulate a player opening and closing the user interface based on the identification comprises: and circularly sending a remote procedure call request for simulating the opening and closing of the user interface by a player to the client of the software to be tested according to the identification.
4. The method of claim 3, wherein cyclically sending a remote procedure call request to a client of the software under test for simulating a player opening and closing the user interface based on the identification comprises: and circularly sending a remote procedure call request for simulating a player to open and close the user interface to the client of the tested software according to the identification by using the websocket or the socket.
5. The method of claim 1, wherein the identification of the user interface comprises a name of the user interface and a reference path of the user interface.
6. The method of claim 1, wherein evaluating whether the user interface is memory-compromised based on a difference in the amount of memory on the memory snapshots comprises:
and counting the difference of the memory quantity on the memory snapshot, and evaluating whether the memory of the user interface is leaked according to the counting result.
7. An apparatus for detecting memory leaks, comprising:
the user interface traversing unit is used for traversing the user interfaces of the tested software and taking the user interfaces obtained through traversal as the user interfaces to be tested in sequence;
the identification obtaining unit is used for obtaining the identification of the user interface to be detected;
the simulation request unit is used for circularly sending a request for simulating a player to open and close the user interface to a client of the software to be tested according to the identification so as to enable the client to execute the operation of opening and closing the user interface; embedding an RPC client in the client to realize the reception of the RPC request;
the memory snapshot obtaining unit is used for obtaining a memory snapshot when the client opens and closes the user interface each time;
and the leakage evaluation unit is used for evaluating whether the memory of the user interface is leaked according to the difference of the memory quantity on the memory snapshot.
8. The apparatus of claim 7, wherein the emulation request unit is to: and circularly sending a request for simulating a player to open and close the user interface to the client of the software to be tested according to the identification through the script code.
9. An electronic device, comprising: a processor; a memory storing instructions for the processor to control the operations of any of claims 1-6.
CN201710321657.1A 2017-05-09 2017-05-09 Method and device for detecting memory leakage and electronic equipment Active CN107145447B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710321657.1A CN107145447B (en) 2017-05-09 2017-05-09 Method and device for detecting memory leakage and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710321657.1A CN107145447B (en) 2017-05-09 2017-05-09 Method and device for detecting memory leakage and electronic equipment

Publications (2)

Publication Number Publication Date
CN107145447A CN107145447A (en) 2017-09-08
CN107145447B true CN107145447B (en) 2020-07-07

Family

ID=59777091

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710321657.1A Active CN107145447B (en) 2017-05-09 2017-05-09 Method and device for detecting memory leakage and electronic equipment

Country Status (1)

Country Link
CN (1) CN107145447B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108984295B (en) * 2018-06-19 2020-08-07 珠海全志科技股份有限公司 Memory recovery method, computer device and computer readable storage medium
CN109977018B (en) * 2019-03-29 2023-11-14 努比亚技术有限公司 hprof file grabbing method and device, mobile terminal and readable storage medium
CN112463626B (en) * 2020-12-10 2023-07-11 网易(杭州)网络有限公司 Memory leakage positioning method and device, computer equipment and storage medium
CN112685305B (en) * 2020-12-30 2024-02-09 抖音视界有限公司 User interface performance test method and device, electronic equipment and readable storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105260294A (en) * 2015-11-16 2016-01-20 曙光信息产业(北京)有限公司 Monitoring method and device for memory occupied by application program
CN106610892A (en) * 2015-10-23 2017-05-03 腾讯科技(深圳)有限公司 Memory leak detecting method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7793161B2 (en) * 2007-05-29 2010-09-07 International Business Machines Corporation Method and apparatus to anticipate memory exhaustion in an open services gateway initiative environment
CN105653451A (en) * 2015-12-29 2016-06-08 北京金山安全软件有限公司 Software performance testing method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106610892A (en) * 2015-10-23 2017-05-03 腾讯科技(深圳)有限公司 Memory leak detecting method and device
CN105260294A (en) * 2015-11-16 2016-01-20 曙光信息产业(北京)有限公司 Monitoring method and device for memory occupied by application program

Also Published As

Publication number Publication date
CN107145447A (en) 2017-09-08

Similar Documents

Publication Publication Date Title
CN107145447B (en) Method and device for detecting memory leakage and electronic equipment
CN108491321B (en) Method and device for determining test case range and storage medium
CN111897724B (en) Automatic testing method and device suitable for cloud platform
CN110730107A (en) Test data generation method and device, computer equipment and storage medium
CN107329894B (en) Application program system testing method and device and electronic equipment
CN110474900B (en) Game protocol testing method and device
CN112035314B (en) Memory leakage monitoring method and device and electronic equipment
CN105787364A (en) Automated testing method, device and system for task
CN107423176B (en) Memory test method, control terminal, server and system
CN110806965A (en) Automatic test method, device, equipment and medium
CN112069068A (en) Automatic test data processing method, device, equipment and readable storage medium
CN109408309B (en) Multi-terminal testing method and device
CN111124911A (en) Automatic testing method, device, equipment and readable storage medium
CN108958890A (en) Container microscope testing method, apparatus and electronic equipment
CN105323748B (en) Test error uploading method and device
CN111984527A (en) Software performance testing method, device, equipment and medium
CN111352829A (en) Memory leak test method, device and equipment
CN107102938B (en) Test script updating method and device
CN115718692A (en) Solid state disk evaluation method and device based on firmware simulation and readable storage medium
CN108959931B (en) Vulnerability detection method and device, information interaction method and equipment
CN115373929A (en) Test method, device, equipment, readable storage medium and program product
CN104021083A (en) Test method and device
CN110442370B (en) Test case query method and device
CN113434364A (en) Screen-side equipment memory detection method and device, storage medium and electronic device
CN112685305B (en) User interface performance test method and device, electronic equipment and readable storage medium

Legal Events

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