Disclosure of Invention
In order to solve the technical problems, the invention provides a method, a system, equipment and a storage medium for visual analysis and management of a JavaScript memory. The invention provides an effective way for conveniently and visually analyzing the problems of memory leakage and the like, reduces the learning cost and the labor cost of performance analysis and optimization of the code by JavaScript developers, and is beneficial to the front-end development team to control the code performance integrally and improve the code quality.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
The visual analysis and management method of the JavaScript memory comprises the following steps:
Analyzing the JavaScript object code to generate a corresponding abstract syntax tree and a scope of the variable;
Running the JavaScript object code, and recording the execution context stack and heap memory snapshot information in the code running process;
And rendering the occupation condition of the JavaScript heap memory in real time according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, and drawing a call relation diagram among variable nodes in the scope.
Further, when the JavaScript object code is analyzed to generate the corresponding abstract syntax tree and the scope of the variable, the JavaScript object code is statically analyzed according to a common memory leakage tracking library, and the scope of the problem that leakage is possibly caused is marked.
Further, the method further comprises the step of giving optimization suggestions of the JavaScript object code according to the result of static analysis of the JavaScript object code.
Furthermore, the method further comprises the steps of automatically updating the common memory leakage tracking library according to a self-learning method, automatically identifying memory leakage problems according to the updated common memory leakage tracking library, and sending corresponding early warning information and positioning problem nodes.
Further, the specific process of running the JavaScript object code and recording the execution context stack and heap memory snapshot information in the code running process is as follows:
Running the JavaScript object code, recording a heap memory snapshot of the problem action domain and recording a heap memory snapshot of the non-problem action domain;
Recording the execution context stack and heap memory snapshot information in the code running process, updating the memory snapshot information regularly if the memory is normal, and continuously recording the memory snapshot information at fixed time intervals if the memory is abnormal;
and monitoring and recording system-level monitoring information and garbage collection mechanism conditions in the code executing process.
Further, the specific process of rendering the call relation graph among the variable nodes in the scope according to the abstract syntax tree, the execution context stack and the heap memory snapshot information and rendering the JavaScript heap memory occupation condition in real time is as follows:
drawing a call relation diagram among variable nodes in the scope according to the abstract syntax tree and the execution upper and lower Wen Zhan, and marking a garbage recycling condition;
in the call relation diagram, the memory health state of the node is identified;
And rendering JavaScript memory data at a target moment according to the heap memory snapshot information, and rendering a visual chart of indexes such as a system level memory and the like in real time.
Further, in the call relation diagram, the method for identifying the memory health state of the node is as follows:
Gray is adopted to indicate that the variable node experiences a complete memory life cycle;
Yellow is adopted to indicate that the variable node still has references and is stored in the memory at present;
The free variable nodes are indicated by red.
The invention also provides a JavaScript memory visual analysis and management system, which comprises a code pre-analysis device, a data acquisition device and a visual rendering device;
the code pre-analysis device is used for analyzing the JavaScript object code and generating a corresponding abstract syntax tree and a scope of the variable;
The data acquisition device is used for running the JavaScript object code and recording the execution context stack and heap memory snapshot information in the code running process;
the visual rendering device is used for rendering the occupation condition of the JavaScript heap memory in real time according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, and drawing a call relation diagram among variable nodes in the scope.
The invention also proposes a device comprising:
a memory for storing a computer program;
and a processor for implementing method steps when executing the computer program.
The invention also proposes a readable storage medium on which a computer program is stored, which computer program when being executed by a processor realizes the method steps.
The effects provided in the summary of the invention are merely effects of embodiments, not all effects of the invention, and one of the above technical solutions has the following advantages or beneficial effects:
The invention provides a visual analysis and management method, a visual analysis and management system, visual analysis and management equipment for a JavaScript memory and a visual analysis and management storage medium for the JavaScript memory, wherein the visual analysis and management method comprises the steps of analyzing JavaScript object codes to generate corresponding abstract syntax trees and action fields of variables; and according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, rendering the occupation condition of the JavaScript heap memory in real time, and drawing a call relation diagram among variable nodes in the scope. The method also comprises the steps of statically analyzing the JavaScript object code according to the common memory leakage tracking library, marking a problem scope which is likely to cause leakage, automatically updating the common memory leakage tracking library according to a self-learning method, automatically identifying the memory leakage problem according to the updated common memory leakage tracking library, and sending corresponding early warning information and positioning problem nodes. The invention can render the memory monitoring data and save the heap memory snapshot when the JavaScript code runs in real time on the one hand, and can draw the relation diagram of the execution upper and lower Wen Zhan (call stack) of the JavaScript code and identify the problem node and the call path thereof on the other hand, so that JavaScript developers can simply and clearly know the bottom operation performed in the code execution process and visually track the change of the occupation condition of the memory. Through pre-analyzing the JavaScript code, collecting and recording heap memory snapshots and executing the upper and lower Wen Zhan when the code runs, an effective way for conveniently and visually analyzing the problems of memory leakage and the like is provided for JavaScript developers, the learning cost and the labor cost for the JavaScript developers to perform performance analysis and optimization on the code are reduced, the front-end development team is facilitated to integrally control the code performance, the code quality is improved, and meanwhile, the common memory problem library is continuously updated through a self-learning algorithm, and the technology and experience accumulation of the company development team are facilitated.
Based on the visual analysis and management method of the JavaScript memory, a visual analysis and management system of the JavaScript memory, a device and a storage medium are also provided. The method also has the functions of the method and is not described in detail herein.
Detailed Description
In order to clearly illustrate the technical features of the present solution, the present invention will be described in detail below with reference to the following detailed description and the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different structures of the invention. In order to simplify the present disclosure, components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and processes are omitted so as to not unnecessarily obscure the present invention.
Example 1
The embodiment 1 of the invention provides a visual analysis and management method for a JavaScript memory, which can be used for rendering memory monitoring data and saving heap memory snapshots in real time when the JavaScript code runs, drawing a relation diagram of execution upper and lower Wen Zhan (call stack) of the JavaScript code, marking out problem nodes and call paths thereof, and enabling JavaScript developers to simply and clearly know the bottom operation performed in the code execution process and visually track the change of the occupation condition of the memory.
FIG. 1 is a path diagram of a visual analysis and management method for a JavaScript memory according to an embodiment 1 of the present invention;
in step S101, parsing the JavaScript object code to generate a corresponding abstract syntax tree and scope of the variable;
In the step, firstly, lexical analysis and grammar analysis are carried out on JavaScript codes, and corresponding AST abstract grammar trees, the scope of the variables and the scope chain of the functions are generated.
Wherein the Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of the source code, which represents the syntax structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code.
According to a common memory leakage tracking library, the JavaScript object code is statically analyzed, and a problem scope which possibly causes leakage is marked for subsequent analysis and tracking.
In step S102, javaScript object code is run, and execution context stack and heap memory snapshot information in the code running process are recorded. And running JavaScript codes, and recording heap memory snapshots of a problem scope or other target scopes focused by a code preresolved device according to the requirements of developers. Meanwhile, in the execution process of the JavaScript code, the corresponding ECS execution upper and lower Wen Zhan are synchronously recorded so as to observe the call depth of the target scope and track the reference relation of the target node.
Wherein the execution context Wen Zhan (ECS), also called call stack, is used to store all execution contexts created during code execution, with the characteristics of LIFO (last in first out). And each time a function call occurs, a corresponding function execution context is created and pushed to a call stack, the execution context at the top of the call stack is destroyed and the control right of the context is transferred to the execution context at the top of a new call stack.
The execution process of the steps is as follows:
Running JavaScript object codes, recording heap memory snapshots of problem action domains and recording heap memory snapshots of non-problem action domains;
Recording execution context Wen Zhan in the code running process, focusing on memory change in the execution context changing process so as to follow up the reference relation of the tracking node;
Recording heap memory snapshot information in the code running process, updating the memory snapshot information regularly if the memory is normal, and continuously recording the memory snapshot information at fixed time intervals if the memory is abnormal;
And monitoring and recording system-level monitoring information and garbage collection mechanism conditions in the code execution process, so that the memory condition can be conveniently compared and analyzed. The system level monitoring information comprises indexes such as a system memory, CPU utilization rate and the like.
In step S103, according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, the JavaScript heap memory occupation situation is rendered in real time, and a call relation diagram between variable nodes in the scope is drawn.
The visual rendering device loads heap memory snapshot information stored by the data acquisition device, an AST abstract syntax tree and an ECS scope chain, renders the occupation condition of the JavaScript heap memory in real time, draws a call relation diagram among variable nodes in the scope and marks garbage collection paths and problem nodes. FIG. 2 is a schematic diagram of a memory stack of JavaScript data type of embodiment 1 of the invention, wherein the JavaScript data type is divided into a basic data type and a reference data type, the basic type comprises Undefined, null, boolean, number, string and Symbol, and the reference type comprises Object;
The JavaScript memory space comprises a JavaScript memory using Stack memory (Stack) and a Heap memory (Heap), wherein the Stack memory provides an environment for JavaScript code execution and stores basic data types, and the Heap memory stores reference data types.
The specific implementation process of the method comprises the steps of drawing a call relation diagram among variable nodes in a scope according to an abstract syntax tree and execution upper and lower Wen Zhan, and marking a garbage collection condition, wherein the garbage collection comprises a reference counting method and a mark clearing method.
In the call relation diagram, the memory health state of the node is identified, and in the call relation diagram, the method for identifying the memory health state of the node is as follows:
gray is adopted to indicate that the variable node experiences a complete memory life cycle, wherein the memory life cycle comprises memory allocation, memory use and memory recovery;
Yellow is adopted to indicate that the variable node still has references and is stored in the memory at present;
The free variable nodes are indicated by red.
And rendering JavaScript memory data at the target moment according to the heap memory snapshot information, and rendering a visual chart of indexes such as a system level memory and the like in real time. Wherein the visualization graphs include, but are not limited to, line graphs, bar graphs, and stack graphs.
In step S104, the common memory leakage tracking library is automatically updated according to the self-learning method, the memory leakage problem is automatically identified according to the updated common memory leakage tracking library, and corresponding early warning information and positioning problem nodes are sent out, namely, the scope and calling path of the variable nodes are recorded, or code optimization suggestions are given according to the static analysis result. The memory leakage is a memory which is not used any more, and is not released in time, so that the memory leakage is caused;
According to the visual analysis and management method for the JavaScript memory, through pre-analyzing the JavaScript code, collecting and recording the heap memory snapshot and executing the upper and lower Wen Zhan when the code runs, an effective way for conveniently and visually analyzing the problems of memory leakage and the like is provided for JavaScript developers, the learning cost and the labor cost for the JavaScript developers to perform performance analysis and optimization on the code are reduced, the front-end development team is facilitated to integrally control the code performance, the code quality is improved, and meanwhile, the common memory problem library is continuously updated through a self-learning algorithm, and the technology and experience accumulation of the company development team are facilitated.
Example 2
Based on the visual analysis and management method of the JavaScript memory provided by the embodiment 1 of the present invention, the embodiment 2 of the present invention also provides a visual analysis and management system of the JavaScript memory, as shown in fig. 3, a schematic diagram of the visual analysis and management system of the JavaScript memory provided by the embodiment 2 of the present invention is provided, and the system comprises a code pre-analysis device, a data acquisition device and a visual rendering device;
The code pre-analysis device is used for analyzing the JavaScript object code to generate a corresponding abstract syntax tree and a scope of the variable;
The data acquisition device is used for running JavaScript object codes and recording execution context stacks and heap memory snapshot information in the code running process;
The visual rendering device is used for rendering the occupation condition of the JavaScript heap memory in real time according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, and drawing a call relation diagram among variable nodes in the scope.
The system also comprises a memory leakage early warning device, wherein the memory leakage early warning device is used for automatically updating a common memory leakage tracking library according to a self-learning method, automatically identifying a memory leakage problem according to the updated common memory leakage tracking library, and sending out corresponding early warning information and positioning problem nodes.
The code pre-analysis device is used for performing lexical analysis and grammar analysis on the JavaScript code to generate a corresponding AST abstract grammar tree, a scope of a variable and a scope chain of a function.
Wherein the Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of the source code, which represents the syntax structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code.
According to a common memory leakage tracking library, the JavaScript object code is statically analyzed, and a problem scope which possibly causes leakage is marked for subsequent analysis and tracking.
The data acquisition device is used for running JavaScript codes, and recording heap memory snapshots of a problem acting domain or other target acting domains focused by the code pre-analysis device according to the requirements of developers. Meanwhile, in the execution process of the JavaScript code, the corresponding ECS execution upper and lower Wen Zhan are synchronously recorded so as to observe the call depth of the target scope and track the reference relation of the target node.
Wherein the execution context Wen Zhan (ECS), also called call stack, is used to store all execution contexts created during code execution, with the characteristics of LIFO (last in first out). And each time a function call occurs, a corresponding function execution context is created and pushed to a call stack, the execution context at the top of the call stack is destroyed and the control right of the context is transferred to the execution context at the top of a new call stack.
Running JavaScript object codes, recording heap memory snapshots of problem action domains and recording heap memory snapshots of non-problem action domains;
Recording execution context Wen Zhan in the code running process, focusing on memory change in the execution context changing process so as to follow up the reference relation of the tracking node;
Recording heap memory snapshot information in the code running process, updating the memory snapshot information regularly if the memory is normal, and continuously recording the memory snapshot information at fixed time intervals if the memory is abnormal;
And monitoring and recording system-level monitoring information and garbage collection mechanism conditions in the code execution process, so that the memory condition can be conveniently compared and analyzed. The system level monitoring information comprises indexes such as a system memory, CPU utilization rate and the like.
The visual rendering device loads heap memory snapshot information stored by the data acquisition device, an AST abstract syntax tree and an ECS scope chain, renders the occupation condition of the JavaScript heap memory in real time, draws a call relation diagram among variable nodes in the scope and marks garbage collection paths and problem nodes.
Drawing a call relation diagram among variable nodes in a scope according to an abstract syntax tree and execution upper and lower Wen Zhan, and marking garbage recycling conditions;
in the call relation diagram, the memory health state of the node is identified, and in the call relation diagram, the method for identifying the memory health state of the node is as follows:
Gray is adopted to indicate that the variable node experiences a complete memory life cycle;
Yellow is adopted to indicate that the variable node still has references and is stored in the memory at present;
The free variable nodes are indicated by red.
And rendering JavaScript memory data at the target moment according to the heap memory snapshot information, and rendering a visual chart of indexes such as a system level memory and the like in real time. Wherein the visualization graphs include, but are not limited to, line graphs, bar graphs, and stack graphs.
The memory leakage early warning device comprises the specific implementation processes of automatically updating a common memory leakage tracking library according to a self-learning method, automatically identifying a memory leakage problem according to the updated common memory leakage tracking library, and sending out corresponding early warning information and positioning problem nodes, namely recording the action scope, the calling path and the like of variable nodes, or giving out code optimization suggestions according to a static analysis result.
Example 3
The invention also provides visual analysis and management of the JavaScript memory, which comprises the following steps:
a memory for storing a computer program;
The processor is used for realizing the following steps when executing the computer program:
in step S101, parsing the JavaScript object code to generate a corresponding abstract syntax tree and scope of the variable;
In the step, firstly, lexical analysis and grammar analysis are carried out on JavaScript codes, and corresponding AST abstract grammar trees, the scope of the variables and the scope chain of the functions are generated.
Wherein the Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of the source code, which represents the syntax structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code.
According to a common memory leakage tracking library, the JavaScript object code is statically analyzed, and a problem scope which possibly causes leakage is marked for subsequent analysis and tracking.
In step S102, javaScript object code is run, and execution context stack and heap memory snapshot information in the code running process are recorded. And running JavaScript codes, and recording heap memory snapshots of a problem scope or other target scopes focused by a code preresolved device according to the requirements of developers. Meanwhile, in the execution process of the JavaScript code, the corresponding ECS execution upper and lower Wen Zhan are synchronously recorded so as to observe the call depth of the target scope and track the reference relation of the target node.
Wherein the execution context Wen Zhan (ECS), also called call stack, is used to store all execution contexts created during code execution, with the characteristics of LIFO (last in first out). And each time a function call occurs, a corresponding function execution context is created and pushed to a call stack, the execution context at the top of the call stack is destroyed and the control right of the context is transferred to the execution context at the top of a new call stack.
The execution process of the steps is as follows:
Running the JavaScript object code, recording a heap memory snapshot of the problem action domain and recording a heap memory snapshot of the non-problem action domain;
Recording execution context Wen Zhan in the code running process, focusing on memory change in the execution context changing process so as to follow up the reference relation of the tracking node;
Recording heap memory snapshot information in the code running process, updating the memory snapshot information regularly if the memory is normal, and continuously recording the memory snapshot information at fixed time intervals if the memory is abnormal;
And monitoring and recording system-level monitoring information and garbage collection mechanism conditions in the code execution process, so that the memory condition can be conveniently compared and analyzed. The system level monitoring information comprises indexes such as a system memory, CPU utilization rate and the like.
In step S103, according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, the JavaScript heap memory occupation situation is rendered in real time, and a call relation diagram between variable nodes in the scope is drawn.
The visual rendering device loads heap memory snapshot information stored by the data acquisition device, an AST abstract syntax tree and an ECS scope chain, renders the occupation condition of the JavaScript heap memory in real time, draws a call relation diagram among variable nodes in the scope and marks garbage collection paths and problem nodes.
Drawing a call relation diagram among variable nodes in a scope according to an abstract syntax tree and execution upper and lower Wen Zhan, and marking garbage recycling conditions;
in the call relation diagram, the memory health state of the node is identified, and in the call relation diagram, the method for identifying the memory health state of the node is as follows:
Gray is adopted to indicate that the variable node experiences a complete memory life cycle;
Yellow is adopted to indicate that the variable node still has references and is stored in the memory at present;
The free variable nodes are indicated by red.
And rendering JavaScript memory data at the target moment according to the heap memory snapshot information, and rendering a visual chart of indexes such as a system level memory and the like in real time. Wherein the visualization graphs include, but are not limited to, line graphs, bar graphs, and stack graphs.
In step S104, the common memory leakage tracking library is automatically updated according to the self-learning method, the memory leakage problem is automatically identified according to the updated common memory leakage tracking library, and corresponding early warning information and positioning problem nodes are sent out, namely, the scope and calling path of the variable nodes are recorded, or code optimization suggestions are given according to the static analysis result.
It should be noted that the technical scheme of the application also provides electronic equipment, which comprises a communication interface capable of carrying out information interaction with other equipment such as network equipment and the like, and a processor connected with the communication interface so as to realize information interaction with other equipment, wherein the processor is used for executing the visual analysis and management method of the JavaScript memory provided by one or more technical schemes when running a computer program, and the computer program is stored on a memory. Of course, in practice, the various components in the electronic device are coupled together by a bus system. It will be appreciated that a bus system is used to enable connected communications between these components. The bus system includes a power bus, a control bus, and a status signal bus in addition to the data bus. The memory in the embodiments of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program for operating on an electronic device. It will be appreciated that the memory can be either volatile memory or nonvolatile memory, and can include both volatile and nonvolatile memory. The non-volatile Memory may be, among other things, a Read Only Memory (ROM), a programmable Read Only Memory (PROM, programmable Read-Only Memory), erasable programmable Read-Only Memory (EPROM, erasable Programmable Read-Only Memory), electrically erasable programmable Read-Only Memory (EEPROM, ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory), magnetic random access Memory (FRAM, ferromagnetic random access Memory), flash Memory (Flash Memory), magnetic surface Memory, optical disk, or compact disk-Only Memory (CD-ROM, compact Disc Read-Only Memory), which may be disk Memory or tape Memory. the volatile memory may be random access memory (RAM, random AccessMemory) which acts as external cache memory. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM, static Random Access Memory), synchronous static random access memory (SSRAM, synchronous Static Random Access Memory), dynamic random access memory (DRAM, dynamic Random Access Memory), synchronous dynamic random access memory (SDRAM, synchronousDynamic Random Access Memory), and so forth, double data rate synchronous dynamic random access memory (DDRSDRAM, double Data Rate Synchronous Dynamic Random Access Memory), enhanced synchronous dynamic random access memory (ESDRAM, enhanced Synchronous Dynamic Random Access Memory), synchronous link dynamic random access memory (SLDRAM, syncLink Dynamic Random Access Memory), direct memory bus random access memory (DRRAM, direct Rambus Random Access Memory). The memory described by embodiments of the present application is intended to comprise, without being limited to, these and any other suitable types of memory. The method disclosed by the embodiment of the application can be applied to a processor or realized by the processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general purpose processor, a DSP (DIGITAL SIGNAL Processing, i.e., a chip capable of implementing digital signal Processing techniques), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The processor may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the present application. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiment of the application can be directly embodied in the hardware of the decoding processor or can be implemented by combining hardware and software modules in the decoding processor. The software modules may be located in a storage medium having a memory, and the processor reads the program in the memory and performs the steps of the method in combination with its hardware. The corresponding flow in each method of the embodiments of the present application is implemented when the processor executes the program, and for brevity, will not be described in detail herein.
Example 4
The invention also provides a readable storage medium, the readable storage medium stores a computer program, and the computer program when executed by a processor realizes the following steps:
in step S101, parsing the JavaScript object code to generate a corresponding abstract syntax tree and scope of the variable;
In the step, firstly, lexical analysis and grammar analysis are carried out on JavaScript codes, and corresponding AST abstract grammar trees, the scope of the variables and the scope chain of the functions are generated.
Wherein the Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of the source code, which represents the syntax structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code.
According to a common memory leakage tracking library, the JavaScript object code is statically analyzed, and a problem scope which possibly causes leakage is marked for subsequent analysis and tracking.
In step S102, javaScript object code is run, and execution context stack and heap memory snapshot information in the code running process are recorded. And running JavaScript codes, and recording heap memory snapshots of a problem scope or other target scopes focused by a code preresolved device according to the requirements of developers. Meanwhile, in the execution process of the JavaScript code, the corresponding ECS execution upper and lower Wen Zhan are synchronously recorded so as to observe the call depth of the target scope and track the reference relation of the target node.
Wherein the execution context Wen Zhan (ECS), also called call stack, is used to store all execution contexts created during code execution, with the characteristics of LIFO (last in first out). And each time a function call occurs, a corresponding function execution context is created and pushed to a call stack, the execution context at the top of the call stack is destroyed and the control right of the context is transferred to the execution context at the top of a new call stack.
The execution process of the steps is as follows:
Running JavaScript object codes, recording heap memory snapshots of problem action domains and recording heap memory snapshots of non-problem action domains;
Recording execution context Wen Zhan in the code running process, focusing on memory change in the execution context changing process so as to follow up the reference relation of the tracking node;
Recording heap memory snapshot information in the code running process, updating the memory snapshot information regularly if the memory is normal, and continuously recording the memory snapshot information at fixed time intervals if the memory is abnormal;
And monitoring and recording system-level monitoring information and garbage collection mechanism conditions in the code execution process, so that the memory condition can be conveniently compared and analyzed. The system level monitoring information comprises indexes such as a system memory, CPU utilization rate and the like.
In step S103, according to the abstract syntax tree, the execution context stack and the heap memory snapshot information, the JavaScript heap memory occupation situation is rendered in real time, and a call relation diagram between variable nodes in the scope is drawn.
The visual rendering device loads heap memory snapshot information stored by the data acquisition device, an AST abstract syntax tree and an ECS scope chain, renders the occupation condition of the JavaScript heap memory in real time, draws a call relation diagram among variable nodes in the scope and marks garbage collection paths and problem nodes.
Drawing a call relation diagram among variable nodes in a scope according to an abstract syntax tree and execution upper and lower Wen Zhan, and marking garbage recycling conditions;
in the call relation diagram, the memory health state of the node is identified, and in the call relation diagram, the method for identifying the memory health state of the node is as follows:
Gray is adopted to indicate that the variable node experiences a complete memory life cycle;
Yellow is adopted to indicate that the variable node still has references and is stored in the memory at present;
The free variable nodes are indicated by red.
And rendering JavaScript memory data at the target moment according to the heap memory snapshot information, and rendering a visual chart of indexes such as a system level memory and the like in real time. Wherein the visualization graphs include, but are not limited to, line graphs, bar graphs, and stack graphs.
In step S104, the common memory leakage tracking library is automatically updated according to the self-learning method, the memory leakage problem is automatically identified according to the updated common memory leakage tracking library, and corresponding early warning information and positioning problem nodes are sent out, namely, the scope and calling path of the variable nodes are recorded, or code optimization suggestions are given according to the static analysis result.
The description of relevant parts in the JavaScript memory visual analysis and management device and the storage medium provided by the embodiment of the application can be referred to the detailed description of corresponding parts in the JavaScript memory visual analysis and management method provided by the embodiment 1 of the application, and will not be repeated here.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements is inherent to. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element. In addition, the parts of the above technical solutions provided in the embodiments of the present application, which are consistent with the implementation principles of the corresponding technical solutions in the prior art, are not described in detail, so that redundant descriptions are avoided.
While the specific embodiments of the present invention have been described above with reference to the drawings, the scope of the present invention is not limited thereto. Other modifications and variations to the present invention will be apparent to those of skill in the art upon review of the foregoing description. It is not necessary here nor is it exhaustive of all embodiments. On the basis of the technical scheme of the invention, various modifications or variations which can be made by the person skilled in the art without the need of creative efforts are still within the protection scope of the invention.