Memory tracking method, device and equipment, storage medium and vehicle

By obtaining the event and memory information of the target business process in the memory tracking tool in the field of intelligent driving, using the tracking point registration function to generate and insert the tracking point record function, fine-grained tracking of memory usage is achieved, and the current solution is to solve the problem of Some tools cannot analyze the memory usage in detail, which improves the pertinence and security of memory management.

CN119248623APending Publication Date: 2025-01-03CHONGQING CHANGAN TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411265824.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

Existing memory tracking tools cannot analyze memory usage on a finer granularity, and cannot obtain the memory usage of the main business data objects in the target business process in a target business process in a target business process, resulting in the memory acquisition being single and not detailed enough.

Method used

By obtaining the event to be tracked and the target memory information of the target business process, the preset tracking point registration function is used to generate the target tracking point record function, and these functions are inserted before and after the code position of the event to achieve detailed tracking and recording of memory usage. .

Benefits of technology

It realizes fine-grained tracking of memory usage, supports personalized definition of tracking content, avoids the problem of singularity and inability to obtain memory situations, and can promptly detect memory leaks and affect driving safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248623A_ABST
    Figure CN119248623A_ABST
Patent Text Reader

Abstract

The invention relates to a memory tracking method and device, equipment, a storage medium and a vehicle, and the method comprises the steps: obtaining a target business process, a to-be-tracked event of the target business process and target memory information needing to be tracked in the to-be-tracked event, the target business process comprises a business process name, and the to-be-tracked event comprises an event name; registering a to-be-tracked event through a preset tracking point registration function and target memory information, generating target tracking point recording functions, and after registration is completed, inserting the target tracking point recording functions before and after the to-be-tracked event according to a business process name and an event name, and performing memory tracking on the to-be-tracked event through the target tracking point recording function, and storing the memory use information to the specified output file of the preset tracking tool, the embodiment of the invention supports the tracking of the use condition of the memory with relatively fine granularity, and also supports the personalized definition of the content for tracking the memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of memory detection technology, and in particular to a memory tracking method, device, equipment, storage medium and vehicle. Background Art

[0002] In the field of intelligent driving, in order to pursue system stability and reliability, it is generally necessary to conduct fine-grained analysis of the memory used by related applications and modules on the vehicle's microprocessor unit. On the other hand, since most applications related to intelligent driving are long-running background service programs, it is necessary to promptly discover and resolve memory leaks to avoid affecting memory usage and, in serious cases, driving safety. Therefore, it is necessary to use tracking tools to track the memory used by applications and modules during operation.

[0003] Current memory tracking tools such as top track the granularity of application processes. That is, they mix all the memory used by the application: such as the memory of the executable body of the executable file, the memory of various dependent libraries, the memory managed by Glibc, the memory used by the standard library, the custom memory (such as the memory actively requested and released by the application), etc. The current tracking tools process all the above memory of the application in an undifferentiated manner.

[0004] However, the above tracking method can only see the total memory of the application, and cannot support users to analyze the memory usage at a finer granularity such as threads and business processing, resulting in a relatively simple memory situation. In addition, different applications use different memory technologies and focus on different dimensions. The current memory tracking tools cannot provide targeted memory usage of major business data objects in the continuous processing of certain data streams. Summary of the invention

[0005] One of the purposes of the present invention is to provide a memory tracking method to solve the problem that the memory conditions obtained in the existing memory tracking methods are relatively single and cannot be targeted to obtain finer-grained memory conditions. The second purpose is to provide a memory tracking device. The third purpose is to provide an electronic device. The fourth purpose is to provide a computer-readable storage medium. The fifth purpose is to provide a vehicle.

[0006] In order to achieve the above object, the technical solution adopted by the present invention is as follows:

[0007] A first aspect of an embodiment of the present invention provides a memory tracking method, the method comprising:

[0008] Acquire a target business process, an event to be tracked of the target business process, and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name;

[0009] Registering the event to be tracked through a preset tracking point registration function and the target memory information to generate a target tracking point recording function;

[0010] When the registration is completed, the target tracking point recording function is respectively inserted before and after the code position of the event to be tracked according to the business process name and the event name;

[0011] The target tracking point recording function is used to perform memory tracking on the event to be tracked, memory usage information of the event to be tracked is obtained, and the memory usage information is stored in a designated output file of a preset tracking tool.

[0012] Optionally, registering the event to be tracked by using a preset tracking point registration function and the target memory information to generate a target tracking point recording function includes:

[0013] Calling a preset tracking point registration function to register the event to be tracked;

[0014] During the registration process, obtaining a recording function corresponding to the event to be tracked;

[0015] The first parameter in the recording function is set according to the target memory information to be tracked, and a target tracking point recording function is generated.

[0016] Optionally, after the registration is completed, inserting the target tracking point recording function before and after the code position of the event to be tracked according to the business process name and the event name, respectively, includes:

[0017] When the registration is completed, the code position of the event to be tracked in the target business process is determined according to the business process name and the event name;

[0018] Inserting a first tracking point recording function before the code position;

[0019] A second tracking point record function is inserted after the code position, and the target tracking point record function includes the first tracking point record function and the second tracking point record function.

[0020] Optionally, one target tracking point record function corresponds to one tracking point;

[0021] Before performing memory tracking on the event to be tracked by recording the target tracking point function, obtaining memory usage information of the event to be tracked, and storing the memory usage information in a specified output file of a preset tracking tool, the method further includes:

[0022] Get the function name list of the target tracking point recording function;

[0023] receiving a first enabling request sent by a preset tracing tool, wherein the first enabling request carries a function name of a third tracing point recording function to be enabled;

[0024] Retrieving the function name from the function name list;

[0025] If the function name is found in the function name list, a fourth tracking point record function corresponding to the function name is enabled through the first enable request, and the target tracking point record function includes the fourth tracking point record function.

[0026] Optionally, performing memory tracking on the event to be tracked by using the target tracking point recording function, obtaining memory usage information of the event to be tracked, and storing the memory usage information in a specified output file of a preset tracking tool includes:

[0027] Traversing the target tracking point recording function;

[0028] If the target tracking point recording function is the fourth tracking point recording function, obtaining an enabling state of the fourth tracking point recording function;

[0029] If the enabling state is successful, obtaining the second parameter in the fourth tracking point recording function;

[0030] Obtaining memory usage information about the event to be tracked through the second parameter;

[0031] After storing the memory usage information in the target buffer of the target application, sending a memory information reading notification to the tracking tool;

[0032] The tracking tool obtains memory usage information according to the memory information reading notification, and stores the memory usage information in a designated output file.

[0033] Optionally, after storing the memory usage information in the target buffer of the target application, sending a memory information reading notification to the tracking tool further includes:

[0034] After storing the memory usage information in a target buffer of a target application, obtaining an information transmission format set in the tracking tool;

[0035] Formatting the memory usage information according to the information transmission format;

[0036] Sending a memory information read notification to the tracing tool.

[0037] Optionally, after retrieving the function name from the function name list, the method further includes:

[0038] If the function name is not found in the function name list, refusing to respond to the first enabling request and sending a warning prompt;

[0039] receiving a second enabling request sent by the user based on the early warning prompt, wherein the second enabling request carries an updated function name of the third tracking point record function to be enabled;

[0040] The updated function name is then searched again in the function name list.

[0041] Optionally, after traversing the target tracking point recording function, the method further includes:

[0042] If the target tracking point recording function is not the fourth tracking point recording function, skipping the current target tracking point recording function and continuing to traverse the next target tracking point recording function;

[0043] If the target tracking point recording function is the fourth tracking point recording function that fails to be enabled, the current target tracking point recording function is skipped, and the next target tracking point recording function is traversed.

[0044] A second aspect of an embodiment of the present invention provides a memory tracking device, the device comprising:

[0045] A first acquisition module is used to acquire a target business process, an event to be tracked of the target business process, and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name;

[0046] A first generating module, used for registering the event to be tracked through a preset tracking point registration function and the target memory information, and generating a target tracking point recording function;

[0047] A first insertion module is used to insert the target tracking point recording function respectively before and after the code position of the event to be tracked according to the business process name and the event name after the registration is completed;

[0048] The second acquisition module is used to perform memory tracking on the event to be tracked through the target tracking point recording function, obtain memory usage information of the event to be tracked, and store the memory usage information in a specified output file of a preset tracking tool.

[0049] A third aspect of an embodiment of the present invention provides an electronic device, including:

[0050] processor;

[0051] a memory for storing instructions executable by the processor;

[0052] The processor is configured to execute the instructions to implement the memory tracking method as described in the first aspect.

[0053] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor of a mobile terminal, the mobile terminal is enabled to execute a memory tracking method.

[0054] According to a fifth aspect of an embodiment of the present application, a vehicle is provided, comprising the memory tracking device described in the second aspect of the present application.

[0055] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0056] The present invention obtains a target business process, an event to be tracked of the target business process and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name, and the event to be tracked is registered through a preset tracking point registration function and target memory information, and a target tracking point recording function is generated. When the registration is completed, the target tracking point recording function is respectively inserted before and after the event to be tracked according to the business process name and the event name, and memory tracking is performed on the event to be tracked through the target tracking point recording function, and the memory usage information is stored in a specified output file of a preset tracking tool. The embodiment of the present invention tracks the memory usage with a finer granularity by tracking the events in the business process, and supports personalized definition of the content of memory tracking by setting the event to be tracked and the target memory information by itself, thereby avoiding the problem that the acquired memory situation is relatively single and the memory situation with a finer granularity cannot be acquired in a targeted manner.

[0057] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0059] Figure 1 is a flowchart of a memory tracking method according to an exemplary embodiment;

[0060] Figure 2 yes Figure 1 The flowchart of step 103 in a memory tracking method according to an exemplary embodiment is shown;

[0061] Figure 3 yes Figure 1 The schematic diagram of the architecture of a memory tracking method according to an exemplary embodiment is shown;

[0062] Figure 4 is a block diagram of a memory tracking device according to an exemplary embodiment;

[0063] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0064] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0065] The first embodiment of the present application relates to a memory tracking method. Figure 1 is a flowchart of a memory tracking method according to an exemplary embodiment. Figure 1 As shown, the following steps are included:

[0066] Step 101, obtaining a target business process, an event to be tracked of the target business process, and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name.

[0067] The embodiments of the present invention are applied to the field of intelligent driving. Users may use multiple application apps to interact with the intelligent driving system, such as navigation apps that provide route planning, real-time traffic information and map services, remote control apps that allow users to remotely start, lock or check vehicle status, smart assistant apps that provide voice control, infotainment and personalized settings, and vehicle health monitoring apps that monitor vehicle performance and health, provide maintenance reminders, etc. In order to pursue system stability and reliability, it is generally necessary to perform fine-grained analysis on the memory used by applications or modules. Therefore, the embodiments of the present invention set a tracking point design interface for implementing memory tracking in the application, as well as a tracking tool for real-time tracking.

[0068] Through the above-mentioned tracking point design interface, it is possible to define and implement tracking of the tracking points required in the application. When tracking the finer-grained memory in the application, it is first necessary to determine the application to be tracked, because there may be multiple processes in an application, and there may be multiple events in a process. The embodiment of the present invention can implement the tracking of events. Because there may be events with exactly the same name in different processes, and there may be the same process in different applications, when tracking events, it is first necessary to determine the specific code location of the event to be tracked in the target business process. At this time, it is necessary to obtain the target application where the event to be tracked is located, and the target business process where the event to be tracked is located in the target application, and then determine the event to be tracked in the target business process. After determining the event to be tracked, it is necessary to continue to determine which target memory information of the event to be tracked is to be tracked. The setting of these target memory information can be based on user needs or expert experience, and the present invention is not specifically limited here.

[0069] For example, define two events to be tracked, and name the interface MEM_TRACE_EVENT. Users define them through the MEM_TRACE_EVENT interface. For example, track the acquisition event of the ring buffer - getAvailRingBuf and the release event of the ring buffer - releaseRingBuf. Different events have two start and end nodes. To obtain the memory usage when the event to be tracked is executed, it is necessary to determine the start and end nodes of the event, and set the tracking node based on these nodes. Then the corresponding nodes obtained are: RingBuf application start node, RingBuf application end node, RingBuf release start node, RingBuf release end node. Specifically:

[0070] Node 1: task_start_getAvailRingBuf indicates that the business process starts to obtain memory

[0071] Node 2: task_end_getAvailRingBuf indicates that the business process has ended the memory acquisition

[0072] Node 3: task_start_releaseRingBuf indicates the start of memory release for the business process

[0073] Node 4: task_end_releaseRingBuf indicates the end of memory release of the business process

[0074] For an event, the target memory information to be tracked may include at least one of the size of the allocated memory, the allocated thread, the business keyword (topic) during allocation, the number of times the event should be executed, the number of times the event is actually executed, etc.

[0075] Step 102: register the event to be tracked through a preset tracking point registration function and target memory information, and generate a target tracking point recording function.

[0076] In the embodiment of the present invention, after the event to be tracked is determined, it is necessary to register it in order to realize the tracking of the event to be tracked. When registering, a preset tracking point registration function can be called to achieve it. The preset tracking point registration function can be tracepoint_probe_register. Tracepoint_probe_register is a function used to register a tracking point probe in the Linux kernel. When registering for any event to be tracked, a corresponding recording function needs to be provided for it. The parameters in the function are set according to the target memory information to be tracked. After the setting is completed, the target tracking point recording function based on the event to be tracked can be obtained. The specific steps include:

[0077] Call the preset tracking point registration function to register the tracking event;

[0078] During the registration process, obtain the recording function corresponding to the event to be tracked;

[0079] The first parameter in the recording function is set according to the target memory information to be tracked, and a target tracking point recording function is generated.

[0080] For example, register for the event getAvailRingBuf. When registering, specify that the recording function corresponding to the event can record the size of the allocated memory. The corresponding first parameter is size, the allocation thread, the corresponding first parameter is task, the business keyword during allocation, the corresponding first parameter is topic, the current sequence of the allocation thread, and the corresponding first parameter is seq (through this sequence, it can be determined which cycle the allocation thread being executed is in). Different parameters require different types. Size is a numeric value, and the corresponding type can be an integer type "int". The corresponding type of task can be a custom data structure or class name "task". Topic is a string, and the corresponding type can be a string type "const char". Seq is a sequence, and the corresponding type can be a long integer type "long long". The corresponding target tracking point recording function is: std::function<void(Task*task,const char*topic,int size,long long seq)> func=[](Task*task,const char*topic,int size,long long seq).

[0081] Step 103, when the registration is completed, according to the business process name and the event name, the target tracking point recording function is respectively inserted before and after the code position of the event to be tracked.

[0082] After all the events to be tracked are registered in the embodiment of the present invention, it is necessary to insert a tracking point in the target application or target module. Because one target tracking point recording function corresponds to one tracking point, the corresponding one to be inserted is the target tracking point recording function. By inserting the target tracking point recording function, it is convenient to obtain the memory usage of the event to be tracked through the inserted target tracking point recording function when it is subsequently enabled. In order to obtain this situation, the embodiment of the present invention stipulates that the target tracking point recording function is inserted before the code position and after the code position of the event to be tracked (corresponding to the start node and the end node position of the event to be tracked).

[0083] Further, step 103, such as Figure 2 As shown:

[0084] Step 1031, when registration is completed, determine the code location of the event to be tracked in the target business process according to the business process name and the event name.

[0085] For example, suppose we have a business process named MyBusinessProcess, in which there is an event named getAvailRingBuf. We need to find the specific code location of getAvailRingBuf in MyBusinessProcess.

[0086] Step 1032, insert the first tracking point recording function before the code position.

[0087] The embodiment of the present invention predefines a start node before the code position of the event to be tracked, inserts a first tracking point recording function at the start node, and can subsequently obtain the first memory information of the target business process before the event to be tracked starts running through the first tracking point recording function.

[0088] For example, before getAvailRingBuf is started, the start node of getAvailRingBuf is pre-set to task_start_getAvailRingBuf, and a first tracking point recording function trace_task_start_getAvailRingBuf(this,to picName.c_str(),len,m_getCallTimes) is inserted at this node. In the trace_task_start_getAvailRingBuf function, the memory usage at the start of the event is recorded, such as available memory, used memory, etc., and this information is stored as first_memory_info.

[0089] Step 1033: insert a second tracking point record function after the code position, and the target tracking point record function includes the first tracking point record function and the second tracking point record function.

[0090] The embodiment of the present invention predefines an end node after the code position of the event to be tracked, and inserts a second tracking point recording function at the end node. The second tracking point recording function can be used to obtain the second memory information of the target business process after the event to be tracked ends. The memory usage during the operation of the event to be tracked is then determined by the second memory information and the first memory information.

[0091] For example, after getAvailRingBuf is finished running, the end node of getAvailRingBuf is pre-set as task_end_getAvailRingBuf, and a second tracking point recording function trace_task_end_getAvailRingBuf(this, topicName.c_str(), len, m_getCallTimes) is inserted at the node. In the trace_task_end_getAvailRingBuf function, the memory usage at the end of the event is recorded, and the information is stored as second_memory_info.

[0092] By comparing first_memory_info and second_memory_info, if the memory usage has changed significantly (for example, the memory usage has increased or decreased), it can be determined that getAvailRingBuf has started normally, and the memory usage of the event to be tracked under the parameters can be determined by comparing the two same memory parameters. If the memory usage has not changed significantly, it may mean that getAvailRingBuf has not started normally. At this time, an error can be reported to prompt the staff to handle it in time.

[0093] Through the above steps, it is convenient to start the tracking point recording functions of different nodes in the future, perform memory tracking on different events to be tracked, and obtain memory usage.

[0094] Step 104 , performing memory tracing on the event to be traced through the target tracing point recording function, obtaining memory usage information of the event to be traced, and storing the memory usage information in a designated output file of a preset tracing tool.

[0095] Memory tracking in the embodiment of the present invention refers to the monitoring and recording of memory usage in a program or system, including memory allocation, release, usage, leakage, etc. The embodiment of the present invention sets a target tracking point recording function for each event to be tracked, and inserts a corresponding target tracking point recording function for the start node and the end node of the event to be tracked. However, the use of the target tracking point recording function is limited. It needs to be enabled before the target tracking point recording function can be enabled to obtain the memory usage information of the event to be tracked. Enablement is usually used to indicate the enabling or activation of a function, module or device so that it can work normally or perform specific operations. Because there may be one or more events to be tracked in the target business program, and one event to be tracked corresponds to at least two target tracking point recording functions. Enabling the target tracking point recording function requires a preset tracking tool to implement. That is, the user inputs the function name of the target tracking point recording function to be enabled on the preset tracking tool, and then sends an enable request carrying the function name. According to the enable request, the function name input by the user is compared and retrieved with the function name list of the target tracking point recording function pre-set on the target application. If the corresponding function name exists in the function name list, the fourth tracking point recording function is screened out from the target tracking point recording function according to the function name, and the fourth tracking point recording function is enabled through the tracking tool. The specific steps include:

[0096] Get the function name list of the target tracking point recording function;

[0097] receiving a first enabling request sent by a preset tracing tool, wherein the first enabling request carries a function name of a third tracing point recording function to be enabled;

[0098] Retrieving the function name from the function name list;

[0099] If the function name is found in the function name list, a fourth tracking point record function corresponding to the function name is enabled through the first enable request, and the target tracking point record function includes the fourth tracking point record function.

[0100] For example, assuming that the function name list of the target trace point recording function includes trace_task_start_getAvailRingBuf and trace_task_end_getAvailRingBuf, the user enters trace_task_start_getAvailRingBuf in the tracing tool, then it is determined that trace_task_start_getAvailRingBuf(this, topicName.c_str(), len, m_getCall Times) in the target trace point recording function is enabled.

[0101] It should be noted that if the function name does not exist in the retrieved function name list, it may be that there is a problem with the function name entered by the user. In this case, a warning prompt can be sent to prompt the user to re-confirm the input function name and send an enable request again for retrieval. The specific steps include:

[0102] If the function name is not found in the function name list, refusing to respond to the first enabling request and sending a warning prompt;

[0103] receiving a second enabling request sent by the user based on the early warning prompt, wherein the second enabling request carries an updated function name of the third tracking point record function to be enabled;

[0104] The updated function name is then searched again in the function name list.

[0105] In addition, after enabling the tracking point recording function where the tracking point is located, the memory information in the target application can be obtained through the fourth tracking point recording function that has been enabled. When performing memory tracking, because there are multiple target tracking point recording functions in the target application, it is necessary to traverse all target tracking point recording functions. When traversing to the fourth tracking point recording function that is successfully enabled in the target tracking point recording function, memory tracking can be performed through this function. When performing memory tracking, because the parameter settings in the target tracking point recording function are set according to user needs, the memory information obtained by memory tracking is also based on user needs. The required memory usage information is filtered out from all information. The specific steps include:

[0106] Traversing the target tracking point recording function;

[0107] If the target tracking point recording function is the fourth tracking point recording function, obtaining an enabling state of the fourth tracking point recording function;

[0108] If the enabling state is successful, obtaining the second parameter in the fourth tracking point recording function;

[0109] Obtaining memory usage information about the event to be tracked through the second parameter;

[0110] After storing the memory usage information in the target buffer of the target application, sending a memory information reading notification to the tracking tool;

[0111] The tracking tool obtains memory usage information according to the memory information reading notification, and stores the memory usage information in a designated output file.

[0112] For example, the fourth trace point recording function enabled is trace_task_start_getAvailRingBuf(this, topicName.c_str(), len, m_getCallTimes), where the second parameter is, "this", "topicName.c_str()", "len" and "m_getCallTimes", where "this" is used to reference the member variables and member functions of the current object, that is, to determine the target business process to which it belongs.

[0113] "topicName.c_str()" is used to determine the business keyword (topic) during allocation, "len" is used to determine the size length of the allocated memory, and "m_getCallTimes" is used to determine the sequence value of the number of calls. The name, size, business topic and number of calls of the allocated thread are obtained through the second parameter, and after storing them in the target buffer of the target application, a memory information reading notification is sent to the tracking tool. Then, the tracking tool reads the memory usage information from the target buffer of the target application according to this notification and records it to the specified output file of the tracking tool cache.

[0114] It should be noted that when traversing the target tracking point recording function, there may be a target tracking point recording function that is not enabled, or a target tracking point recording function that fails to be enabled. In this case, this target tracking point recording function will be skipped and the next target tracking point recording function will be traversed to avoid causing unnecessary load. The specific steps include:

[0115] If the target tracking point recording function is not the fourth tracking point recording function, skipping the current target tracking point recording function and continuing to traverse the next target tracking point recording function;

[0116] If the target tracking point recording function is the fourth tracking point recording function that fails to be enabled, the current target tracking point recording function is skipped, and the next target tracking point recording function is traversed.

[0117] Furthermore, because the memory usage information is sent from the target application to the tracing tool, the tracing tool may set data format requirements. Therefore, when sending the memory usage information from the target application to the tracing tool, it is necessary to first adjust the format of the memory usage information to the format required by the tracing tool according to the requirements of the tracing tool, and then send a notification for transmission. The specific steps include:

[0118] After storing the memory usage information in the target buffer of the target application, obtain the information transmission format set in the tracking tool;

[0119] Formatting the memory usage information according to the information transmission format;

[0120] Send memory information read notification to the trace tool.

[0121] For example, assuming that the memory usage information is stored in the target buffer targetBuffer, and the information transmission format set in the tracking tool is JSON format, the memory usage information is converted into JSON format and a notification is sent to the tracking tool. The information transmission format may also include XML, YAML, CSV, MessagePack, BSON, etc., which are not specifically limited in the present invention.

[0122] Furthermore, the data flow between the preset tracking tool and the target application related to intelligent driving in the embodiment of the present invention is as follows: Figure 3 As shown, the target application controls the operation of the business process therein. When the target tracking point recording function (i.e., tracking point) of the target business process is reached, it is first determined whether the tracking point receives the enable request of the tracking tool. If it is enabled, if the target tracking point recording function of the tracking point is called, the memory usage information is read according to the target tracking point recording function and written into the target buffer, and then a memory information reading notification is sent to the tracking tool, and then the target business process is continued to run until the next tracking point is encountered, and the next judgment is continued. If it is not enabled, the inserted tracking point function will return in advance and will not cause unnecessary load. The preset tracking tool records user input, and then sends an enable request to the tracking point of the target application according to the user input, and then receives a memory information reading notification, reads the memory usage information from the target application according to the memory information reading notification, and records it in the cache of the tracking tool, and there is a pre-specified output file in the cache to store the memory usage information.

[0123] The present invention obtains a target business process, an event to be tracked of the target business process and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name, and the event to be tracked is registered through a preset tracking point registration function and target memory information, and a target tracking point recording function is generated. When the registration is completed, the target tracking point recording function is respectively inserted before and after the event to be tracked according to the business process name and the event name, and memory tracking is performed on the event to be tracked through the target tracking point recording function, and the memory usage information is stored in a specified output file of a preset tracking tool. The embodiment of the present invention tracks the memory usage with a finer granularity by tracking the events in the business process, and supports personalized definition of the content of memory tracking by setting the event to be tracked and the target memory information by itself, thereby avoiding the problem that the acquired memory situation is relatively single and the memory situation with a finer granularity cannot be acquired in a targeted manner.

[0124] A second embodiment of the present application relates to a memory tracking device, Figure 4 is a flowchart of a memory tracking device according to an exemplary embodiment. Figure 4 As shown, the following steps are included:

[0125] The first acquisition module 201 is used to acquire a target business process, an event to be tracked of the target business process, and target memory information to be tracked in the event to be tracked. The target business process includes a business process name, and the event to be tracked includes an event name.

[0126] The first generating module 202 is used to register the event to be tracked through a preset tracking point registration function and target memory information, and generate a target tracking point recording function.

[0127] The first inserting module 203 is used to insert the target tracking point recording function before and after the code position of the event to be tracked according to the business process name and the event name after the registration is completed.

[0128] The second acquisition module 204 is used to perform memory tracing on the event to be traced through the target tracing point recording function, obtain memory usage information of the event to be traced, and store the memory usage information in a specified output file of a preset tracing tool.

[0129] Optionally, the first generating module 202 specifically includes:

[0130] The first registration submodule is used to call a preset tracking point registration function to register the event to be tracked.

[0131] The first acquisition submodule is used to acquire the recording function corresponding to the event to be tracked during the registration process.

[0132] The first generating submodule is used to set the first parameter in the recording function according to the target memory information to be tracked, and generate the target tracking point recording function.

[0133] Optionally, the first insertion module 203 specifically includes:

[0134] The first determination submodule is used to determine the code position of the event to be tracked in the target business process according to the business process name and the event name after the registration is completed.

[0135] The first insertion submodule is used to insert a first tracking point recording function before the code position.

[0136] The second inserting submodule is used to insert a second tracking point recording function after the code position, and the target tracking point recording function includes the first tracking point recording function and the second tracking point recording function.

[0137] Optionally, one target tracking point record function corresponds to one tracking point.

[0138] The memory tracking device also includes:

[0139] The third acquisition module is used to obtain a function name list of the target tracking point recording function.

[0140] The first receiving module is used to receive a first enabling request sent by a preset tracing tool, wherein the first enabling request carries a function name of a third tracing point recording function to be enabled.

[0141] The first search module is used to search the function name in the function name list.

[0142] The enabling module is used to enable the fourth tracking point recording function corresponding to the function name through a first enabling request if the function name exists in the function name list, and the target tracking point recording function includes the fourth tracking point recording function.

[0143] Optionally, the second acquisition module 204 specifically includes:

[0144] The first traversal submodule is used to traverse the target tracking point recording function.

[0145] The second acquisition submodule is used to acquire the enabling state of the fourth tracking point recording function if the target tracking point recording function is the fourth tracking point recording function.

[0146] The third acquisition submodule is used to acquire the second parameter in the fourth tracking point recording function if the enabling state is successful.

[0147] The fourth acquisition submodule is used to acquire memory usage information about the event to be tracked through the second parameter.

[0148] The sending submodule is used to store the memory usage information in the target buffer of the target application and then send a memory information reading notification to the tracking tool.

[0149] The storage submodule is used for the tracking tool to obtain memory usage information according to the memory information reading notification, and store the memory usage information to a specified output file.

[0150] Optionally, the sending submodule specifically includes:

[0151] The acquisition unit is used to acquire the information transmission format set in the tracking tool after storing the memory usage information in the target buffer of the target application.

[0152] The formatting unit is used to format the memory usage information according to the information transmission format.

[0153] The sending unit sends a memory information reading notification to the tracking tool.

[0154] Optionally, the memory tracking device further includes:

[0155] The prompt module is used to refuse to respond to the first enabling request and send a warning prompt if the function name in the function name list is not retrieved.

[0156] The second receiving module is used to receive a second enabling request sent by the user based on the early warning prompt, and the second enabling request carries the updated function name of the third tracking point recording function to be enabled.

[0157] The second search module is used to continue searching the updated function name in the function name list.

[0158] Optionally, the second acquisition module 204 specifically further includes:

[0159] The second traversal submodule is used to skip the current target tracking point recording function and continue to traverse the next target tracking point recording function if the target tracking point recording function is not the fourth tracking point recording function.

[0160] The third traversal submodule is used to skip the current target tracking point recording function and continue to traverse the next target tracking point recording function if the target tracking point recording function is the fourth tracking point recording function that fails to be enabled.

[0161] The present invention obtains a target business process, an event to be tracked of the target business process and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name, and the event to be tracked is registered through a preset tracking point registration function and target memory information, and a target tracking point recording function is generated. When the registration is completed, the target tracking point recording function is respectively inserted before and after the event to be tracked according to the business process name and the event name, and memory tracking is performed on the event to be tracked through the target tracking point recording function, and the memory usage information is stored in a specified output file of a preset tracking tool. The embodiment of the present invention tracks the memory usage with a finer granularity by tracking the events in the business process, and supports personalized definition of the content of memory tracking by setting the event to be tracked and the target memory information by itself, thereby avoiding the problem that the acquired memory situation is relatively single and the memory situation with a finer granularity cannot be acquired in a targeted manner.

[0162] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0163] A third embodiment of the present application relates to an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement any memory tracking method.

[0164] Figure 5 1 is a block diagram of an electronic device 300 according to an exemplary embodiment. For example, the electronic device 300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0165] Reference Figure 5 , the electronic device 300 may include one or more of the following components: a processing component 302 , a memory 304 , a power component 306 , a multimedia component 308 , an audio component 310 , an input / output interface 312 , a sensor component 314 , and a communication component 316 .

[0166] The processing component 302 generally controls the overall operation of the device 300, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 302 may include one or more processors 320 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 302 may include one or more modules to facilitate the interaction between the processing component 302 and other components. For example, the processing component 302 may include a multimedia module to facilitate the interaction between the multimedia component 308 and the processing component 302.

[0167] The memory 304 is configured to store various types of data to support operations on the device 300. Examples of such data include instructions for any application or method operating on the device 300, contact data, phone book data, messages, pictures, videos, etc. The memory 304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0168] The power supply component 306 provides power to the various components of the electronic device 300. The power supply component 306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 300.

[0169] The multimedia component 308 includes a screen that provides an output interface between the electronic device 300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 308 includes a front camera and / or a rear camera. When the electronic device 300 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0170] The audio component 310 is configured to output and / or input audio signals. For example, the audio component 310 includes a microphone (MIC), and when the electronic device 300 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 304 or sent via the communication component 316. In some embodiments, the audio component 310 also includes a speaker for outputting audio signals.

[0171] The input / output interface 312 provides an interface between the processing component 302 and the peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0172] The sensor assembly 314 includes one or more sensors for providing various aspects of status assessment for the electronic device 300. For example, the sensor assembly 314 can detect the open / closed state of the electronic device 300, the relative positioning of components, such as the display and keypad of the electronic device 300, and the sensor assembly 314 can also detect the position change of the electronic device 300 or a component of the electronic device 300, the presence or absence of user contact with the electronic device 300, the orientation or acceleration / deceleration of the electronic device 300, and the temperature change of the electronic device 300. The sensor assembly 314 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 314 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 314 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0173] The communication component 316 is configured to facilitate wired or wireless communication between the electronic device 300 and other devices. The electronic device 300 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 316 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0174] In an exemplary embodiment, the electronic device 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0175] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 304 including instructions, and the instructions can be executed by a processor 320 of an electronic device 300 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0176] In an exemplary embodiment, a vehicle is also provided, which may specifically include: the above-mentioned memory tracking device.

[0177] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.

[0178] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim that lists several devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes may be made without departing from its scope. The scope of the present invention is limited only by the appended claims.

Claims

1. A memory tracking method, characterized in that: The method comprises: Acquire a target business process, an event to be tracked of the target business process, and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name; Registering the event to be tracked through a preset tracking point registration function and the target memory information to generate a target tracking point recording function; When the registration is completed, the target tracking point recording function is respectively inserted before and after the code position of the event to be tracked according to the business process name and the event name; The target tracking point recording function is used to perform memory tracking on the event to be tracked, memory usage information of the event to be tracked is obtained, and the memory usage information is stored in a designated output file of a preset tracking tool.

2. The method according to claim 1, characterized in that The registering the event to be tracked by using a preset tracking point registration function and the target memory information to generate a target tracking point recording function includes: Calling a preset tracking point registration function to register the event to be tracked; During the registration process, obtaining a recording function corresponding to the event to be tracked; The first parameter in the recording function is set according to the target memory information to be tracked, and a target tracking point recording function is generated.

3. The method according to claim 1, characterized in that When the registration is completed, according to the business process name and the event name, the target tracking point recording function is respectively inserted before and after the code position of the event to be tracked, including: When the registration is completed, the code position of the event to be tracked in the target business process is determined according to the business process name and the event name; Inserting a first tracking point recording function before the code position; A second tracking point record function is inserted after the code position, and the target tracking point record function includes the first tracking point record function and the second tracking point record function.

4. The method according to claim 1, characterized in that: One target tracking point record function corresponds to one tracking point; Before performing memory tracking on the event to be tracked by recording the target tracking point function, obtaining memory usage information of the event to be tracked, and storing the memory usage information in a specified output file of a preset tracking tool, the method further includes: Get the function name list of the target tracking point recording function; receiving a first enabling request sent by a preset tracing tool, wherein the first enabling request carries a function name of a third tracing point recording function to be enabled; Retrieving the function name from the function name list; If the function name is found in the function name list, a fourth tracking point record function corresponding to the function name is enabled through the first enable request, and the target tracking point record function includes the fourth tracking point record function.

5. The method according to claim 4, characterized in that The memory tracking of the event to be tracked is performed through the target tracking point recording function, the memory usage information of the event to be tracked is obtained, and the memory usage information is stored in a specified output file of a preset tracking tool, including: Traversing the target tracking point recording function; If the target tracking point recording function is the fourth tracking point recording function, obtaining an enabling state of the fourth tracking point recording function; If the enabling state is successful, obtaining the second parameter in the fourth tracking point recording function; Obtaining memory usage information about the event to be tracked through the second parameter; After storing the memory usage information in the target buffer of the target application, sending a memory information reading notification to the tracking tool; The tracking tool obtains memory usage information according to the memory information reading notification, and stores the memory usage information in a designated output file.

6. The method according to claim 5, characterized in that After storing the memory usage information in the target buffer of the target application, sending a memory information reading notification to the tracking tool also includes: After storing the memory usage information in a target buffer of a target application, obtaining an information transmission format set in the tracking tool; Formatting the memory usage information according to the information transmission format; Sending a memory information read notification to the tracing tool.

7. The method according to claim 4, characterized in that After retrieving the function name from the function name list, the method further includes: If the function name is not found in the function name list, refusing to respond to the first enabling request and sending a warning prompt; receiving a second enabling request sent by the user based on the early warning prompt, wherein the second enabling request carries an updated function name of the third tracking point record function to be enabled; The updated function name is then searched again in the function name list.

8. The method according to claim 5, characterized in that After traversing the target tracking point recording function, the method further includes: If the target tracking point recording function is not the fourth tracking point recording function, skipping the current target tracking point recording function and continuing to traverse the next target tracking point recording function; If the target tracking point recording function is the fourth tracking point recording function that fails to be enabled, the current target tracking point recording function is skipped, and the next target tracking point recording function is traversed.

9. A memory tracking device, characterized in that: include: A first acquisition module is used to acquire a target business process, an event to be tracked of the target business process, and target memory information to be tracked in the event to be tracked, wherein the target business process includes a business process name, and the event to be tracked includes an event name; A first generating module, used for registering the event to be tracked through a preset tracking point registration function and the target memory information, and generating a target tracking point recording function; A first insertion module is used to insert the target tracking point recording function respectively before and after the code position of the event to be tracked according to the business process name and the event name after the registration is completed; The second acquisition module is used to perform memory tracking on the event to be tracked through the target tracking point recording function, obtain memory usage information of the event to be tracked, and store the memory usage information in a specified output file of a preset tracking tool.

10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the instructions to implement the memory tracking method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of the mobile terminal, the mobile terminal is enabled to execute the memory tracking method according to any one of claims 1 to 8.

12. A vehicle, characterized in that: Includes the memory tracking device as claimed in claim 9.

Citation Information

Cited By

  • Data center management and control system and method

    CN120508480A