CN109828859B - Mobile terminal memory analysis method and device, storage medium and electronic equipment - Google Patents

Mobile terminal memory analysis method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN109828859B
CN109828859B CN201910063223.5A CN201910063223A CN109828859B CN 109828859 B CN109828859 B CN 109828859B CN 201910063223 A CN201910063223 A CN 201910063223A CN 109828859 B CN109828859 B CN 109828859B
Authority
CN
China
Prior art keywords
memory
data
analyzed
memory data
file
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
CN201910063223.5A
Other languages
Chinese (zh)
Other versions
CN109828859A (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 CN201910063223.5A priority Critical patent/CN109828859B/en
Publication of CN109828859A publication Critical patent/CN109828859A/en
Application granted granted Critical
Publication of CN109828859B publication Critical patent/CN109828859B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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 invention relates to a method and a device for analyzing a memory of a mobile terminal, belonging to the technical field of computers, wherein the method comprises the following steps: acquiring memory data in program operation, and judging whether the data volume of the memory data reaches a preset threshold value or not; if the data volume of the memory data reaches the preset threshold value, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data; analyzing the memory file to be analyzed, and generating a memory analysis report according to the analysis result of the memory file to be analyzed; and sending the memory analysis report to a preset server. The method solves the problem of higher complexity of memory analysis caused by the problem that the memory needs to be reproduced in the prior art, reduces the complexity of the memory analysis and improves the speed of the memory analysis.

Description

Mobile terminal memory analysis method and device, storage medium and electronic equipment
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a mobile terminal memory analysis method, a mobile terminal memory analysis device, a computer readable storage medium and electronic equipment.
Background
In the live broadcast process, a live broadcast client always has a plurality of memory overflow problems in an external network; in order to solve the problem of memory overflow, the user log can be checked and the user operation can be performed again for analysis and solution. However, in most cases, the problem of memory overflow cannot be reproduced by carrying out the operation of the user again; moreover, since the memory overflow is only an error of obtaining a last memory application operation, but often the operation is only applied in the memory which is just about to overflow, developers cannot accurately know what the object occupying most of the memory is. Therefore, it is desirable to provide a method for accurately analyzing the memory problem when the memory overflow occurs.
The existing memory analysis method may include the following two methods: one is that, the HPROF Viewer of AS can check the utilization rate of the memory in real time under the Debug environment, what is the highest value of the memory used by a single object, and what is the corresponding stack; the MAT can analyze the class and the object which occupy the largest in the current memory of the Dump at this time; furthermore, the core logic of the two methods is to analyze the Hprof file from the memory dump.
However, both of the above methods have the following drawbacks: whether the HPROF VIEWER or MAT of the AS is used under the condition that a development environment exists or a developer exists, namely, the developer needs to reproduce the operation of the current user to obtain the current memory information in order to analyze the memory information, but the environment of the online users is very complex, and the same operation does not cause the memory problem; that is, the same operation makes it difficult for the developer to reproduce the memory problem, thereby increasing the complexity of the memory analysis.
Therefore, it is desirable to provide a new method and apparatus for analyzing a memory of a mobile terminal.
It is to be noted that the information invented in the above background section is only for enhancing the understanding of the background of the present invention, and therefore, may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The invention aims to provide a mobile terminal memory analysis method, a mobile terminal memory analysis device, a computer readable storage medium and an electronic device, thereby overcoming the problem of high complexity of memory analysis caused by the limitations and defects of the related technology at least to a certain extent.
According to an aspect of the present disclosure, a method for analyzing a memory of a mobile terminal is provided, including:
acquiring memory data in program operation, and judging whether the data volume of the memory data reaches a preset threshold value or not;
if the data volume of the memory data reaches the preset threshold value, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data;
analyzing the memory file to be analyzed, and generating a memory analysis report according to the analysis result of the memory file to be analyzed;
and sending the memory analysis report to a preset server.
In an exemplary embodiment of the present disclosure, acquiring memory information in a program running includes:
and acquiring memory data in the program operation by utilizing a Runtime function at intervals of a first preset time.
In an exemplary embodiment of the present disclosure, the determining whether the data amount of the memory data reaches a preset threshold includes:
calculating the data volume of the memory data;
judging whether the data volume of the memory data reaches a preset threshold value or not; the preset threshold value is determined according to the total memory amount allocated by the equipment terminal for the program operation;
if the data volume of the memory data reaches the preset threshold, judging whether the data volume of the memory data reaches the preset threshold again.
In an exemplary embodiment of the present disclosure, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data includes:
filtering the memory data through the Dump operation;
sorting the filtered memory data according to the size of the data object in the filtered memory data to obtain sorted memory data;
generating a memory file to be analyzed according to the sorted memory data;
the memory file to be analyzed is an Hprof file.
In an exemplary embodiment of the present disclosure, analyzing the memory file to be analyzed includes:
searching the interaction components, modules of the interaction components and bitmaps leaked from the memory file to be analyzed;
and analyzing the interactive component, the module of the interactive component and the leakage reason of the bitmap.
In an exemplary embodiment of the present disclosure, generating a memory analysis report according to an analysis result of the memory file to be analyzed includes:
generating a memory analysis report according to the interactive component, the module of the interactive component and the leakage reason of the bitmap;
the memory analysis report comprises one or more of the interactive component, the module of the interactive component, the memory size occupied by the bitmap, the image preview and the reference stack.
In an exemplary embodiment of the present disclosure, after determining whether the data amount of the memory data reaches a preset threshold, the method for analyzing the memory of the mobile terminal further includes:
and if the data volume of the memory data does not reach the preset threshold, acquiring the memory data in the program operation again at intervals of second preset time until the sum of the data volumes of the memory data acquired at each time reaches the preset threshold.
According to an aspect of the present disclosure, there is provided a mobile terminal memory analysis device, including:
the judging module is used for acquiring memory data in program operation and judging whether the data volume of the memory data reaches a preset threshold value or not;
the filtering module is used for filtering the memory data if the data volume of the memory data reaches the preset threshold value, and generating a memory file to be analyzed according to the filtered memory data;
the analysis module is used for analyzing the memory file to be analyzed and generating a memory analysis report according to the analysis result of the memory file to be analyzed;
and the analysis report sending module is used for sending the memory analysis report to a preset server.
According to an aspect of the present disclosure, there is provided a computer-readable storage medium having a computer program stored thereon, the computer program, when executed by a processor, implementing the method for analyzing the memory of the mobile terminal.
According to an aspect of the present disclosure, there is provided an electronic device including:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute any one of the above methods by executing the executable instructions.
The embodiment of the disclosure provides a method and a device for analyzing a memory of a mobile terminal, which are used for judging whether the data volume of memory data reaches a preset threshold value or not; when the data volume of the memory data reaches a preset threshold value, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data; finally, analyzing the memory file to be analyzed, and generating a memory analysis report according to the analysis result of the memory file to be analyzed; on one hand, when the data volume of the memory data reaches a preset threshold value, the memory data is filtered, and a memory file to be analyzed is generated according to the filtered memory data; the memory file to be analyzed is analyzed and an analysis report is generated, so that the problem that the complexity of memory analysis is high due to the fact that the memory problem needs to be reproduced in the prior art is solved, the complexity of memory analysis is reduced, and the speed of memory analysis is improved; on the other hand, the memory data are filtered, and the memory file to be analyzed is generated according to the filtered memory data, so that the redundant data quantity in the memory file to be analyzed is reduced, the analysis speed is increased, and the accuracy of an analysis result is improved; on the other hand, whether the data volume of the memory data reaches the preset threshold value is judged, and the memory data is filtered when the data volume of the memory data reaches the preset threshold value is judged, so that the problem of low accuracy of an analysis result caused by too little memory data is solved, and the accuracy of the analysis result is further improved.
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 accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 schematically shows a flow chart of a mobile terminal memory analysis method.
Fig. 2 schematically shows a flowchart of a method for determining whether the data amount of the memory data reaches a preset threshold.
Fig. 3 schematically shows a flowchart of a method for filtering the memory data and generating a memory file to be analyzed according to the filtered memory data.
Fig. 4 schematically shows a flow chart of a method for analyzing a memory file to be analyzed.
Fig. 5 schematically shows a block diagram of an apparatus for analyzing a memory of a mobile terminal.
Fig. 6 schematically illustrates an exemplary diagram of an electronic device for implementing the mobile terminal memory analysis method.
Fig. 7 schematically illustrates a computer-readable storage medium for implementing the mobile terminal memory analysis method.
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 examples 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 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 technical solutions have not been shown or described in detail to avoid obscuring aspects of the invention.
Furthermore, the drawings are merely schematic illustrations of the invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. 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 devices and/or microcontroller devices.
In the present exemplary embodiment, first, a method for analyzing a memory of a mobile terminal is provided, where the method may be executed on a mobile terminal, and the mobile terminal may be, for example, a mobile phone, a tablet computer, a PC, and the like, and may also be executed on other device terminals, for example, an all-in-one machine, and the like; of course, those skilled in the art may also operate the method of the present invention on other platforms as needed, and this is not particularly limited in this exemplary embodiment. Referring to fig. 1, the method for analyzing the memory of the mobile terminal may include the steps of:
step 110, obtaining memory data in program operation, and judging whether the data volume of the memory data reaches a preset threshold value.
Step S120, if the data volume of the memory data reaches the preset threshold value, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data.
Step S130, analyzing the memory file to be analyzed, and generating a memory analysis report according to the analysis result of the memory file to be analyzed.
And S140, sending the memory analysis report to a preset server.
In the mobile terminal memory analysis method, on one hand, when the data volume of the memory data is judged to reach the preset threshold value, the memory data is filtered, and a memory file to be analyzed is generated according to the filtered memory data; the memory file to be analyzed is analyzed and an analysis report is generated, so that the problem that the complexity of memory analysis is high due to the fact that the memory problem needs to be reproduced in the prior art is solved, the complexity of memory analysis is reduced, and the speed of memory analysis is improved; on the other hand, the memory data are filtered, and the memory file to be analyzed is generated according to the filtered memory data, so that the redundant data amount in the memory file to be analyzed is reduced, the analysis speed is increased, and the accuracy of an analysis result is improved; on the other hand, whether the data volume of the memory data reaches the preset threshold value is judged, and the memory data is filtered when the data volume of the memory data reaches the preset threshold value is judged, so that the problem of low accuracy of an analysis result caused by too little memory data is solved, and the accuracy of the analysis result is further improved.
Hereinafter, each step in the above-mentioned mobile terminal memory analysis method in the present exemplary embodiment will be explained and explained in detail with reference to the drawings.
In step S110, memory data in the program running process is obtained, and it is determined whether the data amount of the memory data reaches a preset threshold.
In this exemplary embodiment, first, memory data in program operation is acquired; the obtaining of the memory data in the program operation may include: and acquiring memory data in the program operation by utilizing a Runtime function at intervals of a first preset time. In detail:
firstly, configuring a Runtime function; wherein, the Runtime function, namely the Runtime function, is a dynamic shared library composed of a series of functions and data structures and having a common interface; therefore, the memory data in the program running can be acquired at the timing (at the first preset time interval) of the getRuntime () interface in the Runtime function. Further, after the memory data is acquired, whether the data volume of the memory data reaches a preset threshold value is judged.
In step S120, if the data amount of the memory data reaches the preset threshold, the memory data is filtered, and a memory file to be analyzed is generated according to the filtered memory data.
In this exemplary embodiment, when the data amount of the memory data reaches the preset threshold, the memory data may be filtered by repeatedly calling the public static void dual hprofdata () function, the byte data that is not needed and cannot be analyzed basically is deleted, and then the memory file to be analyzed is generated according to the filtered memory data. By using the method, the data volume of the memory file to be analyzed can be far less than that of the memory data, and the analysis speed can be further improved.
In step S130, the memory file to be analyzed is analyzed, and a memory analysis report is generated according to an analysis result of the memory file to be analyzed.
In this exemplary embodiment, first, the analysis memory file may be analyzed by the Hprof analysis tool; among other things, the Hprof analysis tools referred to in this disclosure may be custom Hprof analysis tools. Because the existing open Hprof analysis tools are manufactured based on a PC system and are not suitable for being used as an app third-party SDK toolkit, firstly, the used memory is too high, secondly, the used third-party jar package is too large, and is directly integrated with the app, the volume of the app is greatly increased, and the burden on a terminal is easily caused. The Hprof analysis tool related in the disclosure discards an original data packet with a large memory and changes the original data packet into a jar packet with a small memory, wherein the jar packet is suitable for terminal equipment; meanwhile, the read file Hprof is changed into streaming reading, so that the memory occupied in the analysis process is reduced; and secondly, generating a memory analysis report according to the analysis result of the memory file to be analyzed. The generating a memory analysis report according to the analysis result of the memory file to be analyzed may include: and generating a memory analysis report according to the interactive component, the module of the interactive component and the leakage reason of the bitmap. In detail:
leakage reasons of an interactive component (Activity), an interactive component module (Fragment) and a Bitmap (Bitmap) in the memory analysis result of the mobile terminal can be filled in the Html to generate a detailed memory analysis report; the memory analysis report may include the memory size occupied by the interactive components, the modules of the interactive components and the bitmaps, the image preview, the reference stack, and the like.
In step S140, the memory analysis report is sent to a preset server.
In this exemplary embodiment, after the memory analysis report is obtained, the memory analysis report is sent to a preset server, so that the preset server can perform vulnerability repair on the interactive component, the module of the interactive component, and the leakage reason of the bitmap in the mobile terminal according to the analysis report, so that the problem does not occur any more in the following. Further, the preset server may be a server of the device terminal, a cloud server or a server cluster, and the like.
Fig. 2 schematically shows a flowchart of a method for determining whether the data amount of the memory data reaches a preset threshold. Referring to fig. 2, determining whether the data amount of the memory data reaches the preset threshold may include steps S210 to S230. Wherein:
in step S210, the data amount of the memory data is calculated.
In step S220, determining whether the data amount of the memory data reaches a preset threshold; and determining the preset threshold according to the total memory amount allocated by the equipment terminal for the program operation.
In step S230, if the data amount of the memory data reaches the preset threshold, it is determined again whether the data amount of the memory data reaches the preset threshold.
Next, steps S210 to S230 will be explained and explained. Firstly, calculating the total data volume of memory data; then, judging whether the data volume of the memory data reaches a preset threshold value; the preset threshold value can be determined according to the total memory amount allocated by the equipment terminal for the program operation; for example, when the total amount of memory allocated for the program running by the device terminal is 512M, the preset threshold may be set as: 512m × 0.8=409m; other values may be set, and this example is not particularly limited thereto. It should be additionally noted that if the preset threshold is too large, the operation of the program may be affected, and a stuck condition may occur; if the preset threshold is too small, the final data volume of the memory file to be analyzed is too small, and the accuracy of the analysis result is low. Finally, after the data volume of the memory data is judged to reach the preset threshold, whether the data volume of the memory data reaches the preset threshold can be judged again; the memory data can be filtered only after the data volume of the memory data is judged to reach the preset threshold value twice or more. By using the method, the problem that the data quantity is too small due to data quantity fluctuation caused by unstable memory data is avoided.
Furthermore, in order to enable the data amount of the memory data to reach the preset threshold, the memory data analysis method may further include: and if the data volume of the memory data does not reach the preset threshold, acquiring the memory data in the program operation again at intervals of second preset time until the sum of the data volumes of the memory data acquired at each time reaches the preset threshold. For example:
for example, if the data amount of the memory data does not reach the preset threshold (for example, the data amount of the memory data is 300M), the memory data in the program running may be acquired again at intervals of a second preset time (for example, 3min or 5min, and the like, or at intervals of other time periods, which is not particularly limited in this example), and then the data amounts of the memory data acquired in the two previous and next times are combined until the total data amount reaches the preset threshold. It should be added that when the data amount of the memory data exceeds the preset threshold, the memory data may be divided into two parts for processing according to the size of the memory data or the time sequence generated by the memory data; further, if the data amount of the memory data is more than or less than the preset threshold value and does not exceed a certain specific value, calculation can be performed according to the fact that the data amount reaches the preset threshold value; for example, when the amount of data less than the preset threshold does not exceed 10% or the amount of data more than the preset threshold does not exceed 5%, the calculation may be performed in accordance with the amount of data reaching the preset threshold. In addition, other value range intervals may also be set, and this example does not specifically limit this.
Fig. 3 schematically shows a flowchart of a method for filtering the memory data and generating a memory file to be analyzed according to the filtered memory data. Referring to fig. 3, filtering the memory data and generating a memory file to be analyzed according to the filtered memory data may include steps S310 to S330. Wherein:
in step S310, the memory data is filtered through the Dump operation.
In the present exemplary embodiment, first, the Dump operation is customized; because the file obtained by the default used Dump method is the same as the size of the memory, if the threshold value of the memory is higher, a larger file exists, which is not beneficial to storage and analysis; therefore, the Dump of the android at the bottom layer can be called to realize the customized Dump operation through the native hook; then, the memory data is filtered by using the Dump operation, and useless byte data files occupying 80 percent of the size are removed, so that the storage analysis of the memory file to be analyzed becomes much easier and faster.
In step S320, the filtered memory data is sorted according to the size of the data object in the filtered memory data to obtain sorted memory data.
In this exemplary embodiment, the filtered memory data is sorted according to the size of each data object in the filtered memory data, and memory data sorted in sequence is obtained; the sequence may be performed in a positive order (from large to small), or may be performed in a reverse order (from small to large), which is not limited in this example.
In step S330, a memory file to be analyzed is generated according to the sorted memory data; wherein, the memory file to be analyzed is an Hprof file.
In this exemplary embodiment, the memory file to be analyzed in the Hprof format may be generated according to the sorted memory data.
Fig. 4 schematically shows a flowchart of a method for analyzing the memory file to be analyzed. Referring to fig. 4, analyzing the memory file to be analyzed may include steps S410 to S420. Wherein:
in step S410, searching for an interactive component, a module of the interactive component, and a bitmap that are leaked from the memory file to be analyzed;
in step S420, the interactive component, the modules of the interactive component, and the reason for leakage of the bitmap are analyzed.
Next, step S410 and step S420 will be explained and explained. Firstly, searching leaked interactive components, modules of the interactive components and bitmaps from the memory file to be analyzed; the memory data in the memory file to be analyzed is sorted according to the data size, so that the memory data can be sequentially searched according to the sequence; secondly, after the leaked interaction assemblies, the modules of the interaction assemblies and the bitmaps are found, the leaked interaction assemblies, the modules of the interaction assemblies and the leakage reasons of the bitmaps can be analyzed, and memory analysis reports are generated according to the leakage reasons obtained through analysis; and sending the memory analysis report to a server so that the server processes the leaked interactive components, modules of the interactive components and bitmaps according to the memory analysis report. By the method, when the memory occupation of the equipment terminal is too high, the equipment terminal can automatically start to analyze the memory information and send the memory information to the server in a summary report mode; when the server receives the summary report, developers do not need to reappear the operation of the users at that time, can directly take the memory distribution information in the memories of the users at that time, and give a call stack, so that the developers can conveniently and quickly find out problem codes.
The disclosure also provides a mobile terminal memory analysis device. Referring to fig. 5, the mobile terminal memory analysis apparatus may include a determination module 510, a filtering module 520, an analysis module 530, and an analysis report sending module 540. Wherein:
the determining module 510 may be configured to obtain memory data in program running, and determine whether a data amount of the memory data reaches a preset threshold.
The filtering module 520 may be configured to filter the memory data if the data amount of the memory data reaches the preset threshold, and generate a memory file to be analyzed according to the filtered memory data.
The analysis module 530 may be configured to analyze the memory file to be analyzed, and generate a memory analysis report according to an analysis result of the memory file to be analyzed.
The analysis report sending module 540 may be configured to send the memory analysis report to a preset server.
In an exemplary embodiment of the present disclosure, acquiring memory information in a program running includes:
and acquiring memory data in the program operation by using a Runtime function at intervals of a first preset time.
In an exemplary embodiment of the present disclosure, determining whether the data amount of the memory data reaches a preset threshold includes:
calculating the data volume of the memory data;
judging whether the data volume of the memory data reaches a preset threshold value or not; the preset threshold value is determined according to the total memory amount allocated by the equipment terminal for the program operation;
and if the data volume of the memory data reaches the preset threshold, judging whether the data volume of the memory data reaches the preset threshold again.
In an exemplary embodiment of the present disclosure, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data includes:
filtering the memory data through the Dump operation;
sorting the filtered memory data according to the size of the data object in the filtered memory data to obtain sorted memory data;
generating a memory file to be analyzed according to the sorted memory data; the memory file to be analyzed is an Hprof file.
In an exemplary embodiment of the present disclosure, analyzing the memory file to be analyzed includes:
searching the interaction components, modules of the interaction components and bitmaps leaked from the memory file to be analyzed;
and analyzing the interactive components, the modules of the interactive components and the leakage reasons of the bitmap.
In an exemplary embodiment of the present disclosure, generating a memory analysis report according to an analysis result of the memory file to be analyzed includes:
generating a memory analysis report according to the interactive component, the module of the interactive component and the leakage reason of the bitmap;
the memory analysis report comprises one or more of the interactive component, the module of the interactive component, the memory size occupied by the bitmap, the image preview and the reference stack.
In an exemplary embodiment of the present disclosure, the mobile terminal memory analysis apparatus further includes:
and the obtaining module is used for obtaining the memory data in the program running again at intervals of second preset time until the sum of the data amount of the memory data obtained each time reaches the preset threshold value if the data amount of the memory data does not reach the preset threshold value.
The specific details of each module in the mobile terminal memory analysis device have been described in detail in the corresponding mobile terminal memory analysis method, and therefore are not described herein again.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit according to an embodiment of the invention. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Moreover, although the steps of the methods of the present invention are depicted in the drawings in a particular order, this does not require or imply that the steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiment of the present invention.
In an exemplary embodiment of the present invention, there is also provided an electronic device capable of implementing the above method.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or program product. Accordingly, various aspects of the present invention may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.), or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 600 according to this embodiment of the invention is described below with reference to fig. 6. The electronic device 600 shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the electronic device 600 is in the form of a general purpose computing device. The components of the electronic device 600 may include, but are not limited to: the at least one processing unit 610, the at least one memory unit 620, and a bus 630 that couples the various system components including the memory unit 620 and the processing unit 610.
Wherein the storage unit stores program code that is executable by the processing unit 610 to cause the processing unit 610 to perform steps according to various exemplary embodiments of the present invention as described in the above section "exemplary methods" of the present specification. For example, the processing unit 610 may perform step S110 as shown in fig. 1: acquiring memory data in program operation, and judging whether the data volume of the memory data reaches a preset threshold value; step S120: if the data volume of the memory data reaches the preset threshold value, filtering the memory data, and generating a memory file to be analyzed according to the filtered memory data; step S130, analyzing the memory file to be analyzed, and generating a memory analysis report according to the analysis result of the memory file to be analyzed; step S140: and sending the memory analysis report to a preset server.
The storage unit 620 may include readable media in the form of volatile memory units, such as a random access memory unit (RAM) 6201 and/or a cache memory unit 6202, and may further include a read-only memory unit (ROM) 6203.
The memory unit 620 may also include programs/utilities 6204 having a set (at least one) of program modules 6205, such program modules 6205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 630 can be any bus representing one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 600, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 600 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interface 650. Also, the electronic device 600 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via the network adapter 660. As shown, the network adapter 660 communicates with the other modules of the electronic device 600 over the bus 630. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, and may also be implemented by software in combination with necessary hardware. Therefore, the technical solution according to the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to make a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) execute the method according to the embodiment of the present invention.
In an exemplary embodiment of the present invention, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above-described method of the present specification. In some possible embodiments, aspects of the invention may also be implemented in the form of a program product comprising program code means for causing a terminal device to carry out the steps according to various exemplary embodiments of the invention described in the above section "exemplary methods" of the present description, when said program product is run on the terminal device.
Referring to fig. 7, a program product 710 for implementing the above method according to an embodiment of the present invention is described, which may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited in this respect, and in this document, a 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.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A 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 (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, 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.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, 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 readable signal medium may also be any readable medium that is not a 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 readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like 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 computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In situations involving remote computing devices, the remote computing devices may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to external computing devices (e.g., through the internet using an internet service provider).
Furthermore, the above-described figures are merely schematic illustrations of processes involved in methods according to exemplary embodiments of the invention, and are not intended to be limiting. It will be readily appreciated that the processes illustrated in the above figures are not intended to indicate or limit the temporal order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

Claims (8)

1. A method for analyzing the memory of a mobile terminal is characterized by comprising the following steps:
acquiring memory data in program operation, and judging whether the data volume of the memory data reaches a preset threshold value;
if the data volume of the memory data reaches the preset threshold value, filtering the memory data through Dump operation, and removing useless byte data files in the memory data; sorting the filtered memory data according to the size of the data object in the filtered memory data to obtain sorted memory data; generating a memory file to be analyzed according to the sorted memory data; wherein, the memory file to be analyzed is an Hprof file;
searching the interaction components, modules of the interaction components and bitmaps leaked from the memory file to be analyzed; analyzing the interactive component, the module of the interactive component and the leakage reason of the bitmap, and generating a memory analysis report according to the analysis result of the memory file to be analyzed; wherein, in the process of reading the memory file to be analyzed, the reading is realized by stream reading; the memory analysis report comprises one or more of the interactive component, the module of the interactive component, the memory size occupied by the bitmap, the image preview and the reference stack;
and sending the memory analysis report to a preset server so that the server performs vulnerability repair on the interactive components, the modules of the interactive components and the leakage reasons of the bitmap in the mobile terminal according to the memory analysis report.
2. The method according to claim 1, wherein the obtaining of the memory information during program execution comprises:
and acquiring memory data in the program operation by using a Runtime function at intervals of a first preset time.
3. The method of claim 1, wherein determining whether the amount of the memory data reaches a predetermined threshold comprises:
calculating the data volume of the memory data;
judging whether the data volume of the memory data reaches a preset threshold value or not; the preset threshold value is determined according to the total memory amount allocated by the equipment terminal for the program operation;
if the data volume of the memory data reaches the preset threshold, judging whether the data volume of the memory data reaches the preset threshold again.
4. The method according to claim 1, wherein the generating a memory analysis report according to the analysis result of the memory file to be analyzed comprises:
and generating a memory analysis report according to the interactive component, the module of the interactive component and the leakage reason of the bitmap.
5. The method according to claim 1, wherein after determining whether the data size of the memory data reaches a preset threshold, the method further comprises:
and if the data volume of the memory data does not reach the preset threshold, acquiring the memory data in the program operation again at intervals of second preset time until the sum of the data volumes of the memory data acquired at each time reaches the preset threshold.
6. A mobile terminal memory analysis device is characterized by comprising:
the judging module is used for acquiring memory data in program operation and judging whether the data volume of the memory data reaches a preset threshold value or not;
the filtering module is used for filtering the memory data through the Dump operation to remove useless byte data files in the memory data if the data volume of the memory data reaches the preset threshold value; sorting the filtered memory data according to the size of the data object in the filtered memory data to obtain sorted memory data; generating a memory file to be analyzed according to the sorted memory data; wherein, the memory file to be analyzed is an Hprof file;
the analysis module is used for searching the interactive components, the modules of the interactive components and the bitmap which are leaked from the memory file to be analyzed; analyzing the interactive component, the module of the interactive component and the leakage reason of the bitmap, and generating a memory analysis report according to the analysis result of the memory file to be analyzed; wherein, in the process of reading the memory file to be analyzed, the reading is realized by stream reading; the memory analysis report comprises one or more of the interactive component, the module of the interactive component, the memory size occupied by the bitmap, the image preview and the reference stack;
and the analysis report sending module is used for sending the memory analysis report to a preset server so that the server performs vulnerability repair on the interactive component, the module of the interactive component and the leakage reason of the bitmap in the mobile terminal according to the memory analysis report.
7. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the mobile terminal memory analysis method of any one of claims 1 to 5.
8. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the mobile terminal memory analysis method of any one of claims 1-5 via execution of the executable instructions.
CN201910063223.5A 2019-01-23 2019-01-23 Mobile terminal memory analysis method and device, storage medium and electronic equipment Active CN109828859B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910063223.5A CN109828859B (en) 2019-01-23 2019-01-23 Mobile terminal memory analysis method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910063223.5A CN109828859B (en) 2019-01-23 2019-01-23 Mobile terminal memory analysis method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN109828859A CN109828859A (en) 2019-05-31
CN109828859B true CN109828859B (en) 2023-03-07

Family

ID=66861903

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910063223.5A Active CN109828859B (en) 2019-01-23 2019-01-23 Mobile terminal memory analysis method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN109828859B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457179A (en) * 2019-07-29 2019-11-15 Oppo广东移动通信有限公司 System detecting method, internal memory monitoring method, device, medium and electronic equipment
CN111694673B (en) * 2020-06-17 2023-05-16 抖音视界有限公司 Memory processing method, memory processing device, electronic equipment and computer readable storage medium
CN113094178A (en) * 2021-04-23 2021-07-09 北京字节跳动网络技术有限公司 Memory image file generation method and device, electronic equipment and storage medium
CN113468128B (en) * 2021-07-21 2023-02-17 上海浦东发展银行股份有限公司 Data processing method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20150002300A (en) * 2013-06-28 2015-01-07 부산대학교 산학협력단 Apparatus and Method for Detecting Memory Leak using Heap Analysis
CN106886476A (en) * 2017-02-08 2017-06-23 腾讯科技(深圳)有限公司 A kind of memory analysis method of client, apparatus and system
CN107632929A (en) * 2017-08-21 2018-01-26 北京京东尚科信息技术有限公司 A kind of method and apparatus for detecting memory overflow
CN107957941A (en) * 2016-10-17 2018-04-24 腾讯科技(深圳)有限公司 Mobile terminal memory overflow treating method and apparatus
CN109165202A (en) * 2018-07-04 2019-01-08 华南理工大学 A kind of preprocess method of multi-source heterogeneous big data

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20150002300A (en) * 2013-06-28 2015-01-07 부산대학교 산학협력단 Apparatus and Method for Detecting Memory Leak using Heap Analysis
CN107957941A (en) * 2016-10-17 2018-04-24 腾讯科技(深圳)有限公司 Mobile terminal memory overflow treating method and apparatus
CN106886476A (en) * 2017-02-08 2017-06-23 腾讯科技(深圳)有限公司 A kind of memory analysis method of client, apparatus and system
CN107632929A (en) * 2017-08-21 2018-01-26 北京京东尚科信息技术有限公司 A kind of method and apparatus for detecting memory overflow
CN109165202A (en) * 2018-07-04 2019-01-08 华南理工大学 A kind of preprocess method of multi-source heterogeneous big data

Also Published As

Publication number Publication date
CN109828859A (en) 2019-05-31

Similar Documents

Publication Publication Date Title
CN109828859B (en) Mobile terminal memory analysis method and device, storage medium and electronic equipment
CN109739478B (en) Front-end project automatic construction method and device, storage medium and electronic equipment
CN107506300B (en) User interface testing method, device, server and storage medium
CN107436844B (en) Method and device for generating interface use case aggregate
US11144437B2 (en) Pre-populating continuous delivery test cases
CN111611145B (en) Breakdown information collection method and device, storage medium and electronic equipment
CN110955640A (en) Cross-system data file processing method, device, server and storage medium
CN112395098B (en) Application program interface calling method and device, storage medium and electronic equipment
CN111352957A (en) Remote dictionary service optimization method and related equipment
CN112199261A (en) Application program performance analysis method and device and electronic equipment
CN110955438A (en) Method, device and equipment for monitoring performance of small program and storage medium
CN110795353A (en) Debugging method, device and equipment for fast application and storage medium
CN108595178B (en) Hook-based data acquisition method, device and equipment
CN109684207B (en) Method and device for packaging operation sequence, electronic equipment and storage medium
CN108965295B (en) File compression and combination method and related device
CN110716859A (en) Method for automatically pushing test cases for modified codes and related device
CN112463574A (en) Software testing method, device, system, equipment and storage medium
CN113918444A (en) Method, device, medium and electronic equipment for positioning collapse source code
CN113377376A (en) Data packet generation method, data packet generation device, electronic device, and storage medium
CN113419957A (en) Rule-based big data offline batch processing performance capacity scanning method and device
CN114116418A (en) Information processing method and device, computer storage medium and electronic equipment
CN111949549A (en) Test request screening method, system, electronic device and storage medium
CN114338846A (en) Message testing method and device
CN111176718A (en) Script online method and device, storage medium and electronic equipment
CN110704222A (en) Dump file analysis method and device, storage medium and electronic equipment

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