Memory data acquisition method and device, vehicle-mounted equipment and vehicle

By creating a child process in the target program of the vehicle device, the child process traversing and generating memory files, the problem of application operation interruption when obtaining memory data in the prior art is solved, and the user experience is improved.

CN119862035APending Publication Date: 2025-04-22GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411940807.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-04-22

AI Technical Summary

Technical Problem

In the prior art, when obtaining the memory data of the application, it is necessary to stop running the application, resulting in the application being unable to respond to user operations and affecting the user experience.

Method used

By creating a child process in the main process of the target program, the child process runs based on the memory data stored in the first memory space by the main process, and iterates over the memory data in the target area in the second memory space, and generates the memory file of the target program.

Benefits of technology

It realizes that the application does not affect the normal operation of the application when obtaining memory data, improves the continuity and process of the application, and thus improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862035A_ABST
    Figure CN119862035A_ABST
Patent Text Reader

Abstract

The embodiment of the invention is suitable for the technical field of computers, and provides a memory data acquisition method and device, vehicle-mounted equipment and a vehicle. The method comprises the steps that under the condition that any target program meets a data acquisition condition, a sub-process is created based on a main process of the target program; the sub-process is operated based on memory data stored in a first memory space by the host process; traversing memory data of a second memory space in a target area through the sub-process, and generating a memory file corresponding to the target program; the target region is a region for storing memory data of a preset type in a second memory space; the second memory space is the same space as the first memory space, or a third memory space used for storing memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space. According to the method provided by the embodiment of the invention, the vehicle-mounted equipment can generate the memory file corresponding to the target program through the sub-process, so that when the memory file is generated, the host process can continue to respond to the user operation, and the use experience of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application belong to the field of computer technology, and in particular, relate to a method and device for acquiring memory data, a vehicle-mounted device, and a vehicle. Background Art

[0002] With the development of intelligent cockpit systems of automobiles, more and more applications are running in intelligent cockpit systems. In order to solve the failure problems that occur during the operation of applications (such as crashes, exceptions, memory leaks, freezes, etc.), technicians need to obtain the memory data of the application when it is running to optimize the above failure problems. In the prior art, when obtaining memory data, the vehicle-mounted device usually needs to suspend the application first, and then obtain the memory data of the application from the memory space used to run the application, and then re-run the application after the memory data is obtained. That is, obtaining memory data will cause the operation of the application to be interrupted. It can be seen that the prior art needs to stop running the application when obtaining the memory data of the application, resulting in the inability of the application to respond to user operations during the process of obtaining memory data, affecting the continuity and process of the user's use of the application, thereby reducing the user's experience. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a memory data acquisition method, device, vehicle-mounted equipment and vehicle, so that when the vehicle-mounted equipment generates a memory file of a target program, the main process can continue to respond to user operations, thereby improving the continuity and flow of the target program, and thereby improving the user experience.

[0004] A first aspect of an embodiment of the present application provides a method for acquiring memory data, comprising:

[0005] In the case where any target program meets the data acquisition condition, a subprocess is created based on the main process of the target program; the subprocess is run based on the memory data stored in the first memory space by the main process;

[0006] The subprocess traverses the memory data in the target area of ​​the second memory space to generate a memory file corresponding to the target program; the target area is an area in the second memory space that stores memory data of a preset type; the second memory space is the same space as the first memory space, or is a third memory space for storing memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space.

[0007] In a possible implementation manner of the first aspect, traversing the target data of the memory data in the target area by the subprocess to generate a memory file corresponding to the target program includes:

[0008] For any area in the second memory space, if the area is not a preload area and is not a mirror area, the area is identified as the target area, and the memory data in the target area is traversed by the child process to obtain the target data corresponding to the target area; the target data is used to generate the memory file; the preload area is an area in the second memory space that stores preload data; the mirror area is an area in the second memory space that stores mirror data of the class.

[0009] In a possible implementation manner of the first aspect, traversing the memory data in the target area by the subprocess to obtain target data corresponding to the target area includes:

[0010] In the process of traversing the memory data in the target area through the sub-process, for any memory data in the target area, if the data type of the any memory data does not meet the preset clipping condition, identifying the any memory data as the target data;

[0011] All the target data in the second memory space are read by the subprocess to generate a memory file corresponding to the target program.

[0012] In a possible implementation manner of the first aspect, the clipping condition includes at least one of the following:

[0013] The data type of any memory data is byte type;

[0014] The data type of any memory data is integer;

[0015] The data type of any memory data is short integer;

[0016] The data type of any memory data is a long integer;

[0017] The data type of any memory data is single-precision floating point type;

[0018] The data type of any memory data is double-precision floating point type;

[0019] The data type of any memory data is a character type;

[0020] The data type of any memory data is Boolean type.

[0021] In a possible implementation of the first aspect, the target area includes a young generation area, an old generation area and a survivor area; the young generation area is an area in the second memory space for allocating memory data; the survivor area is an area in the second memory space for temporarily storing memory data; the old generation area is an area in the second memory space for storing memory data whose effective duration is greater than a preset duration threshold.

[0022] In a possible implementation manner of the first aspect, when any target program meets the data acquisition condition, after creating a subprocess based on a main process of the target program, the method includes:

[0023] Creating a memory mapping relationship between the first memory space and the third memory space of the child process through a kernel interface corresponding to the target program;

[0024] Correspondingly, traversing the memory data of the second memory space in the target area by the subprocess to generate a memory file corresponding to the target program includes:

[0025] If the main process does not perform a data write operation on the first memory space, the sub-process traverses the memory data of the first memory space in the target area based on the memory mapping relationship to generate a memory file corresponding to the target program.

[0026] In a possible implementation manner of the first aspect, after creating a memory mapping relationship between the first memory space and the third memory space of the child process through the kernel interface corresponding to the target program, the method includes:

[0027] If the main process performs a data write operation on the first memory space, all memory data in the first memory space that meets the data acquisition condition is copied to the third memory space through the kernel interface;

[0028] Correspondingly, traversing the memory data of the second memory space in the target area by the subprocess to generate a memory file corresponding to the target program includes:

[0029] The memory data of the third memory space in the target area is traversed by the subprocess to generate a memory file corresponding to the target program.

[0030] A second aspect of an embodiment of the present application provides a memory data acquisition device, including:

[0031] A sub-process creation module, used for creating a sub-process based on the main process of any target program when the target program meets the data acquisition condition; the sub-process is run based on the memory data stored in the first memory space by the main process;

[0032] A memory file generation module, used to traverse the memory data in the target area of ​​the second memory space through the sub-process to generate a memory file corresponding to the target program; the target area is an area in the second memory space that stores memory data of a preset type; the second memory space is the same space as the first memory space, or a third memory space for storing memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space.

[0033] A third aspect of an embodiment of the present application provides a vehicle-mounted device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the memory data acquisition method as described in the first aspect above is implemented.

[0034] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the memory data acquisition method as described in the first aspect above is implemented.

[0035] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the memory data acquisition method described in the first aspect.

[0036] A fifth aspect of an embodiment of the present application provides a vehicle including an on-board device, wherein the on-board device is used to execute the memory data acquisition method as described in the first aspect above.

[0037] Compared with the prior art, the embodiments of the present application have the following advantages:

[0038] In an embodiment of the present application, when any target program meets the data acquisition conditions, the vehicle-mounted device can create a corresponding sub-process through the main process of the target program, and the sub-process is run based on the memory data stored in the first memory space by the main process, that is, the two programs can use the same memory data, and there is no need to occupy additional memory space to maintain the operation of the sub-process; wherein, the main program can be used to maintain the normal operation of the target program, and the sub-program can traverse the memory data in the target area of ​​the second memory space, so that the purpose of generating a memory file while running the normal operation of the target program can be achieved. It can be seen that compared with the existing memory file generation technology, the method provided by this embodiment can achieve the acquisition requirements of the memory file without affecting the continuity of the operation of the target application, and the main process and the sub-process can share the same memory space to maintain the process operation, without occupying additional memory space, thereby improving the utilization of the memory space. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0040] Figure 1 is a schematic diagram of a memory space provided in an embodiment of the present application;

[0041] Figure 2 It is a schematic diagram of the existing memory data acquisition process;

[0042] Figure 3 It is a schematic diagram of a method for acquiring memory data provided in an embodiment of the present application;

[0043] Figure 4 is a schematic diagram of another memory data acquisition method provided in an embodiment of the present application;

[0044] Figure 5 It is a structural schematic diagram of a heap data area provided in an embodiment of the present application;

[0045] Figure 6 is a schematic diagram of a memory file provided in an embodiment of the present application;

[0046] Figure 7 is a schematic diagram of a memory data acquisition device provided in an embodiment of the present application;

[0047] Figure 8 It is a schematic diagram of a vehicle-mounted device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In the following description, specific details such as specific system structures, technologies, etc. are proposed for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application.

[0049] The computer's memory space is a temporary data storage area in the computer, which is used to support the operation of applications. With the development of application development technology, applications have more and more functions. In order to ensure the independence of each function, different functions of the application can be implemented through different program modules. During the operation of the application, in order to enable the application to provide users with multiple functions at the same time and to achieve fault isolation of each function during operation, the computer can create different processes for different program modules and allocate a memory space for each created process to support the operation of the process.

[0050] See also Figure 1 , shows a schematic diagram of a memory space provided by an embodiment of the present application. Figure 1 As shown in the figure, the memory space of any process is mainly composed of two areas: the shared data area and the private data area. Among them, the memory data in the shared data area can be shared by different processes to achieve efficient communication and data sharing between processes. The shared data area mainly includes the method area (Method Area) and the heap data area (Heap Area). Among them, the method area is mainly used to store data such as class information, constants, static variables, and code compiled by the just-in-time compiler loaded by the virtual machine. The heap data area is mainly used to store object instance data, and the creation and destruction of object instance data are all performed in the heap data area.

[0051] The memory data in the private data area cannot be shared between processes. The private data area mainly consists of the stack data area (Stack Area), the program counter area (Program Counter Area) and the native method stack area (Native Method Stack Area). Among them, the stack data area is mainly used to store the data generated by the function call when the process implements a certain program module function. For example, when the process needs to call the function func (int a, int b), the value of parameter a in the function func, the value of parameter b, and the local variables defined inside the function func and other data will be stored in the stack data area in the form of stack data. The program counter area is mainly used to store the address of the bytecode instruction being executed by the current process. The native method stack area is similar to the stack area, but the native method stack area is mainly used to support the call of native methods (Native Method). Native methods refer to methods written in non-Java languages ​​(such as C or C++). Native methods are usually written by developers to enable applications to access underlying system resources or to improve application performance.

[0052] See also Figure 2 , shows a schematic diagram of the existing memory data acquisition process. Figure 2As shown, during the running process of the application, the operating system in the vehicle-mounted device can continuously monitor whether the application meets the data acquisition condition. When the operating system determines that the current application meets the data acquisition condition, the operating system can initiate a data acquisition instruction to the process running the application. After receiving the data acquisition instruction, the process can respond to the data acquisition instruction, stop executing the data recovery operation and suspend the process, that is, the process can respond to the data acquisition instruction of the operating system from the running state to the static state to ensure that the memory data stored in the memory space of the process can accurately reflect the real state of the application when the data acquisition condition is met. At this time, the operating system can call the data reading tool pre-set by the R&D personnel to traverse and read the memory data in the memory space of the process to generate a memory file corresponding to the application. Specifically, the data reading tool can obtain at least one memory data of the process during the execution process by calling at least one data writing node of the process during the execution process. After generating the memory file, the operating system can restore the normal operation of the process, that is, the operating system can switch the process from the static state to the running state so that the process can continue to execute the application and respond to user operations.

[0053] Among them, during the period when the operating system traverses the memory data through the data reading tool, since the process is in a static state, the page of the application on the display device at this time can remain stuck at the page when the data acquisition condition is met, or the page of the application on the display device can be in a gray screen state, that is, the application cannot respond to user operations at this time. It can be seen that in the prior art, when the vehicle-mounted device obtains the memory data of a process, it usually needs to pause the process first, and then obtain the memory data corresponding to the process from the memory space corresponding to the process, and then re-run the process after the memory data is obtained. That is, obtaining the memory data will cause the operation of the process to be interrupted, thereby causing the application to be unable to respond to user operations.

[0054] In order to solve the problem that obtaining memory data in the prior art may cause the interruption of process operation, an embodiment of the present application provides a method for obtaining memory data. The implementation process of the embodiment of the present application is described below.

[0055] Reference Figure 3 , showing a schematic diagram of a memory data acquisition method provided by an embodiment of the present application. The method can be applied to any vehicle-mounted device equipped with an intelligent cockpit system. The method can be used as a basic function in the intelligent cockpit system, that is, the method can be integrated in the intelligent cockpit system to monitor the memory data of the application in the vehicle-mounted device equipped with the intelligent cockpit system in real time. The above-mentioned memory data acquisition method can specifically include the following steps:

[0056] S301. When any target program meets the data acquisition condition, a subprocess is created based on the main process of the target program.

[0057] In this embodiment, when a developer needs to obtain a memory file corresponding to a target program, the developer can first set the corresponding data acquisition condition according to the data analysis requirements of the target program. The target program can be any application program in the vehicle-mounted device whose memory data needs to be obtained. Specifically, during the operation of the target program, the vehicle-mounted device can continuously monitor whether each main process in the target program meets the data acquisition condition. The main process can be a process in the vehicle-mounted device for executing at least one program module in the target program. When the vehicle-mounted device determines that any main process corresponding to the target program meets the data acquisition condition, that is, when the target program meets the data acquisition condition, the vehicle-mounted device can create a sub-process corresponding to the main process of the current data acquisition condition. The sub-process created by the vehicle-mounted device can be based on the memory data stored in the first memory space of the main process. The first memory space can be the memory space allocated to the main process by the vehicle-mounted device when creating the main process to support the operation of the main process. For any main process of the target program, if the vehicle-mounted device determines that the main process does not meet the data acquisition condition, the vehicle-mounted terminal may not create a sub-process and continue to monitor whether the main process meets the data acquisition condition.

[0058] In a possible implementation, when there are multiple parallel main processes in the target program, multiple main processes may meet the data acquisition conditions at the same time. At this time, in order to ensure the smoothness of each main process creating a sub-process and to ensure data consistency, when the vehicle-mounted device determines that any main process corresponding to the target program meets the data acquisition conditions, the main process that meets the data acquisition conditions can be suspended first, and a sub-process can be created based on the main process. After the sub-process is created, the vehicle-mounted device can resume the operation of the main process corresponding to the sub-process, and continue to execute its corresponding program module through the main process, so that the target program can continue to respond to user operations. Among them, since the time required for the vehicle-mounted device to create a sub-process is much less than the time to traverse the memory data, the method provided in this embodiment can ensure the feasibility of the vehicle-mounted device creating a sub-process while ensuring data consistency and the smoothness of the main process operation.

[0059] In a possible implementation, the data acquisition condition corresponding to the target program may include an abnormal acquisition condition. Specifically, during the operation of any main process of the target program, the vehicle-mounted device may continuously monitor whether each main process is in a stuck state or a crash state. When the vehicle-mounted device detects that any main process corresponding to the target program is in a stuck state or a crash state, the vehicle-mounted device may determine that the main process meets the abnormal acquisition condition in the data acquisition condition. Specifically, when the vehicle-mounted device detects that a main process sends a crash signal, the vehicle-mounted device may determine that the main process is currently in a crash state. When the vehicle-mounted device detects that the response time of a main process is greater than a preset response threshold, the vehicle-mounted device may determine that the main process is currently in a stuck state. At this time, the vehicle-mounted device may create a sub-process corresponding to the main process to generate a memory file corresponding to the target application through the sub-process. If the vehicle-mounted device does not detect that the main process is stuck or crashed, the vehicle-mounted device may continue to run the main process and continuously monitor whether the main process meets the data acquisition condition.

[0060] In a possible implementation, the data acquisition condition corresponding to the target program may also include a periodic acquisition condition. Specifically, during the operation of any main process of the target program, the vehicle-mounted device may periodically create a sub-process corresponding to the main process according to the acquisition period in the periodic acquisition condition, so as to periodically acquire the memory file corresponding to the target program through the sub-process.

[0061] S302: traverse the memory data in the target area of ​​the second memory space through a child process to generate a memory file corresponding to the target program.

[0062] In this embodiment, after the vehicle-mounted device creates a subprocess, it can traverse the memory data in the target area of ​​the second memory space through the subprocess, and generate a memory file corresponding to the target program through the subprocess. Specifically, after the vehicle-mounted device creates a subprocess, it can first determine the target area in the second memory space through the subprocess. Then, the memory data in the target area is traversed through the subprocess to generate a memory file corresponding to the target program. Since the subprocess may occupy a certain memory space of the vehicle-mounted device, after the subprocess generates the memory file corresponding to the target program, the vehicle-mounted device can delete the subprocess to improve the memory utilization of the vehicle-mounted device. Because after the vehicle-mounted device creates a subprocess, it can realize the concurrent execution of multiple processes and independently manage the status of each process through the process management mechanism. In addition, the subprocess created by the vehicle-mounted device has an independent execution path, that is, the subprocess and the main process are two independent processes that do not affect each other. Therefore, after the vehicle-mounted device creates a subprocess, the vehicle-mounted device can continue to execute its corresponding program module through the main process so that the target program can continue to respond to user operations.

[0063] Specifically, the target area traversed by the sub-process may be an area in the second memory space storing memory data of a preset type. The second memory space may be the same space as the first memory space of the main process, or a third memory space for storing memory data stored in the first memory space when the data acquisition condition is met. The third memory space may be a memory space different from the first memory space. Specifically, the third memory space may be a memory space allocated to the sub-process by the vehicle-mounted device when the sub-process is created, for supporting the operation of the sub-process.

[0064] Through the method provided in this embodiment, since the vehicle-mounted device can create a sub-process based on the main process when determining that the target program meets the data acquisition condition, and generate a memory file of the target program at the moment when the data acquisition condition is met through the sub-process. Through the method provided in this embodiment, since the vehicle-mounted device can generate a memory file through the sub-process, the method provided in this embodiment allows the main process to continue running the application while the sub-process is generating the memory file, so that the application can still respond to user operations during the process of generating the memory file, thereby improving the continuity and process of the user's use of the application, and improving the user's use experience.

[0065] In a possible implementation, after creating a child process, the vehicle-mounted device can first create a memory mapping relationship between the first memory space and the third memory space of the child process through the kernel interface corresponding to the target program that currently meets the data acquisition condition. At this time, since the child process can access the first memory space through the memory mapping relationship and traverse the memory data in the first memory space, in this case, the second memory space can be the same space as the first memory space of the main process. Among them, the kernel interface is a dedicated interface for bidirectional data transmission between the kernel layer of the operating system and the application. Through the kernel interface, the child process can access the address mapping relationship between the virtual address and the physical memory address of the application, that is, through the kernel interface, the child process can know the virtual address space range of the application and the corresponding physical memory location. Therefore, the child process can gradually access each address in the memory space corresponding to the target program through the kernel interface according to the preset rules, thereby realizing the traversal of the memory data corresponding to the target program. Then, the vehicle-mounted device can continuously determine whether the main process in the running state performs a data write operation on the first memory space. If the vehicle-mounted device determines that the main process in the running state does not perform a data write operation on the first memory space, the sub-process can traverse the memory data of the first memory space in the target area through the memory mapping relationship to generate a memory file corresponding to the target program based on the memory data in all target areas.

[0066] If the vehicle-mounted device detects that the main process in the running state performs a data write operation on the first memory space, then at this time, the vehicle-mounted device can copy all memory data in the first memory space that meets the data acquisition condition to the third memory space corresponding to the child process through the kernel interface corresponding to the target program. Then, the vehicle-mounted device can traverse the memory data in the target area of ​​the third memory space through the child process, and generate a memory file corresponding to the target program based on the memory data in all target areas in the third memory space.

[0067] Since the time when the main process executes the data write operation during the running process is not fixed, but depends on the user's operation behavior during the running of the main process, in view of this, in an embodiment of the present application, the specific implementation method of the sub-process traversing the memory data in the target area of ​​the second memory space can be divided into three cases.

[0068] Case 1: From the creation of the child process to the generation of the memory file by the child process, the main process does not perform data writing operations on the first memory space. In this case, the second memory space can be the same space as the first memory space of the main process. That is, in this case, the child process can continue to traverse the memory data of the first memory space in the target area through the memory mapping relationship to generate a memory file corresponding to the target program according to the memory data in all target areas of the first memory space.

[0069] Case 2: After the vehicle-mounted device creates a child process, before the child process traverses the memory data in the target area, the main process has already performed a data write operation on the first memory space. In this case, before the child process traverses the memory data in the target area, the vehicle-mounted device has copied all the memory data in the first memory space that meets the data acquisition conditions to the third memory space corresponding to the child process through the kernel interface corresponding to the target program. Therefore, in this case, the child process can traverse the memory data in the target area of ​​the third memory space, and generate a memory file corresponding to the target program based on the memory data in all the target areas in the third memory space.

[0070] Case three, during the process of the sub-process traversing the memory data, the main process performs a data write operation on the first memory space. In this case, before the main process performs the data write operation, the sub-process can traverse the memory data in the target area of ​​the first memory space one by one through the memory mapping relationship. When the main process performs the data write operation on the first memory space, the vehicle-mounted device can suspend the traversal operation of the sub-process and record the data position of the memory data currently traversed by the sub-process. Then, the vehicle-mounted device can copy all the memory data in the first memory space that meets the data acquisition conditions to the third memory space corresponding to the sub-process according to the kernel interface corresponding to the target application. After the vehicle-mounted device copies the memory data in the first memory space to the third memory space, it can continue to traverse the target area in the third memory space according to the recorded data position, and generate a memory file corresponding to the target program according to all the memory data traversed by the sub-process in the first memory space and the third memory space.

[0071] Through the method provided by this embodiment, when the main process needs to perform a data write operation on the first memory space, the vehicle-mounted device can save the memory data when the first memory space meets the data acquisition condition to the third memory space corresponding to the child process. Therefore, the method provided by this embodiment can make the memory file generated by the child process conform to the memory state of the first memory space when the data acquisition condition is met without affecting the normal operation of the main process.

[0072] In addition, since the memory file generation method provided in this embodiment is a method applied to the intelligent cockpit system, and since most of the existing intelligent cockpit systems are systems developed by automobile companies themselves, this method can be configured as a bottom-level function in the intelligent cockpit system. In view of this, in the process of generating a memory file, the subprocess can directly traverse the memory data corresponding to the target program through the kernel interface of the target program, without having to access the memory data corresponding to the target program by hooking the file write node. Furthermore, since the subprocess traverses the memory data through the kernel interface, the memory management mechanism of the operating system, such as memory mapping, page table, etc., can be fully utilized. Thus, the subprocess can be directly traversed according to the physical layout and mapping relationship of the memory, while traversing the memory data through the file write node will not only result in unnecessary disk input / output operations, but also require additional data format conversion operations. Therefore, the method provided in this embodiment can improve the efficiency of the subprocess traversing memory data and reduce the time required for the subprocess to generate a memory file.

[0073] Figure 4 FIG. 4 shows a specific implementation flow chart of a method S302 for acquiring memory data provided in the second embodiment of the present application. Figure 4 , compared to Figure 3In the embodiment, in a method for acquiring memory data provided in this embodiment, S302 includes: S3021-S3022, which are described in detail as follows:

[0074] S3021. For any area in the second memory space, if any area is not a preload area and is not a mirror area, the area is identified as a target area, and the memory data in the target area is traversed through a child process to obtain target data corresponding to the target area.

[0075] In this embodiment, after creating a sub-process, the vehicle-mounted device can filter each area in the second memory space through the sub-process to identify all target areas from the second memory space. After the vehicle-mounted device determines all target areas in the second memory space through the sub-process, the memory data in each target area can be traversed in sequence through the sub-process to obtain the memory data corresponding to each target area, and generate a memory file corresponding to the target application according to the memory data of all target areas in the second memory space. Specifically, for any area in the second memory space, the vehicle-mounted device can determine whether the area is a preloaded area or a mirrored area. Among them, the preloaded area can be an area in the second memory space for storing preloaded data. The mirrored area can be an area in the second memory space for storing mirrored data of a class. If the vehicle-mounted device determines that the area is not a preloaded area and is not a mirrored area, the electronic device can identify the area as a target area and traverse the memory data in the target area through a sub-process.

[0076] Among them, Figure 1 As shown, the memory space mainly consists of two areas: a shared data area and a private data area. Since the memory data in the private data area cannot be shared between processes, the area that the child process can traverse is mainly the memory data in the shared data area of ​​the first memory space, that is, the memory data in the second memory space is mainly the memory data in the shared data area of ​​the first memory space.

[0077] The shared data area may include the heap data area and the method area. Since the heap data area is used to dynamically allocate memory, objects and data structures can be allocated and released on the heap data area as needed during program execution. Therefore, the heap data area is the main place where problems such as memory leaks, dangling pointers, and memory fragmentation occur. Memory leaks refer to the situation where the allocated space in the heap data area cannot be released normally when it is no longer needed, resulting in abnormal occupancy. This is usually caused by the incorrect handling of object reference relationships.

[0078] Furthermore, since the method area in the shared data area is mainly used to store memory data such as class information, constants and static variables, these memory data are relatively stable and generally do not change frequently during the operation of the target program. In addition, common problems related to memory space, such as memory leaks and performance bottlenecks, have a lower correlation with the memory data stored in the method area, but a higher correlation with the memory data stored in the heap data area. Therefore, in order to solve the memory leak problem and / or memory allocation problem of the application, the developer needs to obtain the memory data of the heap data area during the operation of the application, so as to understand the specific usage of the heap data area based on the memory data of the heap data area, such as which parts occupy a large amount of memory, whether there is a memory leak, etc., and then optimize the application in a targeted manner.

[0079] In view of this, the child process can determine the target area of ​​memory data that needs to be traversed from the heap data area. Specifically, the heap data area can contain multiple candidate areas. For each candidate area in the heap data area, the child process can determine whether the current candidate area is a preload area or a mirror area. If the child process determines that the current candidate area is not a preload area and is not a mirror area, the child process can identify the current candidate area as the target area.

[0080] In one possible implementation, see Figure 5 , shows a schematic diagram of the structure of a heap data area provided by an embodiment of the present application. Figure 5As shown, the heap data area can mainly include a young generation area, an old generation area, a survivor area, a preload area and a mirror area. Among them, the young generation area can be an area in the heap data area of ​​the second memory space for allocating memory data. The old generation area can be an area in the heap data area of ​​the second memory space for storing memory data with an effective duration greater than a preset duration threshold. The survivor area can be an area in the heap data area of ​​the second memory space for temporarily storing memory data. Among them, after arriving at the memory space, the memory data can be first allocated in the young generation area, and when the space in the young generation area is insufficient, the memory data that needs to be continued to be stored in the young generation area can be copied to the survivor area. After the memory data arrives in the survivor area, the storage effective duration corresponding to the memory data can be calculated in the survivor area. Among them, the memory data with a storage effective duration greater than the duration threshold can be copied to the old generation area for storage, and the memory data with a storage effective duration less than or equal to the duration threshold can be deleted. Specifically, the survivor area can include a first survivor area and a second survivor area. The first survivor area can be the survivor area that the memory data in the young generation area arrives at when it is cached for the first time. The second survivor area may be a survivor area to which the memory data in the young generation area is cached for the second time. The preload area may be an area in the heap data area of ​​the second memory space for storing preload data. The mirror area may be an area in the heap data area of ​​the second memory space for storing mirror data of the class.

[0081] Therefore, for each candidate area in the heap data area, the child process can identify the young generation area, the old generation area, and the survivor area as the target area, and traverse each of the above target areas to obtain the memory data corresponding to each of the above target areas. Finally, the child process can generate a memory file corresponding to the target application based on the memory data traversed in all target areas.

[0082] In a possible implementation, the specific process of the sub-process traversing the memory data in the target area to generate a memory file can be described as follows. In the process of traversing the memory data in the target area, for any memory data in the target area, the sub-process can determine whether the memory data meets the clipping conditions pre-set by the R&D personnel. If the sub-process determines that the data type of a certain memory data in the target area does not meet the clipping conditions, the sub-process can identify the memory data as the target data. If the sub-process determines that the data type of a certain memory data in the target area meets the clipping conditions, the sub-process may not identify the memory data as the target data. Among them, the clipping conditions pre-set by the R&D personnel include at least one of the following: the data type of the memory data is byte type; the data type of the memory data is integer type; the data type of the memory data is short integer type; the data type of the memory data is long integer type; the data type of the memory data is single-precision floating point type; the data type of the memory data is double-precision floating point type; the data type of the memory data is character type; the data type of the memory data is Boolean type.

[0083] Specifically, for any memory data in the target area, if the child process determines that the data type of the memory data is not any of the eight data types of byte type, integer type, short integer type, long integer type, single-precision floating point type, double-precision floating point type, character type and Boolean type, then the child process can identify the memory data as target data. After determining all the target data in the target area, the child process can parse each target data in the target area one by one and read each target data one by one. Then, the child process can generate a memory file corresponding to the target program based on all the read target data.

[0084] For any memory data in the target area, if the child process determines that the data type of the memory data is any one of the eight data types of byte, integer, short integer, long integer, single-precision floating point, double-precision floating point, character type and Boolean type, the child process may not identify the memory data as the target data. For memory data in the target area that is not the target data, the child process may not perform the parsing and reading operation on the memory data.

[0085] Through the method provided in this embodiment, since the subprocess first filters out the target data from the target area before extracting the memory data, and then extracts the target data as a whole to generate a memory file. Compared with the method in the prior art that directly extracts all the memory data in the memory space and then cuts the extracted memory data to generate a memory file, the method provided in this embodiment simplifies the process of the subprocess generating the memory file, thereby reducing the CPU resources consumed in the process of the subprocess generating the memory file. Therefore, compared with the prior art, the method provided in this embodiment can capture the memory file corresponding to the target program in real time when the vehicle-mounted device is actually running, so that the operator can monitor the actual running status of each application in the vehicle-mounted device in real time.

[0086] In addition, since the child process does not trim the extracted memory data, all data in the memory file generated by the child process are complete data. After obtaining the memory file, the R&D personnel can directly parse the memory file to analyze the data in the memory file without performing operations such as data backfilling. Therefore, the method provided in this embodiment can improve the convenience of R&D personnel in analyzing memory data.

[0087] S3022: For any area in the second memory space, if any area is a preload area or a mirror area, the child process may not identify the area as a target area.

[0088] In this embodiment, for any area in the second memory space, if the area is a preload area or a mirror area, the child process may not identify the area as a target area, that is, the child process may identify the area as a non-target area. For the non-target area in the memory space, the child process may not traverse the memory data in the area.

[0089] According to the method provided by this embodiment, since the subprocess can determine the target area of ​​memory data that needs to be traversed from the memory space before traversing the memory data, the subprocess may not traverse the memory data in the non-target area. That is, the method provided by this embodiment can reduce the data that the subprocess needs to traverse by filtering the area before the subprocess traverses the data. Therefore, the method provided by this embodiment can further improve the efficiency of the subprocess in generating memory files. In addition, since the memory data in the preload area is temporary and the repetitiveness of the memory data in the area is high, and the memory data in the mirror area is read-only and the R&D personnel can directly obtain it from the disk mirror file. Therefore, when the subprocess generates the memory file, it does not read the memory data in the preload area and the mirror area, and will not affect the memory analysis results of the R&D personnel. Therefore, the method provided by this embodiment can improve the speed of the subprocess generating memory files without affecting the memory analysis.

[0090] See also Figure 6 , shows a schematic diagram of a memory file provided by an embodiment of the present application. Figure 6 (a) is a schematic diagram of a memory file generated by the prior art. Figure 6 As shown in (a) in the figure, it is a schematic diagram of the memory file generated by the prior art. Among them, the memory capacity occupied by the memory data of the mirror area is 7910581 bytes, the memory capacity occupied by the memory data of the preload area is 329380 bytes, and the memory capacity occupied by the common memory data of the young generation area, the old generation area, and the survivor area is 4633818 bytes. The memory file generated by the method provided in this embodiment is as follows: Figure 6 As shown in (b), since the child process did not extract the memory data of the preload area and the mirror area during the process of generating the memory file, in addition, the child process further screened the memory data in the target area according to the data type. Therefore, the memory data extracted by the method provided in this embodiment only occupies 276566 bytes of memory capacity. It can be seen that the method provided in this embodiment can effectively reduce the amount of memory data extracted by the child process, streamline the memory data that the child process needs to extract, reduce the occupancy of CPU and IO, and greatly facilitate the data monitoring of the application.

[0091] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0092] Reference Figure 7 , shows a schematic diagram of a memory data acquisition device provided in an embodiment of the present application, which may specifically include a sub-process creation module 701 and a memory file generation module 702, wherein:

[0093] The sub-process creation module 701 is used to create a sub-process based on the main process of any target program when the target program meets the data acquisition condition; the sub-process is run based on the memory data stored in the first memory space by the main process;

[0094] A memory file generation module 702 is used to traverse the memory data in the target area of ​​the second memory space through the sub-process to generate a memory file corresponding to the target program; the target area is an area in the second memory space that stores memory data of a preset type; the second memory space is the same space as the first memory space, or is a third memory space for storing memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space.

[0095] Among them, the memory file generation module can also be used for any area in the second memory space. If any area is not a preload area and is not a mirror area, then the any area is identified as the target area, and the memory data in the target area is traversed by the sub-process to obtain the target data corresponding to the target area; the target data is used to generate the memory file; the preload area is the area in the second memory space where preload data is stored; the mirror area is the area in the second memory space where mirror data of the class is stored.

[0096] The memory file generation module can also be used to identify any memory data in the target area as the target data during the process of traversing the memory data in the target area through the sub-process, if the data type of any memory data in the target area does not meet the preset clipping conditions; read all the target data in the second memory space through the sub-process to generate a memory file corresponding to the target program.

[0097] The trimming conditions in the memory file generation module include at least one of the following: the data type of any memory data is byte type; the data type of any memory data is integer type; the data type of any memory data is short integer type; the data type of any memory data is long integer type; the data type of any memory data is single-precision floating point type; the data type of any memory data is double-precision floating point type; the data type of any memory data is character type; the data type of any memory data is Boolean type.

[0098] The target area in the memory file generation module includes a young generation area, an old generation area and a survivor area; the young generation area is an area in the second memory space for allocating memory data; the survivor area is an area in the second memory space for temporarily storing memory data; the old generation area is an area in the second memory space for storing memory data whose effective duration is greater than a preset duration threshold.

[0099] The child process creation module can also be used to create a memory mapping relationship between the first memory space and the third memory space of the child process through the kernel interface corresponding to the target program; correspondingly, the memory file generation module can also be used to, if the main process does not perform a data write operation on the first memory space, then the child process traverses the memory data of the first memory space in the target area based on the memory mapping relationship to generate a memory file corresponding to the target program.

[0100] The child process creation module can also be used to copy all memory data in the first memory space to the third memory space through the kernel interface if the main process performs a data write operation on the first memory space when the data acquisition condition is met; correspondingly, the memory file generation module can also be used to traverse the memory data in the target area of ​​the third memory space through the child process to generate a memory file corresponding to the target program.

[0101] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.

[0102] Reference Figure 8 , shows a schematic diagram of a vehicle-mounted device provided by an embodiment of the present application. Figure 8 As shown, the vehicle-mounted device 800 in the embodiment of the present application includes: a processor 810, a memory 820, and a computer program 821 stored in the memory 820 and executable on the processor 810. When the processor 810 executes the computer program 821, the steps in each embodiment of the above-mentioned memory data acquisition method are implemented, such as Figure 1 Alternatively, when the processor 810 executes the computer program 821, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 7 Functions of modules 701 to 702 are shown.

[0103] Exemplarily, the computer program 821 may be divided into one or more modules / units, which are stored in the memory 820 and executed by the processor 810 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which may be used to describe the execution process of the computer program 821 in the vehicle-mounted device 800. For example, the computer program 821 may be divided into a subprocess creation module and a memory file generation module, and the specific functions of each module are as follows:

[0104] A sub-process creation module, used for creating a sub-process based on the main process of any target program when the target program meets the data acquisition condition; the sub-process is run based on the memory data stored in the first memory space by the main process;

[0105] A memory file generation module, used to traverse the memory data in the target area of ​​the second memory space through the sub-process to generate a memory file corresponding to the target program; the target area is an area in the second memory space that stores memory data of a preset type; the second memory space is the same space as the first memory space, or a third memory space for storing memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space.

[0106] The vehicle-mounted device 800 may be a central control display screen, a head-up display device, a rear entertainment device, an interactive device, a vehicle-mounted computer, a vehicle networking module, etc. The vehicle-mounted device 800 may include, but is not limited to, a processor 810 and a memory 820. Those skilled in the art will appreciate that Figure 8 It is only an example of the vehicle-mounted device 800 and does not constitute a limitation of the vehicle-mounted device 800. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the vehicle-mounted device 800 may also include input and output devices, network access devices, buses, etc.

[0107] The processor 810 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0108] The memory 820 may be an internal storage unit of the vehicle-mounted device 800, such as a hard disk or memory of the vehicle-mounted device 800. The memory 820 may also be an external storage device of the vehicle-mounted device 800, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the vehicle-mounted device 800. Further, the memory 820 may also include both an internal storage unit of the vehicle-mounted device 800 and an external storage device. The memory 820 is used to store the computer program 821 and other programs and data required by the vehicle-mounted device 800. The memory 820 may also be used to temporarily store data that has been output or is to be output.

[0109] An embodiment of the present application also discloses a vehicle-mounted device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the memory data acquisition method described in the aforementioned embodiments is implemented.

[0110] An embodiment of the present application further discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the memory data acquisition method as described in the above-mentioned embodiments is implemented.

[0111] An embodiment of the present application further discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the memory data acquisition method described in the above-mentioned embodiments.

[0112] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application is described in detail with reference to the above-mentioned embodiments, a person skilled in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method for acquiring memory data, characterized in that: include: When any target program meets the data acquisition condition, a subprocess is created based on the main process of the target program; The sub-process is run based on the memory data stored in the first memory space by the main process; Traversing the memory data of the second memory space in the target area by the subprocess to generate a memory file corresponding to the target program; The target area is an area in the second memory space that stores memory data of a preset type; the second memory space is the same space as the first memory space, or is a third memory space used to store memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space.

2. The method according to claim 1, characterized in that: The step of traversing the target data in the target area of ​​the memory data by the subprocess to generate a memory file corresponding to the target program includes: For any area in the second memory space, if the area is not a preload area and is not a mirror area, the area is identified as the target area, and the memory data in the target area is traversed by the child process to obtain the target data corresponding to the target area; the target data is used to generate the memory file; the preload area is an area in the second memory space that stores preload data; the mirror area is an area in the second memory space that stores mirror data of the class.

3. The method according to claim 2, characterized in that The traversing the memory data in the target area through the subprocess to obtain the target data corresponding to the target area includes: In the process of traversing the memory data in the target area through the sub-process, for any memory data in the target area, if the data type of the any memory data does not meet the preset clipping condition, identifying the any memory data as the target data; All the target data in the second memory space are read by the subprocess to generate a memory file corresponding to the target program.

4. The method according to claim 3, characterized in that: The cutting condition includes at least one of the following: The data type of any memory data is byte type; The data type of any memory data is integer; The data type of any memory data is short integer; The data type of any memory data is a long integer; The data type of any memory data is single-precision floating point type; The data type of any memory data is double-precision floating point type; The data type of any memory data is a character type; The data type of any memory data is Boolean type.

5. The method according to claim 1, characterized in that The target area includes a young generation area, an old generation area and a survivor area; the young generation area is an area where memory data is allocated in the second memory space; The survivor area is an area in the second memory space that temporarily stores memory data; the old generation area is an area in the second memory space that stores memory data whose effective duration is greater than a preset duration threshold.

6. The method according to any one of claims 1 to 5, characterized in that: In the case where any target program meets the data acquisition condition, after creating a subprocess based on the main process of the target program, the method includes: Creating a memory mapping relationship between the first memory space and the third memory space of the child process through a kernel interface corresponding to the target program; Correspondingly, traversing the memory data of the second memory space in the target area by the subprocess to generate a memory file corresponding to the target program includes: If the main process does not perform a data write operation on the first memory space, the sub-process traverses the memory data of the first memory space in the target area based on the memory mapping relationship to generate a memory file corresponding to the target program.

7. The method according to claim 6, characterized in that After creating a memory mapping relationship between the first memory space and the third memory space of the child process through the kernel interface corresponding to the target program, the method includes: If the main process performs a data write operation on the first memory space, all memory data in the first memory space that meets the data acquisition condition is copied to the third memory space through the kernel interface; Correspondingly, traversing the memory data of the second memory space in the target area by the subprocess to generate a memory file corresponding to the target program includes: The memory data of the third memory space in the target area is traversed by the subprocess to generate a memory file corresponding to the target program.

8. A memory data acquisition device, characterized in that: include: A subprocess creation module, used to create a subprocess based on the main process of any target program when the target program meets the data acquisition condition; The sub-process is run based on the memory data stored in the first memory space by the main process; A memory file generation module, used for traversing the memory data in the target area of ​​the second memory space through the subprocess to generate a memory file corresponding to the target program; The target area is an area in the second memory space that stores memory data of a preset type; the second memory space is the same space as the first memory space, or is a third memory space used to store memory data stored in the first memory space when the data acquisition condition is met; the third memory space is a memory space different from the first memory space.

9. A vehicle-mounted device, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the vehicle-mounted device implements the memory data acquisition method as described in any one of claims 1 to 7.

10. A vehicle, characterized in that: It comprises a vehicle-mounted device, and the vehicle-mounted device is used to execute the memory data acquisition method as described in any one of claims 1-7.