Data processing method and device, electronic device, and storage medium

By obtaining the directed acyclic graph of the application, determining the variable life cycle and clearing the memory, the problem of data occupies memory after it is no longer used and improving the device operation efficiency.

CN114860702BActive Publication Date: 2025-08-08NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210434049.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-24
Publication Date
2025-08-08
Estimated Expiration
2042-04-24

AI Technical Summary

Technical Problem

In the prior art, some data still occupies memory space after it is no longer used, resulting in an increase in the operating cost of the equipment, and the maintenance cost of manual recycling methods is high and error-prone.

Method used

By obtaining the directed acyclic graph of the target application, determine the life cycle of the variable, and delete the variable at the end of the life cycle to clear the memory space.

Benefits of technology

It realizes the timely and accurate clearance of memory space occupied by variables that are no longer used, reducing memory consumption and improving operating performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860702B_ABST
    Figure CN114860702B_ABST
Patent Text Reader

Abstract

The present application provides a data processing method and device, an electronic device, and a storage medium, wherein the method includes: obtaining a directed acyclic graph corresponding to a target application; for each variable of the target application, determining the final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable; merging the final group nodes to determine the group nodes that no longer use the variable in each target path to obtain a recyclable group node set; based on the recyclable group node set corresponding to each variable, determining the recyclable variables corresponding to the current group node where the target application is currently located; deleting the recyclable variables; thereby achieving timely and accurate deletion of variables after the end of their life cycle to clear the memory space occupied by such variables.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to data processing methods and devices, electronic devices, and storage media. Background Art

[0002] In scenarios where contextual data storage is required, such as low-code platforms, some data is used at different stages, while some data is no longer used after a certain stage. If this data is not processed, it will continue to occupy memory space and increase the operating costs of devices (such as servers).

[0003] In the related art, the processing of such data that will no longer be used after a certain stage is done through manual configuration and recycling. This method has the problems of high maintenance cost and prone to errors.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention

[0005] In view of the above problems, the present application is proposed to provide a data processing method and device, an electronic device, and a storage medium that overcome the above problems or at least partially solve the above problems, including:

[0006] A data processing method, comprising:

[0007] Get the directed acyclic graph corresponding to the target application;

[0008] For each variable of the target application, determining a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable;

[0009] Merging the final group nodes to determine the group nodes that no longer use the variables in each target path, and obtaining a recyclable group node set;

[0010] Determine, based on the recyclable group node set corresponding to each variable, the recyclable variable corresponding to the current group node where the target application is currently located;

[0011] Delete the recyclable variable.

[0012] Optionally, obtaining a directed acyclic graph corresponding to the target application includes:

[0013] Acquire multiple program nodes included in the target application;

[0014] Generating a directed graph corresponding to the target application according to the program nodes and the execution order of the program nodes;

[0015] When a directed cycle exists in the directed graph, de-cyclic processing is performed on the directed graph to obtain a directed acyclic graph corresponding to the target application;

[0016] When there is no directed cycle in the directed graph, it is determined that the directed graph is a directed acyclic graph corresponding to the target application.

[0017] Optionally, when a directed cycle exists in the directed graph, performing a de-cyclic process on the directed graph to obtain a directed acyclic graph corresponding to the target application includes:

[0018] Performing a depth-first traversal on the directed graph to determine the group to which each node belongs;

[0019] The directed graph is de-looped according to the groups to which the nodes belong, to obtain a corresponding directed acyclic graph; the nodes in the directed acyclic graph are group nodes, and the nodes that form the same loop in the directed graph are included in the same group node in the directed acyclic graph.

[0020] Optionally, performing a depth-first traversal on the directed graph to determine the group to which each node belongs includes:

[0021] Performing a depth-first traversal on the directed graph, storing the traversed nodes in a first set, and using a doubly linked list to record the traversed depth path;

[0022] When traversing each node, determine whether the current traversed node exists in the first set, and if so, determine the node after the current node based on the traversed depth path recorded in the doubly linked list;

[0023] The nodes following the current node are merged into the group where the current node is located.

[0024] Optionally, determining, for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable, includes:

[0025] Performing a depth-first traversal on the directed acyclic graph to determine multiple paths corresponding to the root group node of the directed acyclic graph to each leaf group node;

[0026] For each variable of the target application, obtaining a target path in the directed acyclic graph that uses the variable;

[0027] For each target path, a final group node that last uses the variable in the target path when the target application runs according to the target path is determined.

[0028] Optionally, merging the final group nodes to determine a group node in each target path that no longer uses the variable to obtain a recyclable group node set includes:

[0029] Merging the final group nodes to obtain a first node set, where the first node set includes the final group node corresponding to each target path and the group nodes before the corresponding final group node;

[0030] Based on the directed acyclic graph and the first group of node sets, a recyclable group node set that no longer uses the variable is determined, the recyclable group node set is the complement of the first group of node set in the directed acyclic graph, or the recyclable group node set is the complement of the first group of node set in the target path corresponding to the variable.

[0031] Optionally, merging the final group nodes to determine a group node in each target path that no longer uses the variable to obtain a recyclable group node set includes:

[0032] Merging the final group nodes to obtain a first node set, where the first node set includes the final group node corresponding to each target path and the group nodes before the corresponding final group node;

[0033] The first group node that is located after the corresponding final group node in each target path and is not in the first group node set is obtained to obtain a recyclable group node set.

[0034] Optionally, determining the recyclable variable corresponding to the current group node where the target application is currently located according to the recyclable group node set corresponding to each variable includes:

[0035] Obtain a target recyclable group node set including the current group node;

[0036] The variables corresponding to the target recyclable group node set are determined as recyclable variables.

[0037] Optionally, determining the recyclable variable corresponding to the current group node where the target application is currently located according to the recyclable group node set corresponding to each variable includes:

[0038] Merge the recyclable group node sets corresponding to each variable to obtain a recyclable group node set set;

[0039] The recyclable group node set corresponding to each variable is processed using a reverse mapping mechanism to obtain a recyclable variable set corresponding to each group node in the recyclable group node set, wherein the recyclable variable set includes all variables no longer used by the corresponding group node;

[0040] When the current group node is within the recyclable group node set, the recyclable variables are determined according to the recyclable variable set corresponding to the current group node.

[0041] A data processing device, comprising:

[0042] A directed acyclic graph acquisition module is used to obtain the directed acyclic graph corresponding to the target application;

[0043] a final group node determination module, configured to determine, for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable;

[0044] a recyclable node determination module, configured to merge the final group nodes to determine the group nodes that no longer use the variables in each target path, and obtain a recyclable group node set;

[0045] A recyclable variable determination module is used to determine the recyclable variable corresponding to the current group node where the target application is currently located according to the recyclable group node set corresponding to each variable;

[0046] The recyclable variable deletion module is used to delete the recyclable variables.

[0047] Optionally, the directed acyclic graph acquisition module includes:

[0048] A program node acquisition module, configured to acquire a plurality of program nodes included in the target application;

[0049] A directed graph generation module based on program nodes, configured to generate a directed graph corresponding to the target application according to the program nodes and the execution order of the program nodes;

[0050] a de-looping processing module, configured to, when a directed loop exists in the directed graph, perform de-looping on the directed graph to obtain a directed acyclic graph corresponding to the target application;

[0051] The directed acyclic graph determination module is used to determine that the directed graph is a directed acyclic graph corresponding to the target application when there is no directed cycle in the directed graph.

[0052] Optionally, the de-ring processing module includes:

[0053] A traversal grouping module is used to perform a depth-first traversal on the directed graph to determine the group to which each node belongs;

[0054] The same group node merging module is used to de-loop the directed graph according to the groups to which the nodes belong, so as to obtain a corresponding directed acyclic graph; the nodes in the directed acyclic graph are group nodes, and the nodes that form the same ring in the directed graph are classified into the same group node in the directed acyclic graph.

[0055] Optionally, the traversal grouping module includes:

[0056] A first processing module is configured to perform a depth-first traversal on the directed graph, store the traversed nodes in a first set, and record the traversed depth paths in a bidirectional linked list;

[0057] A second processing module is configured to determine, when traversing each node, whether a current node currently traversed exists in the first set, and if so, determine a node subsequent to the current node based on the traversed depth path recorded in the bidirectional linked list;

[0058] The third processing module is configured to merge the nodes subsequent to the current node into the group where the current node is located.

[0059] Optionally, the final group node determination module includes:

[0060] An all-path determination module is configured to perform a depth-first traversal on the directed acyclic graph to determine multiple paths corresponding to the root group node of the directed acyclic graph to each leaf group node;

[0061] a target path determination module, configured to obtain, for each variable of the target application, a target path using the variable in the directed acyclic graph;

[0062] The module for determining a final group node based on a target path is used to determine, for each target path, a final group node that last uses the variable in the target path when the target application runs according to the target path.

[0063] Optionally, the recyclable node determination module includes:

[0064] A group node merging module has been used to merge the final group nodes to obtain a first node set, wherein the first node set includes the final group node corresponding to each target path and the group node before the corresponding final group node;

[0065] A first recyclable group node determination module is used to determine a recyclable group node set that no longer uses the variable based on the directed acyclic graph and the first group node set, wherein the recyclable group node set is the complement of the first group node set in the directed acyclic graph, or the recyclable group node set is the complement of the first group node set in the target path corresponding to the variable.

[0066] Optionally, the recyclable node determination module includes:

[0067] A group node merging module has been used to merge the final group nodes to obtain a first node set, wherein the first node set includes the final group node corresponding to each target path and the group node before the corresponding final group node;

[0068] The second recyclable group node determination module is configured to obtain the first group node that is located after the corresponding final group node in each target path and is not in the first group node set, so as to obtain a recyclable group node set.

[0069] Optionally, the recyclable variable determination module includes:

[0070] A target recyclable group node set determining module is used to obtain a target recyclable group node set including the current group node;

[0071] The first recyclable variable determination module is configured to determine the variables corresponding to the target recyclable group node set as recyclable variables.

[0072] Optionally, the recyclable variable determination module includes:

[0073] A recyclable group node set determination module is used to merge the recyclable group node sets corresponding to each variable to obtain a recyclable group node set;

[0074] A module for determining a recyclable variable set based on reverse mapping, configured to process the recyclable group node set corresponding to each variable using a reverse mapping mechanism to obtain a recyclable variable set corresponding to each group node in the recyclable group node set, wherein the recyclable variable set includes all variables no longer used by the corresponding group node;

[0075] The second recyclable variable determination module is configured to determine the recyclable variables according to the recyclable variable set corresponding to the current group node when the current group node is within the recyclable group node set.

[0076] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the data processing method described above when executed by the processor.

[0077] A computer-readable storage medium stores a computer program, which implements the steps of the data processing method described above when executed by a processor.

[0078] This application has the following advantages:

[0079] In an embodiment of the present application, a directed acyclic graph corresponding to a target application is obtained; for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable is determined; the final group nodes are merged to determine the group nodes that no longer use the variable in each target path to obtain a recyclable group node set; based on the recyclable group node set corresponding to each variable, the recyclable variables corresponding to the current group node where the target application is currently located are determined; the recyclable variables are deleted; thereby achieving timely and accurate deletion of variables after the end of their life cycle to clear the memory space occupied by such variables. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for the description of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0081] Figure 1 A flowchart of the steps of a data processing method according to an embodiment of the present application;

[0082] Figure 2 is a schematic diagram of a directed graph in an embodiment of the present application;

[0083] Figure 3 for Figure 2 Schematic diagram of a directed acyclic graph obtained after de-cyclic processing of the directed graph shown;

[0084] Figure 4 This is a schematic diagram showing a variable path in a directed acyclic graph according to an embodiment of the present application;

[0085] Figure 5 This is a structural block diagram of a data processing device according to an embodiment of the present application. DETAILED DESCRIPTION

[0086] To make the above-mentioned purposes, features, and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and specific embodiments. It is apparent that the embodiments described are only a portion of the embodiments of this application, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments in this application without inventive effort are also within the scope of protection of this application.

[0087] An application is a collection of instructions for a computer to execute, which are generated by programmers through code writing. The code writing process generally involves the use of variables. Some variables have a specific lifecycle, meaning they are only used during specific phases and not at other stages. However, while the application is running, variables continue to occupy memory space regardless of whether they are in use. For example, in a game application, before adding certain features to a user's game character, the game character's validity logic may need to be checked. After obtaining the character's basic information and verifying its validity, the character's basic information is no longer needed. Therefore, if this information is not cleared during subsequent logic execution, it will continue to occupy memory space.

[0088] In the related art, the processing of such variables that will no longer be used after a certain stage is carried out through manual configuration and recycling, which has the problems of high maintenance cost and easy error.

[0089] In view of this, an embodiment of the present application provides a data processing method, which determines the life cycle of each variable through the directed acyclic graph corresponding to the application. When the life cycle of the variable ends, the variable is deleted to achieve timely and accurate clearing of the memory space occupied by variables that are no longer used, reduce memory consumption, and improve operating performance.

[0090] The data processing method provided in the embodiments of the present application can be applied to electronic devices to reduce the memory space occupied by running applications. The electronic device can be hardware or software. When the electronic device is hardware, it can be implemented as a cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the electronic device is software, it can be installed in the hardware devices listed above.

[0091] Reference Figure 1 , shows a data processing method provided by an embodiment of the present application, the data processing method may include the following steps:

[0092] Step 101: Obtain a directed acyclic graph corresponding to a target application;

[0093] Step 102: for each variable of the target application, determining a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable;

[0094] Step 103: Merge the final group nodes to determine the group nodes that no longer use the variables in each target path, and obtain a recyclable group node set;

[0095] Step 104: determining the recyclable variables corresponding to the current group node where the target application currently resides, based on the recyclable group node set corresponding to each variable;

[0096] Step 105: Delete the recyclable variable.

[0097] An embodiment of the present application obtains a directed acyclic graph corresponding to a target application; for each variable of the target application, determines the final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable; merges the final group nodes to determine the group nodes that no longer use the variable in each target path to obtain a recyclable group node set; based on the recyclable group node set corresponding to each variable, determines the recyclable variables corresponding to the current group node where the target application is currently located; deletes the recyclable variables; thereby achieving timely and accurate deletion of variables after the end of their life cycle to clear the memory space occupied by such variables.

[0098] Next, the data processing method in this exemplary embodiment will be further described.

[0099] In step 101, a directed acyclic graph corresponding to a target application is obtained.

[0100] An application can include multiple methods. Generally speaking, each method can be considered an ordered combination of steps to solve a class of problems. In other words, a method is a combination of code that implements a certain function. Methods involve the generation of variables, and transitions between methods involve variable transformations. In the process flow, each method in the application is represented as a program node. Therefore, program nodes involve the generation of variables, and transitions between program nodes involve variable transformations.

[0101] In the embodiment of the present application, the target application may refer to an application currently running on the device. The process of obtaining the directed acyclic graph corresponding to the target application may include:

[0102] Acquire multiple program nodes included in the target application;

[0103] Generating a directed graph corresponding to the target application according to the program nodes and the execution order of the program nodes;

[0104] When a directed cycle exists in the directed graph, de-cyclic processing is performed on the directed graph to obtain a directed acyclic graph corresponding to the target application;

[0105] When there is no directed cycle in the directed graph, it is determined that the directed graph is a directed acyclic graph corresponding to the target application.

[0106] In this example, the target application can be obtained by first obtaining the application currently running on the device. If there are multiple applications currently running on the device, it can be considered that multiple target applications have been obtained. The data processing method provided in the embodiment of the present application can be applied to each target application to promptly clear the memory space occupied by the target application. Therefore, the embodiment of the present application only uses a single target application as an example for illustrative explanation and description.

[0107] After determining the target application, the nodes of the directed graph corresponding to the target application can be determined based on the program nodes of the target application, and the edges in the directed graph and the directions of the edges can be determined based on the execution order of the program nodes, thereby obtaining the directed graph corresponding to the target application. It can be understood that the directed graph corresponding to the target application can be used to characterize the running process of the target application. Among them, the nodes of the directed graph correspond one-to-one with the program nodes of the target application, and the edges of the directed graph are used to characterize the execution order of the program nodes in the target application, that is, the path relationship. Furthermore, the path of the variables accessed by each node can be obtained.

[0108] After obtaining the directed graph corresponding to the target application, it is necessary to analyze whether the directed graph contains directed cycles. If so, the directed graph needs to be de-cycled to obtain the corresponding directed acyclic graph. If the directed graph does not contain directed cycles, it can be determined that the directed graph is a directed acyclic graph.

[0109] It should be noted that in the embodiment of the present application, a directed graph with directed loops is de-looped to obtain a corresponding directed acyclic graph. This does not mean deleting the edges of the directed loops in the directed graph, but rather grouping the nodes forming the same loop into the same group to obtain a directed acyclic graph equivalent to the directed graph.

[0110] In one example, topological sorting, depth-first traversal, breadth-first traversal, etc. can be used to determine whether there is a directed cycle in the directed graph. When a directed cycle exists, the directed graph is de-cycliced to obtain the corresponding directed acyclic graph.

[0111] In another example, it is possible to directly remove the loops from the directed graph without determining whether it has directed cycles. This allows the directed graph to be removed to obtain a corresponding directed acyclic graph. It is understood that in this example, if the directed graph has directed cycles, the resulting directed acyclic graph is the removed directed graph; if the directed graph does not have directed cycles, the resulting directed acyclic graph is consistent with the original directed graph, with no directed cycles present.

[0112] In an optional embodiment of the present application, when a directed cycle exists in the directed graph, the process of removing the cycle from the directed graph to obtain a directed acyclic graph corresponding to the target application may include the following steps:

[0113] Perform a depth-first traversal of the directed graph to determine the group to which each node belongs;

[0114] The directed graph is de-looped according to the groups to which each node belongs, to obtain the corresponding directed acyclic graph; the nodes in the directed acyclic graph are group nodes, and the nodes that form the same cycle in the directed graph are classified into the same group node in the directed acyclic graph.

[0115] This embodiment uses a depth-first traversal approach, starting from the root node of the directed graph. Nodes forming the same cycle are grouped together to determine the group to which each node belongs. Furthermore, the nodes of the directed acyclic graph are determined based on the resulting groups. The edges of the directed acyclic graph are determined based on the path relationships between the groups, resulting in a corresponding directed acyclic graph. The nodes of the directed acyclic graph are group nodes, which contain multiple nodes belonging to the same group in the corresponding directed graph.

[0116] By converting a directed graph with directed cycles into an equivalent directed acyclic graph, since there are no cycles in a directed acyclic graph, when the program node running the target application leaves the corresponding group node, it will not return to the group node it has left. Therefore, the directed acyclic graph can be used to determine whether the variables in the corresponding target application are no longer used, and then the unused variables can be deleted to clear memory space.

[0117] In other examples, a topological sorting method or the like may be used to determine multiple nodes forming the same ring, and the multiple nodes forming the same ring may be grouped into the same group to obtain a corresponding directed acyclic graph.

[0118] Furthermore, the process of performing depth-first traversal on the directed graph to determine the group to which each node belongs may include:

[0119] Perform a depth-first traversal on the directed graph, store the traversed nodes in the first set, and use a doubly linked list to record the traversed depth path;

[0120] When traversing each node, determine whether the current traversed node exists in the first set. If so, determine the node after the current node based on the traversed depth path recorded in the doubly linked list;

[0121] Merge the nodes after the current node into the group where the current node is located.

[0122] In this embodiment, a first set can be established in advance to store the traversed nodes, and a bidirectional linked list can be established to record the traversed depth path; through the depth-first traversal method, each time a node is traversed, it is determined whether the node is in the first set. If not, the node is stored in the first set, and the traversal of the next node is continued in the depth-first traversal method; if the node is in the first set, it means that a loop is formed, and then the node is found according to the traversed depth path recorded in the bidirectional linked list, and the node after the node is determined, and the nodes after the node are merged into the group where the node is located.

[0123] For example, assuming that the directed graph corresponding to the target application is Figure 2 As shown, Figure 2 The process of decyclic processing the directed graph shown in the figure to obtain the corresponding directed acyclic graph may include: using a mapping structure to record the nodes contained in the group node. The mapping structure can be recorded as nodeGroupMap, where the key is a string and the value is a set of strings, that is, the key is the group node identifier (GroupID) and the value is the node identifier (nodeID) of all nodes contained in the group node.

[0124] When traversing, first initialize the mapping structure, using the node ID of each node as the key and the value containing the node ID of each node. Figure 2 For example, when initializing the mapping structure, the key of the mapping structure of node 1 is node 1, and the value is node 1; the key of the mapping structure of node 2 is node 2, and the value is node 2; the key of the mapping structure of node 3 is node 3, and the value is node 3; the key of the mapping structure of node 4 is node 4, and the value is node 4; the key of the mapping structure of node 5 is node 5, and the value is node 5; the key of the mapping structure of node 6 is node 6, and the value is node 6; the key of the mapping structure of node 7 is node 7, and the value is node 7.

[0125] Traversal starts from a node that has not been visited in the directed graph. Specifically, taking traversal starting from node 1 as an example, the first set s is used to record the nodes that have been traversed, and the doubly linked list link is used to record the depth path that has been traversed. During the traversal process, it is determined whether the first set s contains the current node being traversed. At this time, the current node is node 1, which is not recorded in the first set s. Therefore, node 1 is stored in the first set s, which contains node 1, and the depth path that has been traversed is recorded as node 1 in the doubly linked list link.

[0126] Continue to traverse the next node 2. At this time, the current node is node 2. It can also be determined that node 2 is not in the first set s. Node 2 is stored in the first set s. The first set s contains node 1 and node 2, and the traversed deep path is recorded as node 1-node 2 in the bidirectional linked list link.

[0127] Continue to traverse the next node. Since the next nodes adjacent to node 2 include node 3 and node 4, any node can be used as the next node. When the next node is node 4, the current node is node 4. It can also be determined that node 4 is not in the first set s. Node 4 is stored in the first set s. The first set s contains node 1, node 2, and node 4, and the traversed deep path is recorded in the bidirectional linked list link as node 1-node 2-node 4.

[0128] Continue to traverse the next node. Since the next nodes adjacent to node 4 include node 6 and node 7, any node can be used as the next node. When the next node is node 6, the current node is node 6. It can also be determined that node 6 is not in the first set s. Node 6 is stored in the first set s. The first set s contains node 1, node 2, node 4, and node 6, and the traversed depth path is recorded in the bidirectional linked list link as node 1-node 2-node 4-node 6.

[0129] Continue to traverse the next node. Since the next nodes adjacent to node 6 include node 2 and node 5, any node can be used as the next node. When the next node is node 2, the current node is node 2. It is determined that node 2 is in the first set s, indicating a loop. The traversed depth path is recorded in the bidirectional linked list link as node 1-node 2-node 4-node 6 to find the nodes after the current node 2, namely node 4 and node 6, and classify node 4 and node 6 into the group where node 2 is located; that is, the values of the mapping structure of node 4 and the mapping structure of node 6 are included in the value of the mapping structure of node 2. At this time, the key of the mapping structure of node 2 is node 2, and the values are node 2, node 4, and node 6.

[0130] when Figure 2After all nodes in the directed graph shown are traversed, the group to which each node belongs can be obtained, as shown in Figure 2 As shown, node 1 belongs to the group of node 1, nodes 2, 4, and 6 all belong to the group of node 2, node 3 belongs to the group of node 3, node 5 belongs to the group of node 5, and node 7 belongs to the group of node 7. According to the conversion relationship between the groups, we can get the following: Figure 3 The directed acyclic graph shown in FIG. 1 shows a graph in which the value in the mapping structure of group node 1 is node 1, the value in the mapping structure of group node 2 is node 2, node 4, and node 6, the value in the mapping structure of group node 3 is node 3, the value in the mapping structure of group node 5 is node 5, and the value in the mapping structure of group node 7 is node 7.

[0131] In step 102 , for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable is determined.

[0132] The target application's program nodes involve the generation of variables, and transitions between program nodes involve the transformation of variables. Therefore, for each variable, all target paths in the directed acyclic graph that use that variable can be determined, as well as the group nodes that use that variable in each target path. Furthermore, the final group node that uses that variable in each target path can be determined. For paths in the directed acyclic graph that don't use that variable, it can be assumed that none of the group nodes in that path contain that variable. Therefore, the variable can be omitted from the group nodes in those paths that don't use that variable.

[0133] Since there are no loops in a directed acyclic graph, when the program node running the target application leaves the corresponding group node, it will not return to the group node it has left. Therefore, the directed acyclic graph can be used to determine whether the variables in the corresponding target application are no longer used, determine the recyclable variables, that is, the variables that can be deleted, and then delete the recyclable variables to clear memory space.

[0134] In an optional embodiment of the present application, the process of determining, for each variable of the target application, the final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable may include:

[0135] Performing a depth-first traversal on the directed acyclic graph to determine multiple paths corresponding to the root group node of the directed acyclic graph to each leaf group node;

[0136] For each variable of the target application, obtaining a target path in the directed acyclic graph that uses the variable;

[0137] For each target path, a final group node that last uses the variable in the target path when the target application runs according to the target path is determined.

[0138] In this embodiment, a depth-first traversal may be performed on the directed acyclic graph to determine all complete paths contained in the directed acyclic graph. A complete path refers to a path from the root node to the leaf nodes of the directed acyclic graph.

[0139] Based on the usage path information corresponding to each variable in the directed graph, the variables used by each path in the directed acyclic graph can be determined. The set of variables used by all paths in the directed acyclic graph is the valid variables of the target application. For any variable in the target application, the paths in the directed acyclic graph that use that variable can be determined. To distinguish them from paths that do not use that variable, the paths that use that variable are recorded as target paths.

[0140] For each target path of the variable, a final group node that last uses the variable in the target path when the target application runs according to the target path can be determined.

[0141] like Figure 4 After depth-first traversal of the directed acyclic graph shown, we can get all the complete paths contained in the directed acyclic graph, namely the first path [1,2,3,5], the second path [1,2,5], and the third path [1,2,7]. The variables used in the first path [1,2,3,5] are aa and ee; the variables used in the second path [1,2,5] are aa and ee; the variables used in the third path [1,2,7] are aa, ee, and ff; we get Figure 4 The corresponding target application variables are aa, ee, and ff.

[0142] For variable aa, it can be determined that the target paths using variable aa are the first path [1, 2, 3, 5], the second path [1, 2, 5], and the third path [1, 2, 7]; in the first path [1, 2, 3, 5], the final group node that finally uses variable aa is group node 3; in the second path [1, 2, 5], the final group node that finally uses variable aa is group node 1; in the third path [1, 2, 7], the final group node that finally uses variable aa is group node 1.

[0143] For the variable ee, it can be determined that the target paths using the variable ee are the first path [1, 2, 3, 5], the second path [1, 2, 5], and the third path [1, 2, 7]; in the first path [1, 2, 3, 5], the final group node that finally uses the variable ee is group node 5; in the second path [1, 2, 5], the final group node that finally uses the variable ee is group node 5; in the third path [1, 2, 7], the final group node that finally uses the variable ee is group node 2.

[0144] For the variable ff, it can be determined that the target path using the variable ff is only the third path [1, 2, 7]; in the third path [1, 2, 7], the final group node that finally uses the variable ff is group node 7.

[0145] It should be noted that, in other optional embodiments, when the directed graph corresponding to the target application is a directed cyclic graph, it is also possible to perform a depth-first traversal of the directed cyclic graph to determine multiple paths corresponding to the root node of the directed cyclic graph to each leaf node. For each variable, the usage path of the variable in the directed cyclic graph is obtained. For each usage path, it is determined that when the target application runs according to the usage path, the final node in the usage path that last uses the variable is the final group node in the corresponding directed acyclic graph. The specific process is similar to the above-mentioned process of obtaining the final group node based on the directed acyclic graph, except that after obtaining the final node based on the directed cyclic graph, it is necessary to determine the final group node corresponding to the final node.

[0146] In step 103, the final group nodes are merged to determine the group nodes that no longer use the variables in each target path, and obtain a recyclable group node set.

[0147] After obtaining the final group node for each variable in the corresponding target path, the path information for each final group node in the corresponding target path can be determined, namely, the group node information passed through from the root node of the target path to the final group node. Therefore, by merging the final group nodes corresponding to each variable, a first node set can be obtained. The first node set includes the final group node corresponding to each target path corresponding to the variable, as well as the group nodes preceding the corresponding final group node. It can be understood that the first node set includes all group nodes that use the variable.

[0148] Continue to combine Figure 4 An exemplary description is given.

[0149] The process of merging the final group nodes of variable aa to obtain the first group node set of variable aa can specifically be to save the final group node 3 of variable aa in the first path [1, 2, 3, 5] of the target path, as well as the group nodes 2 and 1 before group node 3, into the first group node set of variable aa. At this time, the group nodes included in the first group node set of variable aa are {1, 2, 3}. The final group node 1 of variable aa in the second path [1, 2, 5] of the target path, as well as the group nodes before group node 1 (empty in this example), are saved into the first group node set of variable aa. At this time, since group node 1 is already in the first group node set of variable aa, the group nodes included in the first group node set of variable aa are still {1, 2, 3}. Save the final group node 1 of variable aa in the target path of the third path [1, 2, 7] and the group node before group node 1 (empty in this example) to the first group node set of variable aa. At this time, since group node 1 is already in the first group node set of variable aa, the group nodes contained in the first group node set of variable aa are still {1, 2, 3}.

[0150] The process of merging the final group nodes of the variable ee to obtain the first group node set of the variable ee can specifically be to save the final group node 5 of the variable ee in the target path of the first path [1, 2, 3, 5], as well as the group nodes 3, group node 2, and group node 1 before group node 5, into the first group node set of the variable aa. At this time, the first group node set of the variable aa includes the group nodes {1, 2, 3, 5}. The final group node 2 of the variable ee in the target path of the second path [1, 2, 5], as well as the group node 1 before group node 2, are saved into the first group node set of the variable aa. At this time, since the group nodes 1 and 2 are already in the first group node set of the variable ee, the group nodes included in the first group node set of the variable ee are still {1, 2, 3, 5}. Save the final group node 2 of variable ee in the target path of the third path [1, 2, 7] and the group node 1 before group node 2 into the first group node set of variable ee. At this time, since group nodes 1 and 2 are already in the first group node set of variable ee, the group nodes contained in the first group node set of variable ee are still {1, 2, 3, 5}.

[0151] The process of merging the final group nodes of variable ff to obtain the first group node set of variable ff can specifically include saving the final group node 7 of variable ff in the target path of the third path [1, 2, 7], as well as the group nodes 2 and 1 preceding group node 7, into the first group node set of variable ff. At this time, the first group node set of variable ff includes the group nodes {1, 2, 7}. Since variable ff has only one target path, the first group node set of variable ff includes the group nodes {1, 2, 7}.

[0152] In an optional embodiment of the present application, after obtaining the first group of node sets corresponding to each variable, for each variable, a recyclable group of node sets that no longer uses the variable can be determined based on the directed acyclic graph and the first group of node sets, and the recyclable group of node sets is the complement of the first group of node sets in the directed acyclic graph, or the recyclable group of node sets is the complement of the first group of node sets in the target path corresponding to the variable.

[0153] In this embodiment, for each variable, all group nodes in the directed acyclic graph can be divided into group nodes that use the variable and group nodes that no longer use the variable. After obtaining the first group node set corresponding to the variable, all group nodes in the directed acyclic graph that are not in the first group node set can be combined to determine the other group nodes in the directed acyclic graph that are not in the first group node set, thereby obtaining the recyclable group node set of the variable.

[0154] Continue with Figure 4 For example, let's say the group nodes in a directed acyclic graph are {1, 2, 3, 5, 7}. For variable aa, the first node set is {1, 2, 3}, and the corresponding complement is {5, 7}, meaning that the recyclable node set for variable aa is {5, 7}. For variable ee, the first node set is {1, 2, 3, 5}, and the recyclable node set is {7}. For variable ff, the first node set is {1, 2, 7}, and the recyclable node set is {3, 5}.

[0155] In another example of this embodiment, all target paths corresponding to a variable can be divided into group nodes that use the variable and group nodes that no longer use the variable. After obtaining the first set of nodes corresponding to the variable, all group nodes corresponding to the target paths of the variable can be combined to determine other group nodes among the group nodes corresponding to the target paths that are not in the first set of nodes, thereby obtaining the set of recyclable group nodes for the variable.

[0156] Continue with Figure 4 For example, for variable aa, the target paths include the first path [1, 2, 3, 5], the second path [1, 2, 5], and the third path [1, 2, 7]. That is, the set of all group nodes corresponding to the target path is {1, 2, 3, 5, 7}, the first group node set is {1, 2, 3}, and the corresponding complement is {5, 7}, that is, the recyclable group node set of variable aa is {5, 7}.

[0157] For the variable ee, the target paths include the first path [1, 2, 3, 5], the second path [1, 2, 5], and the third path [1, 2, 7]. That is, the set of all group nodes corresponding to the target path is {1, 2, 3, 5, 7}, the first group node set is {1, 2, 3, 5}, and the recyclable group node set is {7}.

[0158] For the variable ff, the target path has a third path [1, 2, 7], that is, the set of all group nodes corresponding to the target path is {1, 2, 7}, the first group node set is {1, 2, 7}, then the recyclable group node set is {}, that is, the empty set.

[0159] This embodiment determines the recyclable group node set by the complement of the first group node set. It is generally used when the number of nodes is small. That is, the memory occupied by the recyclable group node set should be smaller than the memory occupied when the variable is not recycled, so as to reduce memory consumption.

[0160] In another optional embodiment of the present application, after obtaining the first group of nodes corresponding to each variable, for each variable, the first group node that is located after the corresponding final group node in each target path and is not in the first group of nodes can be obtained to obtain a recyclable group node set.

[0161] In this embodiment, for each variable, the first group node that is located after the corresponding final group node in each target path of the variable and is no longer in the first group node set is saved in the recyclable group node set corresponding to the variable to obtain the recyclable group node set of the variable.

[0162] For example, a trie tree (also known as a dictionary tree) structure can be combined to determine the recyclable group node set for each variable. Specifically, the trie tree contains a map structure of child nodes, where the key of the map is a single-layer path, and the value is also a trie tree structure data, including a set of subsequent group nodes that records the final group node grouID, denoted as unusedGroupSet, i.e., the recyclable group node set, and a map of the group node grouID last used by the target path ID, denoted as pathLastUsedGroupMap.

[0163] For example, a path with a variable aa.bb.cc can be represented by a three-layer trie tree. The first layer's trie1 contains the key aa and the value of trie2. The trie2 value contains the key bb and the value of trie3. The trie3 value contains the key cc and the value of trie4, that is, {"path":"","children":{"aa":{"path":"aa","children":{"bb":{"path":"bb","children":{"cc":{"path":"cc"}}}}}}}}

[0164] Perform a depth-first traversal of the directed acyclic graph to obtain a set of all complete deep paths, denoted as deepLinkList. deepLinkList contains multiple complete deep paths. Traverse each deeplink in the directed acyclic graph, record the current deeplink position as index, traverse the list of deepLinkList[index], record the currently traversed group node as currentNodeGroup, and insert the pathLastUsedGroupMap of the trie tree corresponding to the variable path into the key index, with value currentNodeGroup.

[0165] For the pathLastUsedGroupMap in the trie tree, according to the deepLinkList, the final group nodes last used on different paths are merged, and the set of group nodes that can delete the variable before entering a certain node is merged and recorded as unusedGroupSet, so that the group node set can be recycled. Specifically, the trie tree structure can be traversed, and the pathLastUsedGroupMap of each trie tree can be traversed. The key is recorded as pathIndex and the value is recorded as lastUsedGroupId. The path list of the complete deep path corresponding to pathIndex is obtained and recorded as currentPathList. The group nodes of currentPathList are traversed and the group nodes are placed in the first group node set, recorded as beforeLastUsedGroupSet, until the currently traversed group node is equal to the final group node (lastUsedGroupId) of the last accessed variable. At the same time, the lastUsedGroupId is placed in the beforeLastUsedGroupSet. Traverse each key and value in pathLastUserGroupMap. If beforeLastUsedGroupSet contains the current value, retrieve the group node following the current value based on the deepLinkList[key] path. The first group node not included in beforeLastUsedGroupSet is recorded as lastNodeWalk. If lastNodeWalk exists, place it in unusedGroupSet. If not, continue traversal. After constructing the unusedGroupSet, delete pathLastUserGroupMap and beforeLastUserGroupSet.

[0166] Continue with Figure 4For example, for variable aa, the target paths include the first path [1, 2, 3, 5], the second path [1, 2, 5], and the third path [1, 2, 7], and the first group node set is {1, 2, 3}. The first group node in the first path [1, 2, 3, 5] that is not in the first group node set {1, 2, 3} is group node 5, and group node 5 is saved in the recyclable group node set of variable aa, resulting in the recyclable group node set of variable aa being {5}. The first group node in the second path [1, 2, 5] that is not in the first group node set {1, 2, 3} that is not in the first group node set {1, 2, 3} is group node 5. Since group node 5 has been saved in the recyclable group node set of variable aa, the recyclable group node set of variable aa is still {5}. The first group node in the third path [1, 2, 7] that is located after the final group node 1 and is not in the first group node set {1, 2, 3} is group node 7, and group node 7 is saved in the recyclable group node set of variable aa. Therefore, the recyclable group node set of variable aa is {5, 7}.

[0167] For variable ee, the target paths include the first path [1, 2, 3, 5], the second path [1, 2, 5], and the third path [1, 2, 7], and the first group node set is {1, 2, 3, 5}. The first group node in the first path [1, 2, 3, 5] that is not in the first group node set {1, 2, 3, 5} after the final group node 5 is set to empty, and the recyclable group node set of variable ee is {}. The first group node in the second path [1, 2, 5] that is not in the first group node set {1, 2, 3, 5} after the final group node 5 is set to empty, so the recyclable group node set of variable ee is still {}. The first group node in the third path [1, 2, 7] that is not in the first group node set {1, 2, 3, 5} after the final group node 2 is set to group node 7, and group node 7 is saved in the recyclable group node set of variable ee. Therefore, the recyclable group node set of variable ee is {7}.

[0168] For the variable ff, the target path has only the third path [1, 2, 7], and the first group node set is {1, 2, 7}; the third path [1, 2, 7] is placed after the final group node 7, and the first group node that is not in the first group node set {1, 2, 7} is empty, then the recyclable group node set of the variable ff is {}.

[0169] In an embodiment of the present application, after obtaining the recyclable group node set of the variable, the first group node set of the variable can be deleted.

[0170] In step 104, based on the recyclable group node set corresponding to each variable, the recyclable variable corresponding to the current group node where the target application currently resides is determined.

[0171] After obtaining the recyclable group node set corresponding to each variable, the recyclable variable corresponding to the current group node can be determined according to the current group node corresponding to the program node currently running the target application.

[0172] In an optional embodiment of the present application, determining the recyclable variables corresponding to the current group node where the target application is currently located based on the recyclable group node set corresponding to each variable may include:

[0173] Obtain a target recyclable group node set including the current group node;

[0174] The variables corresponding to the target recyclable group node set are determined as recyclable variables.

[0175] When the current group node of the target application is within the recyclable group node set of a variable, it indicates that the current group node no longer needs to use the variable. Therefore, the variable can be treated as a recyclable variable. In the specific implementation process, the recyclable group node set corresponding to each variable can be obtained, and the recyclable group node set of each variable can be determined in turn to determine whether the current group node is included in the recyclable group node set. If so, the recyclable group node set containing the current group node is determined as the target recyclable group node set, and the variable corresponding to the target recyclable group node set is determined as the recyclable variable.

[0176] by Figure 4 For example, when the recyclable group node set is the complement of the first group node set in the directed acyclic graph, that is, the recyclable variable set of variable aa is {5, 7}, the recyclable group node set of variable ee is {7}, and the recyclable group node set of variable ff is {3, 5}; if the current group node is group node 5, then the current group node is in the recyclable group node set of variables aa and variable ff, therefore, variables aa and variable ff are determined as the recyclable variables of the current group node.

[0177] When the recyclable group node set is the complement of the first group node set in the target path corresponding to the variable, that is, the recyclable group node set of variable aa is {5, 7}, the recyclable group node set of variable ee is {7}, and the recyclable group node set of variable ff is {}; if the current group node is group node 5, then the current group node is in the recyclable group node set of variable aa, therefore, variable aa is determined as the recyclable variable of the current group node.

[0178] When the recyclable group node set is the set of the first group node that is located after the corresponding final group node in each target path and is not in the first group node set, that is, the recyclable group node set of variable aa is {5, 7}, the recyclable group node set of variable ee is {7}, and the recyclable group node set of variable ff is {}; if the current group node is group node 5, then the current group node is in the recyclable group node set of variable aa, therefore, variable aa is determined as the recyclable variable of the current group node.

[0179] In another optional embodiment of the present application, determining the recyclable variables corresponding to the current group node where the target application is currently located based on the recyclable group node set corresponding to each variable may include:

[0180] Merge the recyclable group node sets corresponding to each variable to obtain a recyclable group node set set;

[0181] The recyclable group node set corresponding to each variable is processed using a reverse mapping mechanism to obtain a recyclable variable set corresponding to each group node in the recyclable group node set, wherein the recyclable variable set includes all variables no longer used by the corresponding group node;

[0182] When the current group node is within the recyclable group node set, the recyclable variables are determined according to the recyclable variable set corresponding to the current group node.

[0183] This embodiment processes the recyclable group node set corresponding to each variable through a reverse mapping mechanism to obtain a recyclable variable set corresponding to each group node in the recyclable group node set, that is, to obtain a correspondence between each group node and its recyclable variables. Based on this correspondence, the recyclable variables of the current group node can be directly determined.

[0184] by Figure 4 For example, when the recyclable group node set is the complement of the first group node set in the directed acyclic graph, that is, the recyclable variable set of variable aa is {5, 7}, the recyclable group node set of variable ee is {7}, and the recyclable group node set of variable ff is {3, 5}; merging the recyclable group node sets corresponding to each variable can obtain a recyclable group node set set, which is {3, 5, 7}. Using the reverse mapping mechanism to process the recyclable group node sets corresponding to each variable, the recyclable variable set corresponding to group node 3 in the recyclable group node set set is {ff}, the recyclable variable set corresponding to group node 5 is {aa, ff}, and the recyclable variable set corresponding to group node 7 is {aa, ee}.

[0185] If the current group node is group node 5, and the current group node 5 is in the set of recyclable group nodes {3, 5, 7}, the recyclable variable set {aa, ff} corresponding to group node 5 obtained by the above-mentioned reverse mapping mechanism is determined as the recyclable variables of the current group node.

[0186] When the recyclable group node set is the complement of the first group node set in the target path corresponding to the variable, that is, the recyclable group node set of variable aa is {5, 7}, the recyclable group node set of variable ee is {7}, and the recyclable group node set of variable ff is {}; merging the recyclable group node sets corresponding to each variable can obtain a recyclable group node set set, which is {5, 7}. Using the reverse mapping mechanism to process the recyclable group node sets corresponding to each variable, the recyclable variable set corresponding to group node 5 in the recyclable group node set set is {aa}, and the recyclable variable set corresponding to group node 7 is {aa, ee}.

[0187] If the current group node is group node 5, and the current group node 5 is in the recyclable group node set {5, 7}, the recyclable variable set {aa} corresponding to group node 5 obtained by the above-mentioned reverse mapping mechanism is determined as the recyclable variable of the current group node.

[0188] When the recyclable group node set is the set of group nodes that are located after the corresponding final group node in each target path and are not in the first group node set, that is, the recyclable group node set of variable aa is {5, 7}, the recyclable group node set of variable ee is {7}, and the recyclable group node set of variable ff is {}; merging the recyclable group node sets corresponding to each variable can obtain a recyclable group node set set, which is {5, 7}. Using the reverse mapping mechanism to process the recyclable group node sets corresponding to each variable, the recyclable variable set corresponding to group node 5 in the recyclable group node set set is {aa}, and the recyclable variable set corresponding to group node 7 is {aa, ee}.

[0189] If the current group node is group node 5, and the current group node 5 is in the recyclable group node set {5, 7}, the recyclable variable set {aa} corresponding to group node 5 obtained by the above-mentioned reverse mapping mechanism is determined as the recyclable variable of the current group node.

[0190] In this embodiment, the recyclable variable set corresponding to each group node in the recyclable group node set is obtained through the reverse mapping mechanism. During the operation of the target application, it can be judged whether there are recyclable variables based on whether the current group node corresponding to the currently running program node is in the recyclable group node set; when there are recyclable variables, the recyclable variables corresponding to the current group node can be determined based on the correspondence between each group node and the recyclable variable set in the recyclable group node set. Since the recyclable group node set stores the set of the first group node that no longer uses the variable corresponding to each variable, the number of group nodes in the recyclable group node set can be reduced. Moreover, through the recyclable group node set in this embodiment, when the target application runs to the first group node that no longer uses the variable, it can be determined that the variable is a recyclable variable, so that the recyclable variable can be deleted in time; when the target application runs to the node after the first group node that no longer uses the variable, since the recyclable variable has been deleted in time, there is no need to perform the judgment and deletion operations again, thereby preventing repeated deletion operations.

[0191] It should be noted that if an invalid variable exists in the target application, the invalid variable can be directly determined as a recyclable variable. Invalid variables are variables that are not dependent on path usage, and can also be understood as variables that do not generate paths. Generally, invalid variables are set externally. For example, a trie tree structure can be used to determine whether a variable is an invalid variable. That is, variables in the trie tree structure are valid variables. If a variable in the target application does not exist in the trie tree structure, it can be determined that the variable is an invalid variable.

[0192] In step 105, the recyclable variables are deleted.

[0193] After determining the recyclable variables, you can directly delete the recyclable variables to clean up the memory space occupied by the variables to be deleted.

[0194] An embodiment of the present application obtains a directed acyclic graph corresponding to a target application; for each variable of the target application, determines the final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable; merges the final group nodes to determine the group nodes that no longer use the variable in each target path to obtain a recyclable group node set; based on the recyclable group node set corresponding to each variable, determines the recyclable variables corresponding to the current group node where the target application is currently located; deletes the recyclable variables; thereby achieving timely and accurate deletion of variables after the end of their life cycle to clear the memory space occupied by such variables.

[0195] It should be noted that for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.

[0196] Reference Figure 5 , shows a structural block diagram of an embodiment of a data processing device of the present application, corresponding to the above-mentioned embodiment of the data processing method, the data processing device may include the following modules:

[0197] A directed acyclic graph acquisition module 501 is used to acquire a directed acyclic graph corresponding to a target application;

[0198] A final group node determination module 502 is configured to determine, for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable;

[0199] A recyclable node determination module 503 is configured to merge the final group nodes to determine the group nodes that no longer use the variable in each target path, thereby obtaining a recyclable group node set;

[0200] A recyclable variable determination module 504 is configured to determine, based on a set of recyclable group nodes corresponding to each variable, a recyclable variable corresponding to a current group node where the target application currently resides;

[0201] The recyclable variable deletion module 505 is used to delete the recyclable variables.

[0202] In an optional embodiment of the present application, the directed acyclic graph acquisition module 501 includes:

[0203] A program node acquisition module, configured to acquire a plurality of program nodes included in the target application;

[0204] A directed graph generation module based on program nodes, configured to generate a directed graph corresponding to the target application according to the program nodes and the execution order of the program nodes;

[0205] a de-looping processing module, configured to, when a directed loop exists in the directed graph, perform de-looping on the directed graph to obtain a directed acyclic graph corresponding to the target application;

[0206] The directed acyclic graph determination module is used to determine that the directed graph is a directed acyclic graph corresponding to the target application when there is no directed cycle in the directed graph.

[0207] In an optional embodiment of the present application, the de-ringing processing module includes:

[0208] A traversal grouping module is used to perform a depth-first traversal on the directed graph to determine the group to which each node belongs;

[0209] The same group node merging module is used to de-loop the directed graph according to the groups to which the nodes belong, so as to obtain a corresponding directed acyclic graph; the nodes in the directed acyclic graph are group nodes, and the nodes that form the same ring in the directed graph are classified into the same group node in the directed acyclic graph.

[0210] In an optional embodiment of the present application, the traversal grouping module includes:

[0211] A first processing module is configured to perform a depth-first traversal on the directed graph, store the traversed nodes in a first set, and record the traversed depth paths in a bidirectional linked list;

[0212] A second processing module is configured to determine, when traversing each node, whether a current node currently traversed exists in the first set, and if so, determine a node subsequent to the current node based on the traversed depth path recorded in the bidirectional linked list;

[0213] The third processing module is configured to merge the nodes subsequent to the current node into the group where the current node is located.

[0214] In an optional embodiment of the present application, the final group node determination module 502 includes:

[0215] An all-path determination module is configured to perform a depth-first traversal on the directed acyclic graph to determine multiple paths corresponding to the root group node of the directed acyclic graph to each leaf group node;

[0216] a target path determination module, configured to obtain, for each variable of the target application, a target path using the variable in the directed acyclic graph;

[0217] The module for determining a final group node based on a target path is used to determine, for each target path, a final group node that last uses the variable in the target path when the target application runs according to the target path.

[0218] In an optional embodiment of the present application, the recyclable node determination module 503 includes:

[0219] A group node merging module has been used to merge the final group nodes to obtain a first node set, wherein the first node set includes the final group node corresponding to each target path and the group node before the corresponding final group node;

[0220] A first recyclable group node determination module is used to determine a recyclable group node set that no longer uses the variable based on the directed acyclic graph and the first group node set, wherein the recyclable group node set is the complement of the first group node set in the directed acyclic graph, or the recyclable group node set is the complement of the first group node set in the target path corresponding to the variable.

[0221] In an optional embodiment of the present application, the recyclable node determination module 503 includes:

[0222] A group node merging module has been used to merge the final group nodes to obtain a first node set, wherein the first node set includes the final group node corresponding to each target path and the group node before the corresponding final group node;

[0223] The second recyclable group node determination module is configured to obtain the first group node that is located after the corresponding final group node in each target path and is not in the first group node set, so as to obtain a recyclable group node set.

[0224] In an optional embodiment of the present application, the recyclable variable determination module 504 includes:

[0225] A target recyclable group node set determining module is used to obtain a target recyclable group node set including the current group node;

[0226] The first recyclable variable determination module is configured to determine the variables corresponding to the target recyclable group node set as recyclable variables.

[0227] In an optional embodiment of the present application, the recyclable variable determination module 504 includes:

[0228] A recyclable group node set determination module is used to merge the recyclable group node sets corresponding to each variable to obtain a recyclable group node set;

[0229] A module for determining a recyclable variable set based on reverse mapping, configured to process the recyclable group node set corresponding to each variable using a reverse mapping mechanism to obtain a recyclable variable set corresponding to each group node in the recyclable group node set, wherein the recyclable variable set includes all variables no longer used by the corresponding group node;

[0230] The second recyclable variable determination module is configured to determine the recyclable variables according to the recyclable variable set corresponding to the current group node when the current group node is within the recyclable group node set.

[0231] 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 partial description of the method embodiment.

[0232] An embodiment of the present application also discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the data processing method described above when executed by the processor.

[0233] The embodiment of the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data processing method described above are implemented.

[0234] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0235] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0236] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0237] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0238] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0239] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0240] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0241] The above is a detailed introduction to a data processing method and device, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present application.

Claims

1. A data processing method, characterized in that: The method comprises: Get the directed acyclic graph corresponding to the target application; For each variable of the target application, determining a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable; the variables include variables generated by a code combination used by the target application to implement a preset function, and variables involved in jumps between the code combinations; Merging the final group nodes to determine the group nodes that no longer use the variables in each target path, and obtaining a recyclable group node set; Determine, based on the recyclable group node set corresponding to each variable, the recyclable variable corresponding to the current group node where the target application is currently located; Delete the recyclable variable.

2. The method according to claim 1, characterized in that Obtaining a directed acyclic graph corresponding to the target application includes: Acquire multiple program nodes included in the target application; Generating a directed graph corresponding to the target application according to the program nodes and the execution order of the program nodes; When a directed cycle exists in the directed graph, de-cyclic processing is performed on the directed graph to obtain a directed acyclic graph corresponding to the target application; When there is no directed cycle in the directed graph, it is determined that the directed graph is a directed acyclic graph corresponding to the target application.

3. The method according to claim 2, characterized in that When a directed cycle exists in the directed graph, performing a de-cyclic process on the directed graph to obtain a directed acyclic graph corresponding to the target application program includes: Performing a depth-first traversal on the directed graph to determine the group to which each node belongs; The directed graph is de-looped according to the groups to which the nodes belong, to obtain a corresponding directed acyclic graph; the nodes in the directed acyclic graph are group nodes, and the nodes that form the same loop in the directed graph are included in the same group node in the directed acyclic graph.

4. The method according to claim 3, characterized in that The performing a depth-first traversal on the directed graph to determine the group to which each node belongs includes: Performing a depth-first traversal on the directed graph, storing the traversed nodes in a first set, and using a doubly linked list to record the traversed depth path; When traversing each node, determine whether the current traversed node exists in the first set, and if so, determine the node after the current node based on the traversed depth path recorded in the doubly linked list; The nodes following the current node are merged into the group where the current node is located.

5. The method according to claim 1, characterized in that The step of determining, for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable, includes: Performing a depth-first traversal on the directed acyclic graph to determine multiple paths corresponding to the root group node of the directed acyclic graph to each leaf group node; For each variable of the target application, obtaining a target path in the directed acyclic graph that uses the variable; For each target path, a final group node that last uses the variable in the target path when the target application runs according to the target path is determined.

6. The method according to claim 5, characterized in that The merging of the final group nodes to determine the group nodes that no longer use the variable in each target path to obtain a recyclable group node set includes: Merging the final group nodes to obtain a first node set, where the first node set includes the final group node corresponding to each target path and the group nodes before the corresponding final group node; Based on the directed acyclic graph and the first group of node sets, a recyclable group of node sets that no longer uses the variable is determined, the recyclable group of node sets being the complement of the first group of node sets in the directed acyclic graph, or the recyclable group of node sets being the complement of the first group of node sets in the target path corresponding to the variable.

7. The method according to claim 5, characterized in that The merging of the final group nodes to determine the group nodes that no longer use the variable in each target path to obtain a recyclable group node set includes: Merging the final group nodes to obtain a first node set, where the first node set includes the final group node corresponding to each target path and the group nodes before the corresponding final group node; The first group node that is located after the corresponding final group node in each target path and is not in the first group node set is obtained to obtain a recyclable group node set.

8. The method according to claim 6 or 7, characterized in that The determining, based on the recyclable group node set corresponding to each variable, the recyclable variable corresponding to the current group node where the target application is currently located, includes: Obtain a target recyclable group node set including the current group node; The variables corresponding to the target recyclable group node set are determined as recyclable variables.

9. The method according to claim 6 or 7, characterized in that The determining, based on the recyclable group node set corresponding to each variable, the recyclable variable corresponding to the current group node where the target application is currently located, includes: Merge the recyclable group node sets corresponding to each variable to obtain a recyclable group node set set; The recyclable group node set corresponding to each variable is processed using a reverse mapping mechanism to obtain a recyclable variable set corresponding to each group node in the recyclable group node set, wherein the recyclable variable set includes all variables no longer used by the corresponding group node; When the current group node is within the recyclable group node set, the recyclable variables are determined according to the recyclable variable set corresponding to the current group node.

10. A data processing device, characterized in that: The device comprises: A directed acyclic graph acquisition module is used to obtain the directed acyclic graph corresponding to the target application; a final group node determination module configured to determine, for each variable of the target application, a final group node that last uses the variable in each target path of the directed acyclic graph that uses the variable; the variables comprising variables generated by a code combination used by the target application to implement a preset function, and variables involved in jumps between the code combinations; a recyclable node determination module, configured to merge the final group nodes to determine the group nodes that no longer use the variables in each target path, and obtain a recyclable group node set; A recyclable variable determination module is used to determine the recyclable variable corresponding to the current group node where the target application is currently located according to the recyclable group node set corresponding to each variable; The recyclable variable deletion module is used to delete the recyclable variables.

11. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the data processing method according to any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • SQL workflow processing method and device, electronic equipment and storage medium

    CN112347122A

  • Task circulation direction identification method and system, electronic equipment and storage medium

    CN114327692A