CN111638952A - Memory dump method and device and electronic equipment - Google Patents

Memory dump method and device and electronic equipment Download PDF

Info

Publication number
CN111638952A
CN111638952A CN202010388017.4A CN202010388017A CN111638952A CN 111638952 A CN111638952 A CN 111638952A CN 202010388017 A CN202010388017 A CN 202010388017A CN 111638952 A CN111638952 A CN 111638952A
Authority
CN
China
Prior art keywords
main process
memory
memory dump
sub
calling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010388017.4A
Other languages
Chinese (zh)
Other versions
CN111638952B (en
Inventor
李锐
薛秋实
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information 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 Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202010388017.4A priority Critical patent/CN111638952B/en
Publication of CN111638952A publication Critical patent/CN111638952A/en
Application granted granted Critical
Publication of CN111638952B publication Critical patent/CN111638952B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Landscapes

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

Abstract

The embodiment of the application provides a memory dump method, a memory dump device and electronic equipment, and relates to the technical field of data processing. The memory dump method comprises the following steps: and calling the main process to execute a preset task and judging whether the main process meets the memory dump condition. And if the main process meets the memory dump condition, creating a subprocess, and calling the subprocess to perform memory dump on the main process. A memory dump method is provided, so that the system can also work normally in the process of memory dump of the electronic equipment.

Description

Memory dump method and device and electronic equipment
Technical Field
The embodiment of the application relates to the technical field of data processing, in particular to a memory dump method, a memory dump device and electronic equipment.
Background
And after the application process of the operating system crashes due to the overflow of the memory, dumping the data in the memory into the storage device so as to facilitate the problem location of related technicians. The later generated files of the memory dump may be referred to as a memory image.
Taking the android system as an example, the android system provides an interface for generating a memory mirror image by memory dumping. That is, in the android system, if a system crash (or memory leak) occurs, a memory dump can be implemented through the memory dump interface. Specifically, after the system crashes, the memory dump interface is called, and the system temporarily freezes all threads in the memory and generates a memory image. According to different sizes of the memory heap, the system freezes the progress for several seconds or even several minutes, and the freezing time depends on the occupied size of the current virtual machine heap. If the freezing time is too long, the freezing process can not work normally, and the normal operation can be recovered after the dumping is finished.
Disclosure of Invention
The application provides a memory dump method, a memory dump device and electronic equipment, so that a system can work normally in the process of memory dump of the electronic equipment.
In order to achieve the technical purpose, the embodiment of the application adopts the following technical scheme:
in a first aspect, the present application provides a method for memory dump, where the method may include: and calling the main process to execute a preset task and judging whether the main process meets the memory dump condition. And if the main process meets the memory dump condition, creating a subprocess, and calling the subprocess to perform memory dump on the main process.
It can be understood that when the main process meets the memory dump condition, the system can perform memory dump on the main process. Specifically, the system determines that the main process meets the memory dump condition, creates a sub-process for the main process, and calls the sub-process to perform memory dump on the main process. That is, the system may create a sub-process for the main process, and perform a memory dump on the main process through the sub-process. Therefore, the main process is not frozen in the process of memory dump, and the normal operation of the system is not influenced. That is to say, in the process of performing memory dump on the main process in the sub-process, the main process can also continue to run, and the system will not be stuck.
In a possible implementation manner, if the main process meets the memory dump condition, the sub-process is created, and the sub-process is called to perform the memory dump on the main process. The specific implementation can include: and if the main process meets the memory dump condition, suspending the main process from executing the preset task. And aiming at the main process, a copy-on-write technology is adopted, a subprocess is created, and the subprocess is called to carry out memory dump on the main process.
After the main process is suspended, the current main process is copied by adopting a copy-on-write technology, so that the current progress of the sub-process can be ensured to be consistent with the current progress of the main process. Therefore, the sub-process can dump the memory occupied by the main process to generate the memory image.
In another possible implementation, after creating the sub-process if the main process meets the memory dump condition, the method may further include: and continuing to call the main process to execute the preset task.
That is, during the memory dump process of the sub-process to the main process, the main process may continue to execute the corresponding task. Thus, the system does not suffer from jamming.
In another possible implementation, after the calling sub-process performs the memory dump on the main process, the method may further include: the main process can monitor the state of the sub-process through interprocess communication; the sub-process completes the memory dump, and the main process can monitor the information generated by the memory dump file of the sub-process.
In another possible implementation, the main process satisfying the memory dump condition includes: the memory space occupied by the main process is larger than a preset memory threshold value, the memory leakage occurs when the main process operates, and the memory shortage occurs when the main process operates.
In a second aspect, the present application provides a memory dump apparatus, which may include: the device comprises a judging module and a creating module. And the judging module is used for calling the main process to execute the preset task and judging whether the main process meets the memory dump condition. And the creating module is used for creating the subprocess and calling the subprocess to perform memory dump on the main process if the main process meets the memory dump condition.
In a possible embodiment, the creating module is configured to create a sub-process if the main process meets a memory dump condition, and call the sub-process to perform a memory dump on the main process. The method specifically comprises the following steps: and the creating module is specifically used for pausing the main process to execute the preset task if the main process meets the memory dump condition. And aiming at the main process, a copy-on-write technology is adopted, a subprocess is created, and the subprocess is called to carry out memory dump on the main process.
In another possible implementation, the apparatus further includes a calling module; and the calling module is used for continuing calling the main process to execute the preset task after the subprocess is created.
In another possible implementation, the determining module is specifically configured to monitor a state of the sub-process through inter-process communication by the main process; the sub-process completes the memory dump, and the main process can monitor the information generated by the memory dump file of the sub-process.
In another possible implementation, the main process satisfying the memory dump condition includes: the memory space occupied by the main process is larger than a preset memory threshold value, the memory leakage occurs when the main process operates, and the memory shortage occurs when the main process operates.
In a third aspect, the present application further provides an electronic device, including a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of the first aspect and any of its possible embodiments described above.
In a fourth aspect, the present application further provides a computer-readable storage medium having computer instructions stored thereon, where the computer instructions are characterized by implementing the method of the first aspect and any possible implementation manner thereof when the computer instructions are executed on an electronic device.
It is to be understood that the advantages achieved by the apparatus in the second aspect and any possible implementation manner thereof, the electronic device in the third aspect and the computer-readable storage medium in the fourth aspect are provided as follows, and therefore, the description thereof is omitted here for brevity.
Drawings
FIG. 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;
fig. 2A is a schematic structural diagram of a virtual machine according to an embodiment of the present disclosure;
fig. 2B is a schematic structural diagram of a process corresponding to a virtual machine running application according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for memory dump according to an embodiment of the present application;
FIG. 4 is a flowchart of another method for memory dump according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of another electronic device according to an embodiment of the present application.
Detailed Description
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present embodiment, "a plurality" means two or more unless otherwise specified.
The terms referred to in the present application will be explained below.
Linux: the Operating system is an Operating system which is based on Portable Operating System Interface (POSIX) and Unix (the name of an Operating system) and supports multiple users, multiple tasks and multiple Central Processing Units (CPUs).
Android (Android): the operating system is a Linux-based free and open source code operating system.
Virtual Machine (Virtual Machine): refers to a complete computer system with complete hardware system functionality, which is simulated by software and runs in a completely isolated environment. The work that can be done in a physical computer can be implemented in a virtual machine. When creating a virtual machine in a computer, it is necessary to use a part of the hard disk and the memory capacity of the physical machine as the hard disk and the memory capacity of the virtual machine.
Memory mirroring: and (4) generating a file after memory dump, wherein the file can comprise the current memory occupation condition.
A Java virtual machine: is a virtual machine that can run Java programs. The application programs on the Android system are all written by using Java language, so that the application programs on the Android system can run in a Java virtual machine.
And (4) process: is a running activity of a program in a computer on a certain data set, and can also be a basic unit for resource allocation and scheduling of a system. A program is a description of instructions, data, and their organization in a computer system, and a process is an entity of a program. When an application program runs on a computer system, multiple processes may be generated.
Memory Leak (Memory Leak): the memory space allocated to the program dynamically by the system during the program running is a phenomenon that the memory space occupied by the program is not released or can not be released due to some reason. The memory leak causes the memory of the system to be unreleased or not released, which causes memory waste, and may result in slow program running speed, even system crash, and the like.
Memory overflow (Out Of Memory, OOM): the method refers to the fact that a memory which cannot be released exists in a system or the memory of the system is occupied more, when a new program needs to run by the system, the memory needed by the new program is larger than the maximum memory which can be provided by the system, and therefore the new program cannot run.
Generally, for example, Android is used, and the stability of an application program in an Android system during running is closely related to the situation that a process of the application program occupies a memory. In the Android system, the process of the application program runs in a Java virtual machine. For example, when an application program runs in the Java virtual machine, the memory of the Java virtual machine is insufficient due to memory leak or memory overflow in other development stages. When the memory of the Java virtual machine is not sufficient to support the memory required by the application's process, the stability of the application may be degraded. The stability of the application program is poor, which affects the user experience, and how to ensure the stability of the application program is a problem that developers often face. Therefore, in the process of developing the application program, if the process of the application level occupies insufficient memory, the developer needs to know the reason of the insufficient memory of the application program to solve the problem. Therefore, in the process of executing the task by the process of the application program, a memory image needs to be generated in a memory dump manner, and the memory image includes the memory occupation condition of the current Java virtual machine. A developer knows the reason of insufficient memory in the Java virtual machine by looking up the memory mirror image, and then solves the problem.
It can be understood that the memory occupied by the process corresponding to the application is only a virtual memory (or referred to as a logical memory), and in fact, the running of the application requires a physical memory. When a process executes a task in a Java virtual machine, the Android system may map a Memory (virtual Memory) applied for the process to a Random Access Memory (RAM), so that the process of an application program may use a physical Memory. It should be noted that although the virtual memory applied by the process may be mapped to the physical memory, the space operated by the process is a virtual address space, and the RAM cannot be directly operated.
Specifically, the Android system provides a memory dump interface for a developer, and the system can convert a memory currently occupied by a process of an application program into a memory mirror image by calling the memory dump interface. For example, the name of a memory dump interface provided for a Java virtual machine in an Android system is: os. And calling the memory dump interface to generate a memory mirror image (or called an hprof file) when the Android system performs memory dump.
Therefore, developers can check the memory mirror image and can know the reason of insufficient memory of the Java virtual machine through analysis of the memory mirror image. When the memory image is generated through the memory dump interface, the system can temporarily freeze all processes in the Java virtual machine for several seconds or several minutes. When all processes in the Java virtual machine are frozen, the system cannot perform any operation, so that the system has a pause phenomenon. If the application is already provided for the user equipment to download online, when the application is run on the user equipment, if a memory dump needs to be performed on a virtual machine of the user equipment, the process of the application is frozen, so that the system is stuck and the user experience is affected.
In addition, because all processes in the virtual machine are frozen in the process of memory dumping, the system cannot currently execute any operation, and the memory dumping mode is inefficient and can only be used at the stage of developing an application. If the memory dump is still performed in this way after the application is online, the user experience is affected. If the memory dump is cancelled after the application is online, the developer cannot find the problem that occurs when the application runs on the user equipment of the client.
The embodiment of the application provides a memory dump method, which can be applied to electronic equipment. In the process of application development, the electronic equipment of the developer can generate the memory mirror image through the method, so that the developer can analyze the problem of insufficient memory in the application development according to the memory mirror image. In addition, the method can be applied to the electronic equipment of the user after the application is online, so that a developer can obtain the memory mirror image on the electronic equipment of the user, and the problem of insufficient memory when the application is online is solved by analyzing the memory mirror image. The method for memory dump can not freeze the application process in the implementation process, and reduces the influence of the memory dump on the system.
In the implementation process of the memory dump method, if the system triggers the memory dump, a subprocess can be created for the current main process of the system, and the memory dump process is performed in the subprocess. In this way, the main process of the system can continue to execute tasks, that is, the main process of the system is not frozen, and meanwhile, the system can perform memory dump in the sub-processes.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 1, a schematic diagram of an implementation environment related to a memory dump method provided in an embodiment of the present application is shown. As shown in fig. 1, the enforcement environment may include a server 101 and a plurality of electronic devices 102. For example, the electronic device may be a mobile phone, a computer, or the like.
If the electronic device 102 is a computer of a developer, the electronic device 102 may interact with the server 101 to implement an application development function. If the electronic device 102 is a mobile phone of a user, the electronic device 102 may download an installation package of an Application (APP) from the server 101, and the electronic device 102 may install the APP and run the APP. The server 101 may obtain relevant data of the APP in the electronic device 102.
The electronic device in the embodiment of the present application may be, for example, a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a vehicle-mounted device, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a Personal Digital Assistant (PDA), an Augmented Reality (AR) \ Virtual Reality (VR) device, and the like, and the embodiment of the present application does not particularly limit the specific form of the terminal device.
Please refer to fig. 2A, which is a schematic structural diagram of a Java virtual machine according to an embodiment of the present disclosure. As shown in fig. 2A, the Java virtual machine includes a class loading subsystem, runtime data, a garbage collection system, and an execution engine. Wherein, when the process is run in the Java virtual machine, different operations can be executed.
The operation module corresponding to the class loading subsystem may include: loading, linking, and verifying. Specifically, the class loading subsystem is used for loading class information from a file system or a network system, and storing the class information into a corresponding memory space.
The operation module corresponding to the runtime data may include: java heap, method area, thread stack, and native method heap. Specifically, when the Java virtual machine runs a process, the system allocates a certain memory area for the process. The size of the memory area can be set. And a Java virtual machine is used for managing the memory area, and a part of the Java virtual machine can be separated from the memory area for storing the operation data. Such as objects created, parameters passed to methods, local variables, return values, and the like. This part of the area that is dropped out may be referred to as a runtime data area.
The Java heap is established when the Java virtual machine is started, is used for storing Java object instances, and can share all threads. For example, after the main process creates the sub-process, a memory image is created for the main process in the sub-process, and the sub-process and the main process share threads. The method area is used for storing types, constant pool information in the running process, character size of character strings and the like.
For example, assume that a first application in the Android system runs in a Java virtual machine, if the first application has three processes in the Java virtual machine. Fig. 2B is a schematic structural diagram of an application running in the Java virtual machine. Process 1, process 2, and process 3 run in the Java virtual machine. Taking process 1 as an example, process 1 corresponds to Java virtual machine instance 1 in the Java virtual machine, and Java virtual machine instance 1 calls the Java local interface to run process 1 in the Java virtual machine local environment. It can be understood that the running of the processes is controlled by the system kernel, and the system kernel can know the current situation of the memory of the Java virtual machine occupied by each process in real time. For example, the system kernel may determine whether the host process satisfies a memory dump condition, and if the host process satisfies the memory dump condition, perform memory dump on the host process.
The operation module corresponding to the garbage recycling system can comprise: mark arrangement, concurrent duplication and generation. The garbage recycling system can recycle garbage space of the method area, the java heap and the like.
The operation module corresponding to the execution engine may include: interpretive execution, just-in-time compilation, pre-compilation, and the like. Wherein, the execution engine is one of the most core components of the java virtual machine and is responsible for executing the byte codes of the virtual machine.
Please refer to fig. 3, which is a flowchart illustrating a method for memory dump according to an embodiment of the present application. As shown in fig. 3, the method may include step 301 and step 302.
Step 301: and calling the main process to execute a preset task and judging whether the main process meets the memory dump condition. If the main process meets the memory dump condition, step 302 is executed, otherwise, step 301 is continuously executed.
That is to say, in the process of running the main process in the Java virtual machine, the system will always detect the state of the main process occupying the memory, and determine whether the main process meets the memory dump condition. And if the main process meets the memory dump condition, performing memory dump on the main process. If the main process does not meet the memory dump condition, the normal operation of the main process is ensured, and whether the main process needs to carry out the memory dump or not is judged.
It should be noted that the method in the embodiment of the present application may be applied to an electronic device. Specifically, a developer may use an electronic device to develop an application, and the electronic device may implement the memory dump method. Or, an application program is installed on the electronic device, and the electronic device may implement the above memory dump method. Here, taking the example that the system installed in the electronic device is the Android system, one or more processes corresponding to the application program may be in a Java virtual machine of the Android system.
The main process is a corresponding process when the application program runs in the Java virtual machine. The preset task is an action to be executed when the application program runs, for example, a display task, a data transmission task, a data calculation task, or the like.
In some embodiments, the condition for the main process to perform memory dump may include: the memory space occupied by the main process is larger than a preset memory threshold value, and memory leakage occurs when the main process operates, or insufficient memory occurs when the main process operates. That is, when the main process calls the memory of the Java virtual machine during the task execution process, the memory of the Java virtual machine occupied by the main process can be used for executing the memory dump when any of the above conditions is satisfied. For example, a main process in the Java virtual machine executes a preset task, and when the system detects that a memory space occupied by the main process is greater than a preset threshold, the system determines to perform memory dump.
It is understood that, taking the example of the developer developing the application program using the computer as an example, the developer may also set other conditions as the conditions for performing the memory dump by the main process. For example, the system may monitor whether the resources called by the host process cannot be released all the time, such as a memory overflow phenomenon. The specific requirement may be based on the development requirement of the application program, and is not specifically limited herein.
If the main process is determined not to meet the memory dump condition, the main process continues to execute the preset task, and meanwhile, the system monitors the state of the main process occupying the memory to judge whether the main process needs to perform memory dump or not. Or, when the main process in the Java virtual machine executes a preset task, the system may monitor the state of the main process occupying the memory all the time. And if the system detects that the state of the main process occupying the memory meets the memory dump condition, performing memory dump on the main process.
Step 302: and determining that the main process meets the memory dump condition, creating a subprocess, and calling the subprocess to perform memory dump on the main process.
In some embodiments, if it is determined that the main process meets the memory dump condition, the main process is suspended, a copy-on-write technique is adopted for the main process to create the sub-process, and the sub-process is called to perform the memory dump.
The copy-on-write technology is specifically implemented in such a way that a system kernel creates a sub-process for a main process, and the system kernel creates a virtual space structure for a newly created sub-process. The created sub-process can copy the false space structure of the main process, but the system kernel does not need to allocate physical memory for the sub-process, and the sub-process can share the physical space of the main process. Thus, the subprocess can directly copy the main process and perform memory dump on the main process.
It can be understood that, after the system creates the sub-process for the main process, the sub-process performs a memory dump for the main process to generate a memory image. In addition, in the process of memory dump by the sub-process as the main process, the main process can continue to execute the preset task.
In some embodiments, after the sub-process completes the memory dump to generate the memory image, the sub-process may send a notification to the main process that the memory dump was successful.
The exemplary implementation flow of the memory dump in the Java virtual machine is shown in fig. 4, which includes steps 401 to 406.
Step 401: and determining that the main process meets the memory dump condition.
The memory dump condition is already described in step 301, and reference may be specifically made to the above description related to the memory dump condition, which is not described herein again. It will be appreciated that the Java virtual machine may monitor the state of the host process at all times to determine that the host process satisfies the memory dump condition.
Step 402: and (4) suspending the main process of the virtual machine, and creating a subprogram for the main process by adopting a copy-on-write technology.
It will be appreciated that after the sub-program is created for the host process using copy-on-write techniques, the host process and sub-program are included in the Java virtual machine. The main process is implemented as step 403, and the subroutine is implemented as steps 404 and 405. Wherein, the subprogram and the main process can respectively execute the respective tasks.
The time of the main process pause is millisecond-level time, and no matter a developer develops an application program through the electronic equipment or runs the application program on the user equipment, the pause phenomenon cannot be generated.
For example, when the system determines that the host process satisfies the memory dump condition, the system may call a pause interface of the Java virtual machine to pause the host process. For example, the system may call a suspend (suspend vm) interface of a debugger (debugger) to suspend the host process.
After the main process is halted, the main process may be replicated (fork) to create sub-processes. That is, fork employs copy-on-write techniques. And the time of the fork main process is also the time of millisecond level, so that the sub process is created, the phenomenon of stagnation is not generated by the memory dump system through the sub process, and the user experience is not influenced.
The fork (or called derivation or branch) main process is to divide the main process into two identical processes by calling the fork function, and each process starts a thread starting at the same position.
Step 403: and restoring the preset task currently executed by the main process.
It will be appreciated that after the above-described creation of a sub-process for a main process fork, both the main process and the sub-process are based on threads starting at the same location. That is, after the sub-process is created, the main process may continue to execute the preset task, and the sub-process may execute the task of memory dump.
For example, the system may call an interface of the underlying Java virtual machine to resume the host process to continue executing the current predetermined task. For example, the system calls a resume (resumeVM) interface of the debugger (debug), and the host process may continue to perform the current preset task.
Step 404: the subprogram performs memory dump to the main process.
For example, the child process may call an android.os.debug.dump.hardware Hprof Data interface in the debug to perform memory dump, and store the memory of the host process in the Java virtual machine, so as to generate a memory image.
Step 405: the subprogram completes the memory dump, generates the memory mirror image, and informs the main process that the memory dump is completed.
The sub-process completes the memory dump and sends a notice of the completion of the memory dump to the main process. And the notice of memory dump completion is used for informing the main process that the memory image generation is completed.
Step 406: and the main process monitors the notice of memory dump completion and determines that the memory mirror image generation is completed.
And the main process receives the notice of the completion of the generation of the memory mirror image, determines that the generation of the memory mirror image is completed, and can continue to execute the preset task. It can be understood that if the memory mirror image is generated completely, system prompt information can be set to prompt the user that the memory mirror image is generated completely.
As can be appreciated, the master process can listen to the status of the child processes through interprocess communication. If the sub-process completes the memory dump, the main process may listen to the information generated by the memory dump file of the sub-process.
In the memory dump method provided by the embodiment of the application, when the main process meets the memory dump condition, the system can perform memory dump on the main process. Specifically, when the main process performs memory dump, a sub-process is created for the main process, and the sub-process is called to perform memory dump on the main process. That is, during the process of performing memory dump on the main process, the system may create a sub-process for the main process, and perform memory dump on the main process in the sub-process. Therefore, the main process is subjected to memory dump through the created sub-process, and the main process cannot be frozen in the process of memory dump, so that the normal work of the system cannot be influenced. In addition, in the process of memory dump of the main process in the subprocess, the main process can be executed in a journey, and the system can not generate the phenomenon of stagnation.
It is to be understood that the above-described method may be implemented by an electronic device. In order to implement the above functions, the electronic device includes a hardware structure and/or a software module for performing each function. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
In the embodiment of the present application, the electronic device and the like may be divided into functional modules according to the method example, for example, each functional module may be divided according to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. It should be noted that, in the embodiment of the present application, the division of the module is schematic, and is only one logic function division, and there may be another division manner in actual implementation.
In the case of dividing the functional modules according to the respective functions, fig. 5 shows a schematic diagram of a possible structure of the electronic device according to the above embodiment, and the audio file processing apparatus 500 includes: comprises a judging module 501, a creating module 502 and a calling module 503.
The determining module 501 is configured to invoke the main process to execute a preset task, and determine whether the main process meets a memory dump condition.
A creating module 502, configured to create a sub-process if the main process meets the memory dump condition, and invoke the sub-process to perform memory dump on the main process.
And the calling module 503 is configured to continue to call the main process to execute the preset task after the sub-process is created.
In a possible implementation manner, the creating module 502 is specifically configured to suspend the main process from executing the preset task if the main process meets the memory dump condition. And aiming at the main process, a copy-on-write technology is adopted, a subprocess is created, and the subprocess is called to carry out memory dump on the main process.
In another possible implementation, the determining module 501 is specifically configured to monitor the state of the sub-process through inter-process communication by the main process; the sub-process completes the memory dump, and the main process can monitor the information generated by the memory dump file of the sub-process.
In another possible implementation, the creating module 502 is further configured to send a notification that the memory dump is successful to the main process when the sub-process completes the memory dump, so as to trigger whether the main process meets the memory dump condition.
Of course, the electronic device 500 includes, but is not limited to, the above-listed unit modules. For example, the electronic device 500 may also include a storage module. The storage module may be configured to store that the main process satisfies a memory dump condition. Moreover, the functions that can be specifically realized by the functional units also include, but are not limited to, the functions corresponding to the method steps described in the foregoing examples, and the detailed description of the corresponding method steps may be referred to for the detailed description of other modules of the electronic device 500, which is not described herein again in this embodiment of the present application.
Fig. 6 shows a schematic diagram of a possible structure of the electronic device according to the above-described embodiment, in the case of an integrated unit. As shown in fig. 6, the electronic device 500 includes a processor 601 and a memory 602.
Among other things, processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on. The processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a memory, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. The different processing units may be separate devices or may be integrated into one or more processors.
The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in the memory 602 is used to store at least one instruction for execution by the processor 601 to implement the method of processing an audio file provided by the method embodiments of the present application.
In some embodiments, the electronic device 500 may further optionally include: a peripheral interface 603 and at least one peripheral. The processor 601, memory 602, and peripheral interface 603 may be connected by buses or signal lines. Various peripheral devices may be connected to the peripheral interface 603 via a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 604, a display 605, a camera assembly 606, an audio circuit 607, a positioning component 608, and a power supply 609.
The peripheral interface 603 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 601 and the memory 602. In some embodiments, the processor 601, memory 602, and peripheral interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral interface 603 may be implemented on separate chips or circuit boards, which is not limited in this embodiment.
The Radio Frequency circuit 604 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 604 communicates with communication networks and other communication devices via electromagnetic signals. The rf circuit 604 converts an electrical signal into an electromagnetic signal to transmit, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 604 comprises: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuitry 604 may communicate with other electronic devices via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: metropolitan area networks, various generations of mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or Wi-Fi (Wireless Fidelity) networks. In some embodiments, the radio frequency circuit 404 may also include NFC (Near Field Communication) related circuits, which are not limited by this disclosure.
The display 605 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 605 is a touch display screen, the display screen 605 also has the ability to capture touch signals on or over the surface of the display screen 605. The touch signal may be input to the processor 601 as a control signal for processing. At this point, the display 605 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display 605 may be one, providing the front panel of the electronic device 500; the Display 605 may be made of LCD (Liquid Crystal Display), OLED (Organic Light-emitting diode), and the like.
The camera assembly 606 is used to capture images or video. Optionally, camera assembly 606 includes a front camera and a rear camera. Generally, a front camera is disposed on a front panel of an electronic apparatus, and a rear camera is disposed on a rear surface of the electronic apparatus. Audio circuitry 607 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 601 for processing or inputting the electric signals to the radio frequency circuit 604 to realize voice communication. For stereo capture or noise reduction purposes, the microphones may be multiple and disposed at different locations of the electronic device 500. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is used to convert electrical signals from the processor 601 or the radio frequency circuit 604 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, audio circuitry 607 may also include a headphone jack.
The positioning component 608 is used to locate a current geographic location of the electronic device 500 to implement navigation or LBS (location based Service). The positioning component 608 can be a positioning component based on the GPS (global positioning System) in the united states, the beidou System in china, the graves System in russia, or the galileo System in the european union.
The power supply 609 is used to supply power to various components in the electronic device 500. The power supply 609 may be ac, dc, disposable or rechargeable. When the power supply 609 includes a rechargeable battery, the rechargeable battery may support wired or wireless charging. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, the electronic device 500 also includes one or more sensors 610. The one or more sensors 610 include, but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, fingerprint sensors, optical sensors, and proximity sensors.
The acceleration sensor may detect acceleration magnitudes on three coordinate axes of a coordinate system established with the electronic device 500. The gyro sensor can detect the body direction and the rotation angle of the electronic device 500, and the gyro sensor can cooperate with the acceleration sensor to acquire the 3D motion of the user to the electronic device 500. The pressure sensors may be disposed on the side bezel of the electronic device 500 and/or underlying the display screen 605. When the pressure sensor is disposed on the side frame of the electronic device 500, a user's holding signal of the electronic device 500 may be detected. The fingerprint sensor is used for collecting fingerprints of users. The optical sensor is used for collecting the intensity of ambient light. Proximity sensors, also known as distance sensors, are typically provided on the front panel of the electronic device 500. The proximity sensor is used to capture the distance between the user and the front of the electronic device 500.
Those skilled in the art will appreciate that the configuration shown in fig. 6 is not intended to be limiting of the electronic device 500 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
Embodiments of the present application further provide a computer storage medium, where the computer storage medium includes computer instructions, and when the computer instructions are run on the electronic device, the electronic device is caused to perform various functions or steps in the foregoing method embodiments. For example, the computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a Compact Disc Read-Only Memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
Embodiments of the present application further provide a computer program product, which when run on a computer, causes the computer to execute the functions or steps of the above method embodiments.
Through the description of the above embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, a module or a unit may be divided into only one logic function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another apparatus, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed to a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or partially contributed to by the prior art, or all or part of the technical solutions may be embodied in the form of a software product, where the software product is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for memory dumping, comprising:
calling a main process to execute a preset task, and judging whether the main process meets a memory dump condition;
and if the main process meets the memory dump condition, creating a sub-process, and calling the sub-process to perform memory dump on the main process.
2. The method according to claim 1, wherein if the main process satisfies the memory dump condition, creating a sub-process, and invoking the sub-process to perform memory dump on the main process, includes:
if the main process meets the memory dump condition, suspending the main process from executing the preset task;
and aiming at the main process, adopting a copy-on-write technology, creating the sub-process, and calling the sub-process to perform the memory dump on the main process.
3. The method of claim 2, wherein after creating the sub-process if the main process satisfies the memory dump condition, the method further comprises:
and continuing to call the main process to execute the preset task.
4. The method of any of claims 1-3, wherein after the invoking the sub-process to perform a memory dump on the main process, the method further comprises:
the main process monitors the state of the sub-process through interprocess communication;
and the sub-process completes the memory dump, and the main process monitors the information generated by the memory dump file of the sub-process.
5. The method according to any one of claims 1-3, wherein the main process satisfying the memory dump condition comprises:
the memory space occupied by the main process is larger than a preset memory threshold value, the memory leakage occurs when the main process operates, and the memory shortage occurs when the main process operates.
6. A memory dump device, comprising:
the judging module is used for calling a main process to execute a preset task and judging whether the main process meets a memory dump condition;
and the creating module is used for creating a subprocess and calling the subprocess to perform memory dump on the main process if the main process meets the memory dump condition.
7. The apparatus of claim 6, wherein the creating module is configured to create a sub-process if the main process meets the memory dump condition, and call the sub-process to perform a memory dump on the main process, and includes:
the creating module is specifically configured to suspend the host process from executing the preset task if the host process meets the memory dump condition; and aiming at the main process, adopting a copy-on-write technology, creating the sub-process, and calling the sub-process to perform the memory dump on the main process.
8. The apparatus of claim 7, further comprising a calling module;
and the calling module is used for continuously calling the main process to execute the preset task.
9. An electronic device, comprising: a processor; and a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the method of any one of claims 1-5.
10. A computer-readable storage medium having computer instructions stored thereon, the computer instructions, when executed on an electronic device, implementing the method of any of claims 1-5.
CN202010388017.4A 2020-05-09 2020-05-09 Memory dump method and device and electronic equipment Active CN111638952B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010388017.4A CN111638952B (en) 2020-05-09 2020-05-09 Memory dump method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010388017.4A CN111638952B (en) 2020-05-09 2020-05-09 Memory dump method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN111638952A true CN111638952A (en) 2020-09-08
CN111638952B CN111638952B (en) 2024-08-06

Family

ID=72333180

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010388017.4A Active CN111638952B (en) 2020-05-09 2020-05-09 Memory dump method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN111638952B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698788A (en) * 2020-12-29 2021-04-23 湖南博匠信息科技有限公司 Embedded high-speed dump method and system
CN112835813A (en) * 2021-03-04 2021-05-25 腾讯音乐娱乐科技(深圳)有限公司 Method for processing repeated pictures in memory, electronic equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105989160A (en) * 2015-03-03 2016-10-05 大唐软件技术股份有限公司 Memory data persistence method and apparatus for Redis database
CN107085548A (en) * 2016-02-16 2017-08-22 阿里巴巴集团控股有限公司 A kind of method, device and electronic equipment for monitoring application program internal memory
CN107479980A (en) * 2016-06-08 2017-12-15 阿里巴巴集团控股有限公司 A kind of method and apparatus for detecting deadlock in application
CN108073452A (en) * 2016-11-10 2018-05-25 阿里巴巴集团控股有限公司 Runtime environment processing method, device and the equipment of a kind of dynamic language
US10101910B1 (en) * 2015-09-15 2018-10-16 Amazon Technologies, Inc. Adaptive maximum limit for out-of-memory-protected web browser processes on systems using a low memory manager
CN109165098A (en) * 2018-08-23 2019-01-08 新华三大数据技术有限公司 Spidering process communication means and device based on python
CN110083450A (en) * 2019-04-09 2019-08-02 Oppo广东移动通信有限公司 Method for recovering internal storage, device, electronic equipment and storage medium
CN110413386A (en) * 2019-06-27 2019-11-05 深圳市富途网络科技有限公司 Multiprocessing method, apparatus, terminal device and computer readable storage medium
US20190347132A1 (en) * 2018-05-08 2019-11-14 International Business Machines Corporation Intelligent memory management through peer learning
CN110515774A (en) * 2019-08-28 2019-11-29 北京百度网讯科技有限公司 Generation method, device, electronic equipment and the storage medium of memory image
CN111090536A (en) * 2019-11-19 2020-05-01 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring memory leakage information

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105989160A (en) * 2015-03-03 2016-10-05 大唐软件技术股份有限公司 Memory data persistence method and apparatus for Redis database
US10101910B1 (en) * 2015-09-15 2018-10-16 Amazon Technologies, Inc. Adaptive maximum limit for out-of-memory-protected web browser processes on systems using a low memory manager
CN107085548A (en) * 2016-02-16 2017-08-22 阿里巴巴集团控股有限公司 A kind of method, device and electronic equipment for monitoring application program internal memory
CN107479980A (en) * 2016-06-08 2017-12-15 阿里巴巴集团控股有限公司 A kind of method and apparatus for detecting deadlock in application
CN108073452A (en) * 2016-11-10 2018-05-25 阿里巴巴集团控股有限公司 Runtime environment processing method, device and the equipment of a kind of dynamic language
US20190347132A1 (en) * 2018-05-08 2019-11-14 International Business Machines Corporation Intelligent memory management through peer learning
CN109165098A (en) * 2018-08-23 2019-01-08 新华三大数据技术有限公司 Spidering process communication means and device based on python
CN110083450A (en) * 2019-04-09 2019-08-02 Oppo广东移动通信有限公司 Method for recovering internal storage, device, electronic equipment and storage medium
CN110413386A (en) * 2019-06-27 2019-11-05 深圳市富途网络科技有限公司 Multiprocessing method, apparatus, terminal device and computer readable storage medium
CN110515774A (en) * 2019-08-28 2019-11-29 北京百度网讯科技有限公司 Generation method, device, electronic equipment and the storage medium of memory image
CN111090536A (en) * 2019-11-19 2020-05-01 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring memory leakage information

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698788A (en) * 2020-12-29 2021-04-23 湖南博匠信息科技有限公司 Embedded high-speed dump method and system
CN112698788B (en) * 2020-12-29 2022-12-09 湖南博匠信息科技有限公司 Embedded high-speed dump method and system
CN112835813A (en) * 2021-03-04 2021-05-25 腾讯音乐娱乐科技(深圳)有限公司 Method for processing repeated pictures in memory, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111638952B (en) 2024-08-06

Similar Documents

Publication Publication Date Title
WO2019085658A1 (en) Method for resource allocation and terminal device
WO2022199111A1 (en) Method and apparatus for implementing functions in application program, electronic device and storage medium
US9021436B2 (en) Automatic reconnection of debugger to a reactivated application
EP2864869B1 (en) Api redirection for limited capability operating systems
CN111191224B (en) Countermeasure method and device for virtual machine detection and computer readable storage medium
KR102193404B1 (en) Incrementally compiling software artifacts from an interactive development environment
CN111416756B (en) Protocol testing method, device, computer equipment and storage medium
CN110633190B (en) Application program memory monitoring method, device, equipment and storage medium
CN111638952B (en) Memory dump method and device and electronic equipment
CN113867848A (en) Method, device and equipment for calling graphic interface and readable storage medium
CN115114071A (en) Memory analysis method, device, equipment and medium
CN112035153B (en) Application updating method, device, terminal and storage medium
CN114064450A (en) Application program testing method and device, electronic equipment and storage medium
CN110995842A (en) Method, device and equipment for downloading service data and storage medium
CN110765085A (en) Log information writing method, system, storage medium and mobile terminal
CA2966157A1 (en) Monitoring a mobile device application
CN107861827B (en) Card screen detection method, mobile terminal and computer readable storage medium
US10599444B2 (en) Extensible input stack for processing input device data
CN111722903A (en) Data processing method and device, electronic equipment and storage medium
CN108132817B (en) Object management method and device
EP4354293A1 (en) Detection method and apparatus, and electronic device
WO2019139738A1 (en) Extensible input stack for processing input device data
CN116450473A (en) Method for positioning memory stepping problem and electronic equipment
CN113392120A (en) Method and device for acquiring execution information of SQLite
CN111984541A (en) Memory leak detection method and device and terminal

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