CN110334031B - Memory allocation code detection method and device, computer equipment and storage medium - Google Patents

Memory allocation code detection method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN110334031B
CN110334031B CN201910642148.8A CN201910642148A CN110334031B CN 110334031 B CN110334031 B CN 110334031B CN 201910642148 A CN201910642148 A CN 201910642148A CN 110334031 B CN110334031 B CN 110334031B
Authority
CN
China
Prior art keywords
code
memory allocation
intermediate language
instruction
position information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910642148.8A
Other languages
Chinese (zh)
Other versions
CN110334031A (en
Inventor
程耀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910642148.8A priority Critical patent/CN110334031B/en
Publication of CN110334031A publication Critical patent/CN110334031A/en
Application granted granted Critical
Publication of CN110334031B publication Critical patent/CN110334031B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a memory allocation code detection method, a device, a computer device and a storage medium. Therefore, the scheme can determine the position information of the memory allocation code in the application program to be detected through the target intermediate language code. The memory allocation code detection method provided by the application does not need to run an application program or exhaust each operation condition of the application program, so that the operation is simple and convenient, and the problem of incomplete memory allocation code detection can be avoided.

Description

Memory allocation code detection method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and apparatus for detecting a memory allocation code, a computer device, and a storage medium.
Background
Applications typically use memory to store data at runtime, and when the stored data is no longer used, the GC (Garbage Collection ) mechanism releases the memory space occupied by the data so that this portion of memory space can continue to be used.
In the running process of the application program, if the memory allocation operation is too much or too frequent, garbage collection is triggered, and the garbage collection can cause bad performances such as operation blocking, so how to detect the memory allocation code in the application program code is a technical problem to be solved by those skilled in the art.
Disclosure of Invention
In view of the above, the present application provides a method, apparatus, computer device and storage medium for detecting memory allocation codes in application codes.
In order to achieve the above object, in one aspect, the present application provides a method for detecting a memory allocation code, including:
acquiring an intermediate language code to be detected, wherein the intermediate language code to be detected is an intermediate language code obtained by compiling an application program code to be detected;
determining an instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code of a corresponding memory allocation code;
And determining memory allocation code position information by using the target intermediate language code, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected.
Optionally, after determining the memory allocation code location information of the memory allocation code in the application program code to be detected by using the target intermediate language code, the method further includes:
determining a last modified account by using the memory allocation code position information, wherein the last modified account is an account for last modifying the memory allocation codes of each row;
and sending corresponding memory allocation code position information and memory allocation code modification instructions to a code editing system corresponding to each last modification account so that the code editing system modifies the memory allocation codes.
Optionally, the sending, to the code editing system corresponding to each last modified account, a memory allocation code modification instruction and corresponding memory allocation code location information includes:
and transmitting a memory allocation code modification instruction and corresponding memory allocation code position information to a code editing system corresponding to each last modification account by using an API of a preset task distribution system.
Optionally, the determining the memory allocation code location information by using the target intermediate language code includes:
and determining the line number and the function name of the memory allocation code in the application program code to be detected by using the target intermediate language code.
In yet another aspect, the present application provides a memory allocation code detection system, including:
the intermediate language code to be detected acquisition module is used for acquiring the intermediate language code to be detected; the intermediate language code to be detected is an intermediate language code obtained by compiling the application program code to be detected;
the target intermediate language code determining module is used for determining the instruction code as a target intermediate language code of the target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code of a corresponding memory allocation code;
and the position information determining module is used for determining the position information of the memory allocation code by utilizing the target intermediate language code, wherein the position information of the memory allocation code is the position information of the memory allocation code in the application program code to be detected.
In yet another aspect, the present application also provides a computer device, including:
a processor and a memory;
Wherein the processor is configured to execute a program stored in the memory;
the memory is used for storing a program, and the program is used for at least:
acquiring an intermediate language code to be detected; the intermediate language code to be detected is an intermediate language code obtained by compiling the application program code to be detected;
determining an instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code of a corresponding memory allocation code;
and determining memory allocation code position information by using the target intermediate language code, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected.
In still another aspect, the present application further provides a storage medium, where computer executable instructions are stored, where the computer executable instructions implement the memory allocation code detection method according to any embodiment of the present application when loaded and executed by a processor.
Therefore, the target intermediate language code corresponding to the memory allocation operation can be determined by matching the instruction codes, and the intermediate language code is obtained by compiling the application program code, so that the position information of the memory allocation code in the application program to be detected can be determined by the target intermediate language code. In addition, the memory allocation code detection method provided by the embodiment of the application does not need to run an application program or exhaust each operation condition of the application program, so that the operation is simple and convenient, and the problem of incomplete memory allocation code detection can be avoided.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only embodiments of the present application, and other drawings may be obtained according to the provided drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a hardware composition framework to which a memory allocation code detection method according to an embodiment of the present application is applicable;
fig. 2 is a schematic flow chart of a method for detecting memory allocation codes according to an embodiment of the present application;
fig. 3 is a schematic flow chart of a method for detecting a memory allocation code according to an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating a determining process of memory allocation code location information according to an embodiment of the present application;
fig. 5 is a schematic flow chart of a method for detecting memory allocation codes according to an embodiment of the present application;
fig. 6 is a schematic flow chart of a method for detecting memory allocation codes according to an embodiment of the present application;
fig. 7 shows a system schematic diagram corresponding to an application scenario embodiment of the present application;
FIG. 8 is a block diagram showing the constitution of an embodiment of a memory allocation code detecting system according to an embodiment of the present application;
fig. 9 is a schematic diagram showing the constitution of an embodiment of a computer device according to an embodiment of the present application.
Detailed Description
In the running process of the application program, if the memory allocation operation is too much or too frequent, garbage collection is triggered, and the garbage collection can cause bad performances such as operation blocking, so how to detect the memory allocation code in the application program code is a technical problem to be solved by those skilled in the art. At present, since source codes comprising memory allocation codes are all written by a high-level language, and a function is realized by using the high-level language, the memory allocation operation is realized, the corresponding code writing rules are quite diversified, the same code writing rule can be applicable to a plurality of different functions, and furthermore, the realization of one function can even lead the source code part to have no actual function codes by calling various package forms, namely, the codes for actually realizing the functions are not directly revealed, so the memory allocation codes can not be directly detected from the source codes at present.
The existing memory allocation code detection method generally adopts a dynamic detection mode to run an application program, exhausts all operations which can be performed on the application program by trying various running states, finds out the situation of memory allocation operation and finds out the corresponding source code according to the situation of memory allocation operation, but the mode depends on the running state of the application program and the tried operation situation, the test workload is quite large, and if the tried operation is not complete enough, all the memory allocation codes cannot be detected. The method for detecting the memory allocation codes can conveniently detect all the memory allocation codes.
For easy understanding, a hardware composition framework to which the scheme corresponding to the memory allocation method of the present application is applicable is first described. Referring to fig. 1, fig. 1 is a schematic diagram of a hardware composition framework to which the memory allocation code detection method of the present application is applicable.
Referring to fig. 1, as can be seen from fig. 1, the hardware composition framework may include: the first computer device 101 and the second computer device 102, where the first computer device 101 is a device for implementing a function of detecting a memory allocation code, and there may be one or more than one, and the second computer device 102 is a device for writing an application program code to be detected, and there may also be one or more than one. The first computer device 101 and the second computer device 102 are communicatively connected via a network 103.
It should be understood that the number of computer devices is not limited in the embodiment of the present application, and a plurality of computer devices may cooperate to complete the function of detecting the memory allocation code, for example, the code of an application program is divided into a plurality of items or modules, and one computer device is responsible for the function of detecting the memory allocation code of one item or module. In one possible scenario, referring to fig. 1, as can be seen from fig. 1, the hardware component framework may include: the first computer device 101 and the second computer device 102, where the first computer device 101 is a device for implementing a function of detecting a memory allocation code, and there may be one or more than one, and the second computer device 102 is a device for writing an application program code to be detected, and there may also be one or more than one. The first computer device 101 and the second computer device 102 are communicatively connected via a network 103.
In a possible case, the hardware component framework may also include only one first computer device 101, where the first computer device 101 has both a memory allocation code detection function and an application program writing function to be detected, or where the first computer device 101 stores an application program to be detected in advance.
In another possible scenario, the hardware component framework may include only the plurality of first computer devices 101, and not include the second computer device 102, where the plurality of first computer devices 101 may be interconnected by a network to transmit the application code to be detected to each other, and perform the memory allocation code detection operation on the received application program to be detected.
In the embodiment of the present application, a frame including the first computer device 101 and the second computer device 102 is described as an example, which can be understood that in this embodiment, two computer devices are provided, and the two computer devices interact data, so as to implement a memory allocation code function. Further, the form of the network 103 is not limited in the embodiment of the present application, for example, the network 103 may be a wireless network (such as WIFI, bluetooth, etc.), or may be a wired network; either the internet or a local area network, which is preferred for data transmission security.
The first computer device 101 and the second computer device 102 may be the same computer device, for example, the first computer device 101 and the second computer device 102 are both servers; but may also be different types of computer devices, e.g. the first computer device 101 may be a server device and the second computer device 102 may be a terminal device. In yet another possible scenario, a server with high computing power may be used as the first computer device 101 to improve data processing efficiency and reliability, so that one first computer device may detect application codes to be detected of multiple second computer devices.
For example, referring to fig. 2, after the second computer device 102 obtains the application code to be detected, it sends the application code to be detected to the first computer device 101, the first computer device 101 compiles the application code to be detected to obtain an intermediate language code to be detected, determines the target intermediate language code with the instruction code being the target instruction code in the intermediate language code to be detected, and finally determines the location information of the memory allocation code in the application code to be detected by determining the location information of the source code corresponding to the target intermediate language code in the application code to be detected.
In one possible scenario, after determining the location information of the memory allocation code, the first computer device 101 may send the location information to the second computer device 102, so that the second computer device 102 modifies the memory allocation code of the corresponding location. Therefore, the memory allocation code can be conveniently and comprehensively detected, and the memory allocation code can be timely modified.
With reference to fig. 3, which is a flowchart illustrating an embodiment of a memory allocation code detection method according to the present application, the method of the present embodiment may include:
S101, obtaining an intermediate language code to be detected, wherein the intermediate language code to be detected is an intermediate language code obtained by compiling an application program code to be detected.
The intermediate language codes (Intermediate Language, IL) are codes obtained by compiling high-level language source codes (such as source codes of C#, VB and F#) through a specific compiling tool. The intermediate language code is closer to the machine code executed by the machine, and can determine specific operations that the machine needs to execute from the intermediate language code, that is, the intermediate language code can reflect the actual operations corresponding to the code more directly than the high-level language source code.
The intermediate language code to be detected obtained by the embodiment of the application is the intermediate language code obtained by compiling the application program code to be detected.
In a possible case, the compiling tool selects mono-code, which is an open source library, and can translate the high-level language code to obtain the corresponding intermediate language code. And storing the application program code to be detected in a dll file format, and compiling the dll file of the application program code to be detected through mono.
The application program code to be detected is the high-level language source code, and the compiling operation can be carried out by a local machine, namely, the device for executing the memory allocation code detection method can also be carried out by other devices, and the compiling operation is stored in the local machine through a communication interface or an input unit.
S102, determining an instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code of a corresponding memory allocation code.
The intermediate language code includes instruction codes (OpCodes) that correspond to actual operation identifiers performed by the machine. For example, the instruction code is an intermediate language code of the BOX, and the corresponding operation content is to convert the value class into an object reference (O type). The actual operation content corresponding to each row of intermediate language codes can be determined through the instruction codes of the intermediate language codes.
In this scheme, the instruction code corresponding to the memory allocation operation is predetermined, that is, the target instruction code is determined. The target intermediate language code is the code of the corresponding memory allocation operation in the intermediate language code to be detected.
Optionally, the target instruction code includes an instruction code corresponding to a box instruction, an instruction code corresponding to a newarr instruction, and an instruction code corresponding to a newobj instruction, that is, the instruction code is an intermediate language of a box or newarr or newobj, and the result of the execution by the machine is a memory allocation operation.
In one possible scenario, the target instruction codes are saved by way of a list, with the list of target instruction codes being saved as a matching list. When the target intermediate language code is determined in the intermediate language codes, each instruction code in the intermediate language codes is matched with the target instruction code in the matching list in sequence, and the intermediate language code corresponding to the instruction code in the matching is determined, and the intermediate language code is the target intermediate language code.
It should be noted that, the target instruction code may be added, deleted or modified according to the actual requirement, that is, the list may be modified according to the actual situation.
In an embodiment, the application program is not particularly limited, and may be, for example, a game, and the application program code to be detected may be a game code developed based on a unit engine and using the c# language.
S103, determining memory allocation code position information by using the target intermediate language code, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected.
Because the intermediate language code is obtained by compiling the application program code, a corresponding relation exists between the intermediate language code and the application program code, and the target intermediate language code corresponding to the memory allocation operation is the memory allocation code. In the scheme, the position of the memory allocation code in the application program code to be detected can be determined by using the intermediate language code.
In one possible case, the embodiment of the present application may determine the location information of the memory allocation code corresponding to the target intermediate language code using the symbol file corresponding to the application code to be detected. The Symbol Files (Symbol Files) are a data information file, and in the Windows system, the Symbol Files are named as pdb. The symbol file contains the debugging information of the binary file (such as EXE, DLL, etc.) of the application program, and is specially used for debugging, and all the variable information in the application program is recorded in the file. The symbol file can track the inside of the application program, and the position information of the memory allocation code corresponding to the target intermediate language code in the application program code can also be determined according to the symbol file.
In the embodiment of the application, the intermediate language code to be detected obtained after compiling the application program code to be detected is firstly obtained, and because the intermediate language code comprises the instruction code capable of reflecting the actual operation content of the machine, the target intermediate language code corresponding to the memory allocation operation can be determined by matching the instruction code, and because the intermediate language code is obtained by compiling the application program code, the corresponding relation exists between the intermediate language code and the application program code, and the position information of the memory allocation code in the application program to be detected can be determined through the target intermediate language code. In addition, the memory allocation code detection method provided by the embodiment of the application does not need to run an application program or exhaust each operation condition of the application program, so that the operation is simple and convenient, and the problem of incomplete memory allocation code detection can be avoided.
In one possible case, the target intermediate language code corresponding to the target instruction code is not the intermediate language code corresponding to the memory allocation code, that is, there is a case that the intermediate language code used for implementing the non-memory allocation function is also the target instruction code, if the intermediate language code of such non-memory allocation function is used as the target intermediate language code, the corresponding application program code to be detected is detected as the memory allocation code, and the determination range of the memory allocation code is too large and inaccurate, thereby increasing the work of later modifying the memory allocation code. In order to solve the problem, the embodiment of the application further limits and explains the determination of the memory allocation code position information.
Referring to fig. 4, the determining flow of the memory allocation code location information in this embodiment is as follows:
s201, determining a target intermediate language code comprising a memory allocation instruction in the target intermediate language codes.
In order to more accurately match the target intermediate language code corresponding to the memory allocation code, the embodiment of the application also needs to match the target intermediate language including the memory allocation instruction according to the actual instruction information of the target intermediate language code after matching the target intermediate language code according to the instruction code.
S202, determining the memory allocation code position information by using the target intermediate language code comprising the memory allocation instruction.
According to the embodiment of the application, the target intermediate language codes comprising the memory allocation instructions can be further matched through the instruction content in the target intermediate language, so that the position information of the corresponding memory allocation codes can be determined according to the target intermediate language codes, and the result can be more accurate.
In one possible case, in order to enable the detected memory allocation code to be timely modified, in the embodiment of the present application, the memory allocation code may be timely modified by a corresponding modifier by determining a last modification account of the memory allocation code and sending a code modification instruction and memory allocation code location information to a corresponding code editing system according to the last modification account.
Referring to fig. 5, a flow chart of a memory allocation code illustrating a further embodiment of a memory allocation code detection method according to the present application is shown, where the method of the present embodiment may include:
s301, obtaining an intermediate language code to be detected, wherein the intermediate language code to be detected is an intermediate language code obtained by compiling an application program code to be detected.
S302, determining an instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code of a corresponding memory allocation code.
S303, determining memory allocation code position information by using the target intermediate language code, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected.
S304, determining a last modified account by using the memory allocation code position information, wherein the last modified account is an account for last modifying the memory allocation codes of each row.
In the scheme, a corresponding relation between codes and writers is established through the account numbers of the code writers, and the last modified account number corresponding to each row of memory allocation codes is determined through the memory allocation code position information, wherein the last modified account number is the account number of the last modified memory allocation codes.
The corresponding relation can be stored in a specified data form, for example, a key value pair is used for storing in a database table, a key is position information, and a value is the corresponding last modified account.
The corresponding relation between the position information and the last modified account is stored in a static mode, the corresponding relation is required to be manually updated in time when the last modifier is replaced each time, and the maintenance cost is high. For this purpose, in a specific embodiment, the searching of the last modified account number may be implemented by an existing or preset version control system.
The version control system is a system for managing file changes such as various program codes, configuration files and description files in the software development process, for example, CVS (Concurrent Versions System), SVN (Subversion), RCS (Revision Control System) and GIT (Georgia Institute of Technology) are all version control systems. The version control system can automatically record and update the corresponding relation between the position information of the written application program code and the last modified account.
In one possible case, the API of the version control system is utilized to send a request for acquiring the last modified account number and the memory allocation code location information to the version control system, and acquire the last modified account number corresponding to the memory allocation code location information returned by the version control system.
In this scheme, in order to obtain the last modified account corresponding to the memory allocation code location information by using the version control system, it is necessary to implement the last modified account by using an API (application programming interface) provided by the version control system. Different version control systems may provide different APIs, and the functionality of the version control system may be used by calling the APIs of the version control system.
It should be noted that, the version control system may be any version control system, and the API needs to correspond to the version control system, that is, if the version control system selects SVN, the API needs to be an API provided by SVN, and if the version control system selects GIT, the API needs to be an API provided by GIT. Further, if the SVN is used as the version control system to obtain the last modified account, the SVN svn_name interface can be called, that is, the SVN provides an API of svn_name.
S305, sending corresponding memory allocation code position information and memory allocation code modification instructions to the code editing system corresponding to each last modification account, so that the code editing system modifies the memory allocation codes.
Each last modified account number corresponds to a code editing system, and the code editing system is a system for editing application program codes.
It should be noted that, each last modified account corresponds to a code editing system, each modified account corresponds to different memory allocation code position information, and this step needs to determine the corresponding relationship between the memory allocation code position information and the code editing system according to the corresponding relationship between the last modified account and the code editing system and the corresponding relationship between the last modified account and the memory allocation code position information, and send the memory allocation code position information and the memory allocation code modification instruction corresponding to the memory allocation code position information and the memory allocation code modification instruction to the code editing system.
In one possible case, the correspondence between the last modified account number and the communication information of the code editing system may be preset, and when the memory allocation code position information and the memory allocation code modification instruction are sent to the code editing system, the communication information of the code editing system is determined through the last correspondence, and communication connection is established between the communication information and the code editing system, so that the sending of the memory allocation code position information and the memory allocation code modification instruction is completed. The communication information may be, for example, an IP address.
In one possible case, an API of the preset task distribution system is utilized to send a memory allocation code modification instruction and corresponding memory allocation code location information to a code editing system corresponding to each last modification account.
The task distribution system is a system for managing information such as development tasks of each user in the software development process, and can automatically distribute task notifications corresponding to the task distribution system to the user system. The choice of task distribution system is not particularly limited in this scenario, and may be, for example, TAPD (Tencent Agile Product Development, tencentrated agile product development platform).
The task distribution system adopts TAPD, and can send a demand bill to the code editing system of the last modified account through an add_sub_store interface of the TAPD system, wherein the demand bill comprises a memory allocation code modification instruction and corresponding memory allocation code position information. It should be noted that, in order to facilitate management of the requirement list of the same last modified account, all the memory allocation code modification instructions corresponding to the same last modified account and the corresponding memory allocation code position information may be issued as the same requirement list.
The function of the task distribution system can be used by calling the API of the task distribution system, so that corresponding memory distribution code modification instructions and memory distribution code position information can be sent to each code editing system through the task distribution system in a manner of calling the API, and the corresponding relation between the last modification account number and the communication information of the code editing system is not required to be maintained, so that the instructions and the position information can be sent more quickly and conveniently.
The task distribution system is the same as the version control system, and the task distribution system may be any version control system, and the API needs to correspond to the task distribution system.
According to the embodiment of the application, the memory allocation code can be timely modified by a corresponding modifier by determining the last modification account number of the memory allocation code and sending the code modification instruction and the memory allocation code position information to the corresponding system according to the last modification account number, so that the memory allocation code is prevented from affecting the operation of the application program.
Referring to fig. 6, a flow chart of a memory allocation code illustrating a further embodiment of a memory allocation code detection method according to the present application is shown, where the method of the present embodiment may include:
S401, obtaining an intermediate language code to be detected, wherein the intermediate language code to be detected is an intermediate language code obtained by compiling an application program code to be detected.
S402, determining the instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code of a corresponding memory allocation code.
S403, determining memory allocation code position information by using the target intermediate language code, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected.
S404, judging whether the number of the target intermediate language codes is larger than a preset threshold value. If yes, S405 is executed, and if no, no operation is performed.
In one possible scenario, the maximum number of memory allocation operations allowed to occur for each application to be detected may be flexibly set, where the preset threshold in S404 is a value indicating the maximum number of memory allocation operations that can exist for the application code to be detected. If the number of the target intermediate language codes is greater than the preset threshold, the memory allocation code amount in the application program codes to be detected exceeds the upper limit, and modification is needed, S405 is continued, otherwise, the modification is not needed, and the operation is stopped.
S405, determining a last modified account by using the memory allocation code position information, wherein the last modified account is an account for last modifying the memory allocation codes of each row.
S406, sending corresponding memory allocation code position information and memory allocation code modification instructions to the code editing system corresponding to each last modification account, so that the code editing system modifies the memory allocation codes.
S407, receiving a modification completion instruction sent by the code editing system; the S401 is performed.
In one possible scenario, the modification and detection of the memory allocation code may be accomplished automatically in an iterative manner. That is, after receiving the modification completion instruction sent by the code editing system, S401 is executed, the intermediate language code of the application program code to be detected is detected again, and the above steps are repeated until the number of target intermediate language codes is less than or equal to the preset threshold.
The embodiment of the application automatically completes the detection and modification of the memory allocation codes in an iterative mode, so that the process of detecting and modifying the memory allocation codes is simpler and more convenient.
For easy understanding, please refer to fig. 7, which is described in connection with an application scenario of the present solution.
The first computer device is the computer device for executing the memory allocation code detection operation according to the embodiment of the application, and the second computer device is the computer device for running the code editing system.
The second computer device generates application program codes to be detected through the code editing system, wherein the application program codes to be detected are specifically game codes which are developed by using a C# language and are based on a units engine.
The second computer device uploads relevant information of the game code to the SVN system through a network, where the relevant information is determined according to a management rule of the SVN system, and may include account information, game code, and other information that needs to be managed by the SVN system. In this embodiment, the account information is specifically a user.
The first computer device obtains the dll file corresponding to the game code, and the dll file can be obtained from the SVN system or the dll file can be obtained from the second computer device.
And the first computer equipment compiles the dll file by utilizing a mono-ci tool to obtain an intermediate language code to be detected, which corresponds to the game code.
The first computer device determines a target instruction code, including box, newarr, newobj, matches each row of intermediate language codes to be detected with the target instruction code, respectively, and determines the matched target instruction code.
For example, the game code is:
Unitiy.EventSystem.Publish(“ui_camera_mode”,”ui”,shezhiController.Instan ce.IsGame3DCamera)
the presentation mode in the intermediate language code to be detected after compiling is as follows:
box[mscorlib]System.boolean
the box is the instruction code of the intermediate language code to be detected, and the box is the target instruction code, and then the 'box [ mscorlib ] system' is determined as the target intermediate language code.
The first computer device determines the actual position information of each line of the target intermediate language code in the game code, that is, the memory allocation code position information, including the function name and the line number, through the symbol file corresponding to the dll file.
The first computer device detects the last modified account corresponding to the location information of each memory allocation code through an API provided by the SVN, that is, the svn_frame interface, and in this embodiment, the last modified account is exemplified by a user.
The first computer equipment sends a memory allocation code modification instruction and corresponding memory allocation code position information to a code editing system of which the account is a user through an API (application program interface) provided by TAPD (data processing device), namely add_sub_store.
After the code editing system (namely the second computer device) with the account number of the user finishes modification, uploading the related information of the updated game code to the SVN system according to the steps, and sending a modification completion instruction to the first computer device, wherein the first computer device continues to perform memory allocation code detection operation on the updated game code, and specific operations can be seen from the steps and are not repeated.
The memory allocation codes in the game codes are detected by using the intermediate language codes, the game is not required to be run, various operations are exhausted, the memory allocation codes in the game codes can be determined, the last modified account corresponding to the memory allocation codes can be determined through the SVN system, the TAPD can automatically send memory allocation code modification instructions and memory allocation code position information to the memory allocation codes corresponding to the last modified account, the number of the memory allocation codes can be minimized through continuous iteration loops, and the influence of the memory allocation operation on the game running effect is reduced.
On the other hand, the application also provides a memory allocation code detection system. Referring to fig. 8, a memory allocation code detection system provided by an embodiment of the present application includes:
the intermediate language code to be detected acquisition module 501 is configured to acquire an intermediate language code to be detected; the intermediate language code to be detected is an intermediate language code obtained by compiling the application program code to be detected;
a target intermediate language code determining module 502, configured to determine, in the intermediate language codes to be detected, that an instruction code is a target intermediate language code of a target instruction code; the target instruction code is an instruction code of a corresponding memory allocation code;
And the location information determining module 503 is configured to determine location information of a memory allocation code by using the target intermediate language code, where the location information of the memory allocation code is location information of the memory allocation code in the application code to be detected.
Optionally, the location information determining module 503 includes:
a target intermediate language code determining unit, configured to determine a target intermediate language code including a memory allocation instruction from the target intermediate language codes;
and the memory allocation code position information determining unit is used for determining the memory allocation code position information by utilizing the target intermediate language code comprising the memory allocation instruction.
Optionally, the system further comprises:
the last modified account number determining module is used for determining a last modified account number by utilizing the memory allocation code position information, wherein the last modified account number is an account number for last modifying each row of memory allocation codes;
and the instruction sending module is used for sending corresponding memory allocation code position information and memory allocation code modification instructions to the code editing system corresponding to each last modification account so that the code editing system modifies the memory allocation codes.
Optionally, the system further comprises:
the judging module is used for judging whether the number of the target intermediate language codes is larger than a preset threshold value or not; if yes, the intermediate language code obtaining module 501 to be detected is called.
Optionally, the system further comprises:
and the instruction receiving module is used for receiving the modification completion instruction sent by the code editing system.
Optionally, the last modified account determination module includes:
the request sending unit is used for sending a request for acquiring the last modified account number and the memory allocation code position information to the version control system by using an API of the version control system;
and the last modified account acquisition unit is used for acquiring the last modified account corresponding to the memory allocation code position information returned by the version control system.
Optionally, the instruction sending module is specifically configured to send a memory allocation code modification instruction and corresponding memory allocation code location information to a code editing system corresponding to each last modified account by using an API of a preset task distribution system.
Optionally, the location information determining module 503 is specifically configured to determine, by using the target intermediate language code, a line number and an affiliated function name of the memory allocation code in the application code to be detected.
Optionally, the target instruction code includes:
the instruction code corresponding to the box instruction, the instruction code corresponding to the newarr instruction, and the instruction code corresponding to the newobj instruction.
Further, the embodiment of the application also provides computer equipment. Fig. 9 is a schematic diagram of a computer device to which the memory allocation code detection method of the present application is applicable.
As can be seen from fig. 9, the computer device 10 may include: a processor 11, a memory 12, a communication interface 13, an input unit 14 and a display 15 and a communication bus 16.
The processor 11, the memory 12, the communication interface 13, the input unit 14, the display 15, all perform communication with each other via a communication bus 16.
In the embodiment of the present application, the processor 11 may be a central processing unit (Central Processing Unit, CPU), an asic, a dsp, an off-the-shelf programmable gate array, or other programmable logic device. The processor may call programs stored in the memory 12. Specifically, the processor may perform the operations performed by the computer device side in the following embodiments of the memory allocation code detection method.
The memory 12 is used to store one or more programs, and the programs may include program codes including computer operation instructions, and in the embodiment of the present application, at least a program for implementing any one of the above memory allocation code detection methods is stored in the memory.
In one possible implementation, the memory 12 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (such as a function of compiling application program code), and the like; the storage data area may store data created during use of the computer, such as application code to be detected, intermediate language code, memory allocation code location information, and the like.
In addition, memory 12 may also include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid-state storage device.
The communication interface 13 may be an interface of a communication module, such as an interface of a GSM module.
The application may also comprise a display 14 and an input unit 15 etc.
Of course, the structure of the computer device shown in fig. 9 does not limit the computer device in the embodiment of the present application, and the computer device may include more or less components than those shown in fig. 1 or may combine some components in practical applications.
The computer device 10 in fig. 9 may be a terminal (such as a PC), or a server with higher performance than a common terminal.
In the embodiment of the present application, the computer device 10 may receive, according to the communication interface 13, the application program code to be detected sent by other external devices by using the network; the application code to be detected may also be obtained through its own input unit 14, such as a keyboard, touch screen, voice input device, etc.
Correspondingly, the processor 11 in the computer device 10 may receive the application program code to be detected from the communication interface 13 or the input unit 14 through the communication bus 16, call the program stored in the memory 12, compile the application program code to be detected, and detect the intermediate code obtained by compiling to determine the location information of the memory allocation code, thereby achieving the purpose of conveniently detecting all the memory allocation codes in the application program code.
In another aspect, the present application further provides a storage medium storing a computer program, where the computer program is loaded and executed by a processor, and configured to implement the memory allocation code detection method described in any one of the foregoing embodiments.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other. For the apparatus class embodiments, the description is relatively simple as it is substantially similar to the method embodiments, and reference is made to the description of the method embodiments for relevant points.
Finally, it is further 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 does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. 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.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.

Claims (9)

1. The memory allocation code detection method is characterized by comprising the following steps:
acquiring an intermediate language code to be detected; the intermediate language code to be detected is an intermediate language code obtained by compiling the application program code to be detected;
determining an instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code corresponding to a memory allocation code, and the memory allocation code is a target intermediate language code corresponding to memory allocation operation and a corresponding application program code;
determining a target intermediate language code comprising a memory allocation instruction in the target intermediate language code;
determining memory allocation code position information by using the target intermediate language code comprising the memory allocation instruction, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected;
Determining a last modified account by using the memory allocation code position information, wherein the last modified account is an account for last modifying each row of memory allocation codes, each last account corresponds to a code editing system, and each modified account corresponds to different internal allocation code position information;
transmitting corresponding memory allocation code position information and memory allocation code modification instructions to a code editing system corresponding to each last modification account so that the code editing system modifies the memory allocation codes;
receiving a modification completion instruction sent by the code editing system; and executing the step of acquiring the intermediate language code to be detected.
2. The method of claim 1, wherein before determining the last modified account number using the memory allocation code location information, further comprising:
judging whether the number of the target intermediate language codes is larger than a preset threshold value or not;
if yes, executing the step of determining the last modified account by using the memory allocation code position information.
3. The method of claim 1, wherein determining the last modified account number for last modifying each row of memory allocation codes using the memory allocation code location information comprises:
Transmitting a request for acquiring a last modified account number and memory allocation code position information to a version control system by using an API of the version control system;
and acquiring a last modified account corresponding to the memory allocation code position information returned by the version control system.
4. A method according to any one of claims 1 to 3, wherein the target instruction code comprises:
the instruction code corresponding to the box instruction, the instruction code corresponding to the newarr instruction, and the instruction code corresponding to the newobj instruction.
5. A memory allocation code detection system, comprising:
the intermediate language code to be detected acquisition module is used for acquiring the intermediate language code to be detected; the intermediate language code to be detected is an intermediate language code obtained by compiling the application program code to be detected;
the target intermediate language code determining module is used for determining the instruction code as a target intermediate language code of the target instruction code in the intermediate language codes to be detected; the target instruction code is an instruction code corresponding to a memory allocation code, and the memory allocation code is a target intermediate language code corresponding to memory allocation operation and a corresponding application program code;
The position information determining module is used for determining a target intermediate language code comprising a memory allocation instruction in the target intermediate language code; determining memory allocation code position information by using the target intermediate language code comprising the memory allocation instruction, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected;
a last modified account number determining module, configured to determine a last modified account number by using the memory allocation code location information, where the last modified account number is an account number for last modifying each row of memory allocation codes, each last account number corresponds to a code editing system, and each modified account number corresponds to different internal allocation code location information;
the instruction sending module is used for sending corresponding memory allocation code position information and memory allocation code modification instructions to the code editing system corresponding to each last modification account so that the code editing system modifies the memory allocation codes;
and the instruction receiving module is used for receiving the modification completion instruction sent by the code editing system.
6. The system of claim 5, further comprising:
The judging module is used for judging whether the number of the target intermediate language codes is larger than a preset threshold value or not; if yes, executing the step of determining the last modified account by using the memory allocation code position information.
7. The system of claim 5, wherein the last modified account determination module comprises:
the request sending unit is used for sending a request for acquiring the last modified account number and the memory allocation code position information to the version control system by using an API of the version control system;
and the last modified account acquisition unit is used for acquiring the last modified account corresponding to the memory allocation code position information returned by the version control system.
8. A computer device, comprising:
a processor and a memory;
wherein the processor is configured to execute a program stored in the memory;
the memory is used for storing a program, and the program is used for at least:
acquiring an intermediate language code to be detected; the intermediate language code to be detected is an intermediate language code obtained by compiling the application program code to be detected;
determining an instruction code as a target intermediate language code of a target instruction code in the intermediate language codes to be detected; the target instruction codes are instruction codes corresponding to memory allocation codes, and the memory allocation codes are target intermediate language codes corresponding to memory allocation operation and corresponding application program codes;
Determining a target intermediate language code comprising a memory allocation instruction in the target intermediate language code;
determining memory allocation code position information by using the target intermediate language code comprising the memory allocation instruction, wherein the memory allocation code position information is the position information of the memory allocation code in the application program code to be detected;
determining a last modified account by using the memory allocation code position information, wherein the last modified account is an account for last modifying each row of memory allocation codes, each last account corresponds to a code editing system, and each modified account corresponds to different internal allocation code position information;
transmitting corresponding memory allocation code position information and memory allocation code modification instructions to a code editing system corresponding to each last modification account so that the code editing system modifies the memory allocation codes;
receiving a modification completion instruction sent by the code editing system; and executing the step of acquiring the intermediate language code to be detected.
9. A storage medium having stored therein computer executable instructions which when loaded and executed by a processor implement the memory allocation code detection method of any one of claims 1 to 4.
CN201910642148.8A 2019-07-16 2019-07-16 Memory allocation code detection method and device, computer equipment and storage medium Active CN110334031B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910642148.8A CN110334031B (en) 2019-07-16 2019-07-16 Memory allocation code detection method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910642148.8A CN110334031B (en) 2019-07-16 2019-07-16 Memory allocation code detection method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110334031A CN110334031A (en) 2019-10-15
CN110334031B true CN110334031B (en) 2023-11-03

Family

ID=68145517

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910642148.8A Active CN110334031B (en) 2019-07-16 2019-07-16 Memory allocation code detection method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110334031B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111338864B (en) * 2020-02-18 2023-08-18 上海闻泰电子科技有限公司 Memory problem detection method, device, computer equipment and storage medium
CN113220554B (en) * 2021-05-17 2023-07-25 北京百度网讯科技有限公司 Method and apparatus for detecting performance of program code

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123218A (en) * 2013-04-23 2014-10-29 腾讯科技(深圳)有限公司 Method, device and system for code coverage test
WO2017035748A1 (en) * 2015-08-31 2017-03-09 华为技术有限公司 Code compiling method and code complier
CN109344051A (en) * 2018-08-28 2019-02-15 北京达佳互联信息技术有限公司 Method, apparatus, electronic equipment and the storage medium of data processing

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123218A (en) * 2013-04-23 2014-10-29 腾讯科技(深圳)有限公司 Method, device and system for code coverage test
WO2017035748A1 (en) * 2015-08-31 2017-03-09 华为技术有限公司 Code compiling method and code complier
CN109344051A (en) * 2018-08-28 2019-02-15 北京达佳互联信息技术有限公司 Method, apparatus, electronic equipment and the storage medium of data processing

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Linux平台下基于源代码插装的动态内存检测;高海昌;冯博琴;何杭军;朱利;;小型微型计算机系统(09);全文 *
R. Finlayson ; LIVE.COM ; .An Abstract API for Multicast Address Allocation.IETF rfc2771.2000,全文. *
安全协议多目标语言代码缺陷检测方法仿真;孙雷;;计算机仿真(12);全文 *

Also Published As

Publication number Publication date
CN110334031A (en) 2019-10-15

Similar Documents

Publication Publication Date Title
US10019256B2 (en) Systems and methods for incremental software development
US7975257B2 (en) Iterative static and dynamic software analysis
US8954929B2 (en) Automatically redirecting method calls for unit testing
US9632769B2 (en) Software build optimization
US20240045850A1 (en) Systems and methods for database orientation transformation
CN113885870B (en) Application program updating method, electronic equipment, terminal equipment and system
US20190095181A1 (en) Easy-To-Use Type Of Compile-Time Dependency Injection Method And Device In The Java Platform
US20110126179A1 (en) Method and System for Dynamic Patching Software Using Source Code
US20180060043A1 (en) Preservation of backward compatibility for java card cap files
US20150067653A1 (en) Automatic generation of analysis-equivalent application constructs
CN112099880B (en) Method and system for reducing application program driven by scene
CN110334031B (en) Memory allocation code detection method and device, computer equipment and storage medium
US20130007184A1 (en) Message oriented middleware with integrated rules engine
US9395977B2 (en) Locating program code units after software refactoring
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
US20120222023A1 (en) Automatic runtime dependency lookup
CN107943504A (en) The dynamic update method of software module in a kind of embedded system
CN111352631A (en) Interface compatibility detection method and device
CN116578282A (en) Code generation method, device, electronic equipment and medium
KR20130020135A (en) System and method of providing the developer list of developing code simultaneously in an integrated development environment
US10606569B2 (en) Declarative configuration elements
US20180267780A1 (en) Methods for providing conditional allocation of build files and related systems and computer program products
CN111367796A (en) Application program debugging method and device
US20240103853A1 (en) Code maintenance system
CN116737229A (en) Detection method and device of technical stack, processor and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant