CN113094178A - Memory image file generation method and device, electronic equipment and storage medium - Google Patents

Memory image file generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113094178A
CN113094178A CN202110444005.3A CN202110444005A CN113094178A CN 113094178 A CN113094178 A CN 113094178A CN 202110444005 A CN202110444005 A CN 202110444005A CN 113094178 A CN113094178 A CN 113094178A
Authority
CN
China
Prior art keywords
memory
target process
data
target
image 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.)
Pending
Application number
CN202110444005.3A
Other languages
Chinese (zh)
Inventor
詹云桥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202110444005.3A priority Critical patent/CN113094178A/en
Publication of CN113094178A publication Critical patent/CN113094178A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache

Landscapes

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

Abstract

The embodiment of the disclosure discloses a method and a device for generating a memory mirror image file, electronic equipment and a storage medium, wherein the method comprises the following steps: when the state value of a target process of a target application is updated, reading the occupied memory of the target process; and if the occupied memory is larger than the memory threshold, generating a memory image file of the target process according to preset memory image logic. According to the technical scheme of the embodiment of the invention, the memory mirror image can be generated according to the self-defined memory mirror image logic so as to realize memory optimization analysis, further cutting of the mirror image file is avoided, the load of a server is reduced, the success rate of the memory mirror image is improved, and further the real-time performance, the accuracy and the stability of memory monitoring are improved.

Description

Memory image file generation method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the internet technology, and in particular, to a method and an apparatus for generating a memory image file, an electronic device, and a storage medium.
Background
The memory is the most important high-speed storage resource in the computer, the important data and the running data of all running programs are stored in the memory, and once the memory is used up or the needed memory program cannot be reallocated, an error occurs, which directly causes the running program to crash or exit, and affects the normal running of the service. Therefore, the memory usage directly affects the performance and continuous operation of the computer program, and the memory status needs to be monitored in real time to realize the optimized analysis of the system memory.
Memory optimization analysis is usually achieved by monitoring the memory of the client and generating a memory mirror image to upload to the server. However, once the memory value of the client is high, the generated image file needs to be further cut to relieve the pressure of uploading to the server, otherwise, the problems that the system is overloaded, the memory is used up and the memory image cannot be generated, or the application program does not respond may be caused.
Disclosure of Invention
The invention provides a memory mirror image file generation method and device, electronic equipment and a storage medium, which can generate a memory mirror image according to a custom memory mirror image logic to realize memory optimization analysis, avoid further cutting of the mirror image file, reduce the load of a server, improve the success rate of the memory mirror image, further improve the real-time performance, accuracy and stability of memory monitoring, simultaneously acquire the memory information of a client in a passive receiving mode, and avoid resource waste or insufficient precision caused by active polling.
In a first aspect, an embodiment of the present disclosure provides a method for generating a memory image file, including:
when the state value of a target process of a target application is updated, reading the occupied memory of the target process;
and if the occupied memory is larger than the memory threshold, generating a memory image file of the target process according to preset memory image logic.
In a second aspect, an embodiment of the present disclosure provides a memory image file generating device, including:
the reading module is used for reading the occupied memory of the target process when the state value of the target process of the target application is updated;
and the generating module is used for generating a memory image file of the target process according to preset memory image logic if the occupied memory is larger than a memory threshold value.
In a third aspect, an embodiment of the present disclosure provides an electronic device, which includes a storage, a processing apparatus, and a computer program that is stored in the storage and is executable on the processing apparatus, where the processing apparatus implements a memory image file generation method according to any embodiment of the present disclosure when executing the program.
In a fourth aspect, embodiments of the present disclosure provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the memory image file generation method according to any of the embodiments of the present disclosure.
According to the technical scheme of the embodiment of the invention, the memory mirror image can be generated according to the self-defined memory mirror image logic so as to realize memory optimization analysis, further cutting of the mirror image file is avoided, the load of a server is reduced, the success rate of the memory mirror image is improved, and further the real-time performance, the accuracy and the stability of memory monitoring are improved.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
FIG. 1 is a flow chart of one embodiment of a memory image file generation method of the present disclosure;
FIG. 2 is a flow chart of another embodiment of a memory image file generation method of the present disclosure;
FIG. 3 is a flow chart of another embodiment of a memory image file generation method of the present disclosure;
FIG. 4 is a flow chart of another embodiment of a memory image file generation method of the present disclosure;
fig. 5 is a schematic diagram of another embodiment of a memory image file generation method according to the present disclosure;
fig. 6 is a block diagram illustrating an embodiment of a memory image file generating apparatus according to the present disclosure;
FIG. 7 is a block diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Example one
Fig. 1 is a flowchart of a method for generating a memory image file according to an embodiment of the present disclosure, where this embodiment is applicable to a situation where a memory usage status is monitored according to a memory image file, and the method may be executed by a device for generating a memory image file according to an embodiment of the present disclosure, where the device may be implemented by software and/or hardware and integrated in a terminal device, and the method specifically includes the following steps:
s110, when the state value of the target process of the target application is updated, the occupied memory of the target process is read.
The target application is an application installed in the terminal device, and may be a news client, a browser, or a music player, for example. The terminal device may be any Android system mobile phone, tablet, or vehicle-mounted terminal device, which is not limited in the present disclosure.
The target process of the target application is a program execution process of the target application, and generally, one target application corresponds to one target process. The target process state value ADJ is used for representing the state and the priority of a target process, the states of the target process represented by different values of the target process state value are different, and the states of the target process in the Android system can be divided into the following states according to the priority: the system comprises a foreground process, a visible process, a service process, a background process and an empty process, wherein the priority of the foreground process is the highest, and the priority of the empty process is the lowest.
The memory occupied by the target process refers to the size of the memory occupied by the target process, and for example, the memory occupied by the browser is 100MB, and the memory occupied by the music player is 30 MB. When the target process state value of the target application is updated, the fact that the occupied memory of the target process may change is indicated.
For example, when the target process state value of the target application is updated, the method for reading the occupied memory of the target process may be to read the occupied memory of the target process when the Activity Management Server (AMS) detects that the target process state value of the target application is updated, or may be to write the occupied memory corresponding to the target process into a memory log file when the Activity management server detects that the target process state value of the target application is updated, and write the memory log file into a log system based on a log library interface; and reading a memory log file in a log system and an occupied memory of a target process in the memory log file through a command line tool.
And S120, if the occupied memory is larger than a memory threshold value, generating a memory mirror image file of the target process according to preset memory mirror image logic.
The memory mirror image file refers to a backup file of memory data, and is generally a file with a dump as a suffix name, and can be used for avoiding data loss caused by memory failure.
The memory threshold value may be set according to actual requirements, or may be determined according to the memory capacity of the terminal device.
Illustratively, when it is determined by the memory monitor that the occupied memory corresponding to the target process of the target application is greater than the memory threshold, the memory data of the target process is acquired, and the memory image file of the target process is generated according to the preset memory image logic.
It should be noted that the active mirror image logic is built in the Android system, and the memory mirror image file generated according to the active mirror image logic often includes useless data, so that the generated memory mirror image file has a large data volume, which easily causes system load aggravation, and an application program has no response, even cannot generate a mirror image file. Therefore, the preset memory mirroring logic may be other logic for generating an image file than the source mirroring logic in the Android system, for example, may be mirroring logic for discarding useless data. When the occupied memory is larger than the memory threshold value, the source mirror image logic arranged in the Android system is abandoned, and the memory mirror image file of the target process is generated by adopting the preset memory mirror image logic, so that the mirror image file is prevented from being cut after the source mirror image logic in the Android system is adopted to generate the mirror image file.
Optionally, the method further includes:
and generating a memory state report according to the memory mirror image file.
Illustratively, after a memory image file of a target process is generated according to a preset memory image logic, according to the memory image file, memory data in the memory image file is extracted to generate a memory state report, so as to realize real-time monitoring of the target process of a target application, and also realize optimization of a memory use state according to the memory state report.
According to the technical scheme of the embodiment of the disclosure, when the state value of the target process of the target application is updated, the occupied memory of the target process is read; if the occupied memory is larger than the memory threshold value, a memory mirror image file of the target process is generated according to the preset memory mirror image logic, and a memory mirror image can be generated according to the preset memory mirror image logic to realize memory optimization analysis, so that the mirror image file is prevented from being further cut, the load of a server is reduced, the success rate of the memory mirror image is improved, and the real-time performance, the accuracy and the stability of memory monitoring are further improved.
Example two
Fig. 2 is a flowchart of a method for generating a memory image file according to a second embodiment of the present disclosure, which is embodied on the basis of the second embodiment, in this embodiment, when a state value of a target process of a target application is updated, reading an occupied memory of the target process includes: when the target process state value of the target application is updated, writing the occupied memory corresponding to the target process into a memory log file; writing the memory log file into a log system based on a log library interface; reading a memory log file in a log system and an occupied memory of a target process in the memory log file by a command line tool, wherein the method of the embodiment specifically comprises the following steps:
s210, when the state value of the target process of the target application is updated, writing the occupied memory corresponding to the target process into a memory log file.
The memory log file is a record file or a file set for recording memory data.
When an Activity Manager Service (AMS) detects that the state value of a target process of a target application is updated, namely when the occupied memory corresponding to the target process is changed, the event log server EventLog writes the occupied memory corresponding to the target process into a memory log file by the target application.
And S220, writing the memory log file into a log system based on a log library interface.
The log library is a unit for collecting, storing and querying log data in log service.
Illustratively, a log library interface provided by a log library writes a log file containing an occupied memory corresponding to a target process into a log system. The log library interface is not limited in the embodiment of the present disclosure, and may be a SOCKET interface, for example.
And S230, reading a memory log file in the log system and the occupied memory of the target process in the memory log file through a command line tool.
The command line tool is used to parse the format of the memory log file into a recognizable format, for example, the command line tool may be Logcat. And reading a memory log file in the log system through a command tool Logcat, and further reading the occupied memory of a target process in the memory log file.
Generally, a mode of acquiring the memory occupied by the target process is usually an active polling mode, that is, a preset memory monitoring logic is embedded into each target application through an Axis2 archive (AAR) of an Android system, and the memory occupied by the target process is actively acquired, which brings about a main problem that if the polling frequency is too fast, resources are wasted, and if the frequency is too slow, an accurate current memory value cannot be acquired.
In the embodiment of the present disclosure, when the memory state value changes, the target application writes the occupied memory corresponding to the target process into the memory log file of the log system, and reads the memory log file in the log system through the memory monitor to obtain the occupied memory of the target process. The occupied memory of the target process is obtained by adopting a passive reading mode, and the problem caused by an active polling mode is solved.
S240, if the occupied memory is larger than the memory threshold value, generating a memory image file of the target process according to preset memory image logic.
According to the technical scheme of the embodiment of the disclosure, when the target process state value of the target application is updated, the occupied memory corresponding to the target process is written into the memory log file; writing the memory log file into a log system based on a log library interface; the method comprises the steps of reading a memory log file in a log system and an occupied memory of a target process in the memory log file through a command line tool, if the occupied memory is larger than a memory threshold value, generating a memory mirror image file of the target process according to preset memory mirror image logic, obtaining the occupied memory of the target process in a passive reading mode, improving the real-time performance, accuracy and stability of memory monitoring, generating a memory mirror image according to the preset memory mirror image logic to achieve memory optimization analysis, avoiding further cutting of the mirror image file, reducing server load and improving the success rate of memory mirror image.
EXAMPLE III
Fig. 3 is a flowchart of a method for generating a memory image file according to a third embodiment of the present disclosure, which is embodied based on the foregoing embodiments, and in this embodiment, generating a memory image file of a target process according to a preset memory image logic includes: acquiring memory data corresponding to preset memory mirror image logic and a target process; cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data; generating a memory image file of the target process according to the target memory data, wherein the method of the embodiment specifically comprises the following steps:
s310, when the state value of the target process of the target application is updated, the occupied memory of the target process is read.
And S320, if the occupied memory is larger than the memory threshold, acquiring memory data corresponding to the preset memory mirror image logic and the target process.
The preset memory mirror image logic is logic for generating a memory mirror image file according to memory data. The preset memory mirror image logic is used for discarding basic data, objects with small internal opposite value changes and non-memory leakage, and data with invalid memory optimization or unnecessary data in the memory data when generating the memory mirror image file according to the memory data. The preset memory logic may be stored in a memory of the target application, and the embodiment of the present disclosure is not limited thereto.
Illustratively, if the occupied memory is greater than the memory threshold, the preset memory mirror logic is acquired, and an instruction is sent to the target process to acquire the memory data of the target process.
S330, cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data.
Illustratively, when the memory image file is generated, a source memory image logic built in the Android is abandoned, and the memory data corresponding to the target process is cut through the preset memory image logic to obtain target memory data.
And S340, generating a memory mirror image file of the target process according to the target memory data.
The method includes the steps that memory data corresponding to preset memory mirror image logic and a target process are obtained; cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data; and generating a memory mirror image file of the target process according to the target memory data, discarding useless data at the source of generating the mirror image file, and cutting the mirror image file without generating the mirror image file according to source-generated mirror image logic, so that memory fluctuation is reduced, and the success rate of generating the memory mirror image is improved.
Optionally, in this embodiment of the present disclosure, the cutting the memory data corresponding to the target process through the preset memory mirror logic to obtain target memory data includes:
determining data to be discarded according to the preset memory mirror image logic;
and cutting the data to be discarded from the memory data corresponding to the target process to obtain target memory data.
The data to be discarded can be set according to the user requirement, and can also be set according to the use purpose of the memory image file. For example, if the memory optimization report is generated according to the memory image file, the data to be discarded may include data that is useless for memory optimization.
Optionally, the data to be discarded includes: basic data type, array, incubator data, photo memory buffer data, placeholder, and/or image pixel data.
Optionally, in this embodiment of the present disclosure, the preset memory mirror logic is packaged in a library file.
The method includes the steps that memory data corresponding to preset memory mirror image logic and a target process are obtained; cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data; and generating a memory mirror image file of the target process according to the target memory data, abandoning a source Android mirror image logic, adopting a memory mirror image logic with direct cutting capability, abandoning useless data at the source of generating the mirror image file, and eliminating the step of cutting the mirror image file after the mirror image file is generated, thereby reducing memory fluctuation and improving the success rate of generating the memory mirror image.
Example four
Fig. 4 is a flowchart of a method for generating a memory mirror image file according to a fourth embodiment of the present disclosure, which is embodied based on the foregoing embodiments, and in this embodiment, before generating a memory mirror image file of a target process according to a preset memory mirror image logic if the occupied memory is greater than a memory threshold, the method further includes: setting the value of the class loader of the memory data of the target application to be a null value so that a preset memory mirror logic passes the permission check, wherein the method specifically comprises the following steps:
s410, when the state value of the target process of the target application is updated, the occupied memory of the target process is read.
S420, setting the value of the class loader of the memory data of the target application to be a null value so that the preset memory mirror image logic passes the permission check.
In the embodiment of the disclosure, useless data can be abandoned from the source by abandoning the source mirror image logic in the Android system and adopting the preset mirror image logic with direct cutting capability to generate the mirror image file. However, since the Android system permission setting cannot directly call the library file of the preset memory mirror logic, the value of the class loader of the memory data of the target application needs to be set to be a null value so as to pass the permission check of the Android system.
S430, if the occupied memory is larger than the memory threshold value, generating a memory image file of the target process according to preset memory image logic.
As shown in fig. 5, the specific steps of the embodiment of the present disclosure are: when the target process state value of the target application is updated, the activity management server writes the acquired occupied memory of the target application into a log file through a time log service, and stores the log file into a log library. The method comprises the steps of reading a file in a log library through a monitor to obtain an occupied memory of a target application, obtaining memory data of the target application corresponding to a target process when the occupied memory of the target process is determined to be larger than a memory threshold value, abandoning a source Android mirror image logic, calling a preset memory mirror image logic with a shearing capability to generate a memory mirror image file of the target process, and abandoning useless data on a source of generating the mirror image file.
According to the technical scheme of the embodiment of the disclosure, when the state value of the target process of the target application is updated, the occupied memory of the target process is read; setting the value of a class loader of the memory data of the target application as a null value so that the preset memory mirror image logic passes the permission check; if the occupied memory is larger than the memory threshold value, a memory image file of a target process is generated according to the preset memory image logic, the problem of permission limitation of an Android system to the preset memory image logic is solved, the original Android image logic is abandoned, the memory image logic with direct cutting capability is adopted, useless data are abandoned at the source of generating the image file, the step of cutting the image file after the image file is generated is not needed, the memory fluctuation is reduced, and the success rate of generating the memory image is improved.
EXAMPLE five
Fig. 6 is a block diagram of a structure of a memory image file generating device according to a fifth embodiment of the present disclosure, which specifically includes: a reading module 510 and an image file generating module 520;
a reading module 510, configured to read an occupied memory of a target process when a target process state value of a target application is updated;
a mirror image file generating module 520, configured to generate a memory mirror image file of the target process according to a preset memory mirror image logic if the occupied memory is greater than a memory threshold.
According to the technical scheme of the embodiment of the invention, the memory mirror image can be generated according to the self-defined memory mirror image logic so as to realize memory optimization analysis, further cutting of the mirror image file is avoided, the load of a server is reduced, the success rate of the memory mirror image is improved, and further the real-time performance, the accuracy and the stability of memory monitoring are improved.
Optionally, on the basis of the foregoing technical solution, the reading module 510 is specifically configured to:
when the target process state value of the target application is updated, writing the occupied memory corresponding to the target process into a memory log file;
writing the memory log file into a log system based on a log library interface;
and reading a memory log file in a log system and an occupied memory of a target process in the memory log file through a command line tool.
Optionally, on the basis of the above technical solution, the apparatus further includes:
and the status report generating module is used for generating a memory status report according to the memory mirror image file.
Optionally, on the basis of the above technical solution, the image file generating module 520 is specifically configured to:
acquiring memory data corresponding to preset memory mirror image logic and a target process;
cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data;
and generating a memory mirror image file of the target process according to the target memory data.
Optionally, on the basis of the foregoing technical solution, the image file generating module 520 is further configured to:
determining data to be discarded according to the preset memory mirror image logic;
and cutting the data to be discarded from the memory data corresponding to the target process to obtain target memory data.
Optionally, on the basis of the above technical solution, the data to be discarded includes: basic data type, array, incubator data, photo memory buffer data, placeholder, and/or image pixel data.
Optionally, on the basis of the above technical solution, the apparatus further includes:
and setting the value of a class loader of the memory data of the target application as a null value by the permission module before generating the memory mirror image file of the target process according to the preset memory mirror image logic by the permission module if the occupied memory is larger than the memory threshold value, so that the preset memory mirror image logic passes permission check.
Optionally, on the basis of the above technical solution, the preset memory mirror image logic is packaged in a library file form.
The device can execute the memory image file generation method provided by any embodiment of the disclosure, and has the corresponding functional modules and beneficial effects of the execution method. Technical details that are not elaborated in this embodiment may be referred to a method provided by any embodiment of the present disclosure.
EXAMPLE six
FIG. 7 illustrates a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 7 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (Hyper Text Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: when the state value of a target process of a target application is updated, reading the occupied memory of the target process; and if the occupied memory is larger than the memory threshold, generating a memory image file of the target process according to preset memory image logic.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. The name of a module does not constitute a limitation on the module itself in some cases, for example, a read module may be described as "used for reading the occupied memory of the target process when the state value of the target process of the target application is updated". The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, [ example 1 ] there is provided a memory image file generating method, including:
when the state value of a target process of a target application is updated, reading the occupied memory of the target process;
and if the occupied memory is larger than the memory threshold, generating a memory image file of the target process according to preset memory image logic.
According to one or more embodiments of the present disclosure, [ example 2 ] there is provided the method of example 1, when a target process state value of a target application is updated, reading occupied memory of the target process, including:
when the target process state value of the target application is updated, writing the occupied memory corresponding to the target process into a memory log file;
writing the memory log file into a log system based on a log library interface;
and reading a memory log file in a log system and an occupied memory of a target process in the memory log file through a command line tool.
In accordance with one or more embodiments of the present disclosure, [ example 3 ] there is provided the method of example 1, further comprising:
and generating a memory state report according to the memory mirror image file.
According to one or more embodiments of the present disclosure, [ example 4 ] there is provided the method of example 1, generating a memory image file of a target process according to a preset memory image logic, including:
acquiring memory data corresponding to preset memory mirror image logic and a target process;
cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data;
and generating a memory mirror image file of the target process according to the target memory data.
According to one or more embodiments of the present disclosure, [ example 5 ] there is provided the method of example 4, where the obtaining of the target memory data by clipping the memory data corresponding to the target process through the preset memory mirroring logic includes:
determining data to be discarded according to the preset memory mirror image logic;
and cutting the data to be discarded from the memory data corresponding to the target process to obtain target memory data.
According to one or more embodiments of the present disclosure, [ example 6 ] there is provided the method of example 5, the data to be discarded comprising: basic data type, array, incubator data, photo memory buffer data, placeholder, and/or image pixel data.
According to one or more embodiments of the present disclosure, [ example 7 ] there is provided the method of example 1, before generating the memory image file of the target process according to the preset memory image logic if the occupied memory is greater than the memory threshold, further including:
and setting the value of the class loader of the memory data of the target application as a null value so that the preset memory mirror image logic passes the permission check.
According to one or more embodiments of the present disclosure, [ example 8 ] there is provided the method of any one of examples 1 to 7, wherein the predetermined memory mirroring logic is encapsulated in a form of a library file.
According to one or more embodiments of the present disclosure, [ example 9 ] there is provided a memory image file generating apparatus including:
the reading module is used for reading the occupied memory of the target process when the state value of the target process of the target application is updated;
and the image file generation module is used for generating the memory image file of the target process according to preset memory image logic if the occupied memory is larger than a memory threshold value.
According to one or more embodiments of the present disclosure, [ example 10 ] there is provided the apparatus of example 9, the reading module to:
when the target process state value of the target application is updated, writing the occupied memory corresponding to the target process into a memory log file;
writing the memory log file into a log system based on a log library interface;
and reading a memory log file in a log system and an occupied memory of a target process in the memory log file through a command line tool.
According to one or more embodiments of the present disclosure, [ example 11 ] there is provided the apparatus of example 9, further comprising:
and the status report generating module is used for generating a memory status report according to the memory mirror image file.
According to one or more embodiments of the present disclosure, [ example 12 ] there is provided the apparatus of example 9, the image file generation module to:
acquiring memory data corresponding to preset memory mirror image logic and a target process;
cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data;
and generating a memory mirror image file of the target process according to the target memory data.
According to one or more embodiments of the present disclosure, [ example 13 ] there is provided the apparatus of example 12, the image file generation module further to:
determining data to be discarded according to the preset memory mirror image logic;
and cutting the data to be discarded from the memory data corresponding to the target process to obtain target memory data.
According to one or more embodiments of the present disclosure, [ example 14 ] there is provided the apparatus of example 13, the data to discard comprising: basic data type, array, incubator data, photo memory buffer data, placeholder, and/or image pixel data.
According to one or more embodiments of the present disclosure, [ example 15 ] there is provided the apparatus of example 9, further comprising:
and setting the value of a class loader of the memory data of the target application as a null value by the permission module before generating the memory mirror image file of the target process according to the preset memory mirror image logic by the permission module if the occupied memory is larger than the memory threshold value, so that the preset memory mirror image logic passes permission check.
According to one or more embodiments of the present disclosure, [ example 16 ] there is provided the apparatus of any one of examples 9 to 15, the preset memory mirroring logic packaged in a form of a library file.
According to one or more embodiments of the present disclosure, [ example 20 ] there is provided an electronic device including a memory, a processing apparatus, and a computer program stored on the memory and executable on the processing apparatus, the processing apparatus implementing the memory image file generating method according to any one of examples 1 to 8 when executing the program.
According to one or more embodiments of the present disclosure, [ example 21 ] there is provided a storage medium containing computer-executable instructions for performing the memory image file generation method of any one of examples 1-8 when executed by a computer processor.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (11)

1. A method for generating a memory image file is characterized by comprising the following steps:
when the state value of a target process of a target application is updated, reading the occupied memory of the target process;
and if the occupied memory is larger than the memory threshold, generating a memory image file of the target process according to preset memory image logic.
2. The method of claim 1, wherein reading the memory occupied by the target process when the target process state value of the target application is updated comprises:
when the target process state value of the target application is updated, writing the occupied memory corresponding to the target process into a memory log file;
writing the memory log file into a log system based on a log library interface;
and reading a memory log file in a log system and an occupied memory of a target process in the memory log file through a command line tool.
3. The method of claim 1, further comprising:
and generating a memory state report according to the memory mirror image file.
4. The method of claim 1, wherein generating the memory image file of the target process according to the preset memory image logic comprises:
acquiring memory data corresponding to preset memory mirror image logic and a target process;
cutting the memory data corresponding to the target process through the preset memory mirror image logic to obtain target memory data;
and generating a memory mirror image file of the target process according to the target memory data.
5. The method of claim 4, wherein the obtaining of the target memory data by clipping the memory data corresponding to the target process through the preset memory mirror logic comprises:
determining data to be discarded according to the preset memory mirror image logic;
and cutting the data to be discarded from the memory data corresponding to the target process to obtain target memory data.
6. The method of claim 5, wherein the data to be discarded comprises: basic data type, array, incubator data, photo memory buffer data, placeholder, and/or image pixel data.
7. The method according to claim 1, wherein before generating the memory image file of the target process according to a preset memory image logic if the occupied memory is greater than a memory threshold, the method further comprises:
and setting the value of the class loader of the memory data of the target application as a null value so that the preset memory mirror image logic passes the permission check.
8. The method according to any one of claims 1 to 7, wherein the predetermined memory mirroring logic is encapsulated in the form of a library file.
9. An apparatus for generating a memory image file, comprising:
the reading module is used for reading the occupied memory of the target process when the state value of the target process of the target application is updated;
and the image file generation module is used for generating the memory image file of the target process according to preset memory image logic if the occupied memory is larger than a memory threshold value.
10. An electronic device comprising a memory, a processing means, and a computer program stored on the memory and executable on the processing means, wherein the processing means implements the memory image file generating method according to any one of claims 1 to 8 when executing the program.
11. A storage medium containing computer-executable instructions for performing the memory image file generation method of any one of claims 1-8 when executed by a computer processor.
CN202110444005.3A 2021-04-23 2021-04-23 Memory image file generation method and device, electronic equipment and storage medium Pending CN113094178A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110444005.3A CN113094178A (en) 2021-04-23 2021-04-23 Memory image file generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110444005.3A CN113094178A (en) 2021-04-23 2021-04-23 Memory image file generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113094178A true CN113094178A (en) 2021-07-09

Family

ID=76679655

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110444005.3A Pending CN113094178A (en) 2021-04-23 2021-04-23 Memory image file generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113094178A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018072408A1 (en) * 2016-10-18 2018-04-26 广州市动景计算机科技有限公司 Memory analysis method, device, system and computing device
CN109828859A (en) * 2019-01-23 2019-05-31 网易(杭州)网络有限公司 Mobile terminal memory analysis method, apparatus, storage medium and electronic equipment
CN110795239A (en) * 2019-10-15 2020-02-14 浙江口碑网络技术有限公司 Application memory leakage detection method and device
CN111596932A (en) * 2020-06-22 2020-08-28 腾讯科技(深圳)有限公司 Mirror image file generation method and device and computer readable storage medium
CN111639018A (en) * 2019-03-01 2020-09-08 阿里巴巴集团控股有限公司 Memory leak detection method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018072408A1 (en) * 2016-10-18 2018-04-26 广州市动景计算机科技有限公司 Memory analysis method, device, system and computing device
CN109828859A (en) * 2019-01-23 2019-05-31 网易(杭州)网络有限公司 Mobile terminal memory analysis method, apparatus, storage medium and electronic equipment
CN111639018A (en) * 2019-03-01 2020-09-08 阿里巴巴集团控股有限公司 Memory leak detection method and device
CN110795239A (en) * 2019-10-15 2020-02-14 浙江口碑网络技术有限公司 Application memory leakage detection method and device
CN111596932A (en) * 2020-06-22 2020-08-28 腾讯科技(深圳)有限公司 Mirror image file generation method and device and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN111581563B (en) Page response method and device, storage medium and electronic equipment
CN111930534A (en) Data calling method and device and electronic equipment
CN111198777A (en) Data processing method, device, terminal and storage medium
CN111611145A (en) Breakdown information collection method and device, storage medium and electronic equipment
CN111966653A (en) Data processing method, device, server and storage medium for micro-service call link
CN111338834A (en) Data storage method and device
CN111191225B (en) Method, device, medium and electronic equipment for switching isolated objects
CN113094178A (en) Memory image file generation method and device, electronic equipment and storage medium
CN111625745B (en) Recommendation method, recommendation device, electronic equipment and computer readable medium
CN110727694B (en) Data processing method, device, electronic equipment and storage medium
CN114785770A (en) Mirror layer file sending method and device, electronic equipment and computer readable medium
CN110086880B (en) Method and apparatus for creating instances of network requests
CN113127282A (en) Frame capability determining method and device, electronic equipment and storage medium
CN111552705A (en) Data processing method and device based on chart, electronic equipment and medium
CN116383013B (en) Method for collecting monitoring information of server equipment and electronic equipment
CN117692672B (en) Snapshot-based video information sending method and device, electronic equipment and medium
CN113342837B (en) Data transmission method, device, electronic equipment and computer readable medium
CN112948108B (en) Request processing method and device and electronic equipment
CN112035529B (en) Caching method, caching device, electronic equipment and computer readable storage medium
CN114844741A (en) CAN bus data storage method and device, electronic equipment and computer readable medium
CN117908783A (en) Operation log uploading method and device, electronic equipment and readable medium
CN117076407A (en) Information processing method, device, terminal and storage medium
CN117009168A (en) Application index acquisition method, device, equipment and medium
CN111404824A (en) Method, apparatus, electronic device and computer readable medium for forwarding a request
CN114968944A (en) Offline log processing method and device, electronic equipment and storage medium

Legal Events

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