CN109829298A - RAM leakage risk checking method, terminal and computer readable storage medium - Google Patents

RAM leakage risk checking method, terminal and computer readable storage medium Download PDF

Info

Publication number
CN109829298A
CN109829298A CN201811420317.5A CN201811420317A CN109829298A CN 109829298 A CN109829298 A CN 109829298A CN 201811420317 A CN201811420317 A CN 201811420317A CN 109829298 A CN109829298 A CN 109829298A
Authority
CN
China
Prior art keywords
code
ram leakage
detected
code file
leakage risk
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.)
Pending
Application number
CN201811420317.5A
Other languages
Chinese (zh)
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.)
Nubia Technology Co Ltd
Original Assignee
Nubia Technology 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 Nubia Technology Co Ltd filed Critical Nubia Technology Co Ltd
Priority to CN201811420317.5A priority Critical patent/CN109829298A/en
Publication of CN109829298A publication Critical patent/CN109829298A/en
Pending legal-status Critical Current

Links

Abstract

The present invention provides a kind of RAM leakage risk checking method, terminal and computer readable storage medium, which includes: the code file to be detected for obtaining the application program for being input to code-development tool;Code file to be detected is matched according to the preset code characteristic data with RAM leakage risk;In successful match, determine that code file to be detected has RAM leakage risk at runtime.Implementation through the invention, it is to be matched according to the code characteristic data with RAM leakage risk to code to be measured in code development phase, to which the RAM leakage error code for being easy carelessness to developer is discovered and seized, RAM leakage hidden danger is fundamentally prevented, reduce a possibility that Memory Leaks are broken out after on-line running, improve the working efficiency of exploitation and the usage experience of user.

Description

RAM leakage risk checking method, terminal and computer readable storage medium
Technical field
The present invention relates to intelligent terminal technical fields, more specifically to a kind of RAM leakage risk checking method, end End and computer readable storage medium.
Background technique
In computer science, RAM leakage refers to that be assigned with memory uses to some process, and in the process used There is no releasing memory after depositing, causes allocated memory can not recycling and reusing.It is available interior in system with the operation of process Depositing can be fewer and fewer, and system is caused to cause to paralyse due to no enough memory operation processes.The reason of RAM leakage, may It is that there are hidden danger or system exceptions etc. to cause for the code write due to developer.
Currently, to avoid RAM leakage from leading to systemic breakdown, usually used by means be in the code operation phase, namely During application program is run, when mistake occurs, relevant issues log is captured come to problem by RAM leakage checking tool Code is positioned, and then targetedly to modify problem code to check hidden danger, but can only answered using this means In the case that program is run on line and mistake has occurred and that, hidden danger could be checked namely the prior art only provides A kind of subsequent solution, and cannot fundamentally go to avoid the generation of problem, a fixing still will cause to the use of user It rings.
Summary of the invention
The technical problem to be solved in the present invention is that in the prior art when the code operation phase RAM leakage mistake occurring Hidden danger could be checked, caused Memory Leaks when cannot avoid on-line running completely are asked for the technology Topic provides a kind of RAM leakage risk checking method, terminal and computer readable storage medium.
In order to solve the above technical problems, the present invention provides a kind of RAM leakage risk checking method, the RAM leakage risk Detection method includes:
Obtain the code file to be detected for being input to the application program of code-development tool;
Code file to be detected is matched according to the preset code characteristic data with RAM leakage risk;
In successful match, determine that code file to be detected has RAM leakage risk at runtime.
Optionally, obtaining the code file to be detected of application program for being input to code-development tool includes:
It obtains and is input to the code file of the application program of code editor in the Code Edit stage;
And/or it obtains and is input to the code file of the application program of code encoder in the code compilation stage.
Optionally, obtaining the code file to be detected of application program for being input to code-development tool includes:
Obtain the installation file of application program;
After carrying out reverse-engineering processing to installation file, be input to code-development tool code file be determined as to Detect code file.
Optionally, obtaining the code file to be detected of application program for being input to code-development tool includes:
From all code files for the application program for being input to code-development tool, code text is intercepted according to preset rules Part segment;
Code file segment is determined as code file to be detected.
Optionally, it from all code files for the application program for being input to code-development tool, is cut according to preset rules Replace code file fragment include:
From all code files for the application program for being input to code-development tool, according to the type of performed task Intercept code file segment.
Optionally, code characteristic data comprise at least one of the following: class built in keyword, Software Development Kit SDK.
Optionally, code file to be detected is being carried out according to the preset code characteristic data with RAM leakage risk After matching, further includes:
When it fails to match, the code compilation stage by morphological analysis and syntactic analysis come to code file to be detected into Row complete analysis;
If analyzing result instruction, there are codes lack of standardization to write logic, it is determined that code file to be detected exists at runtime RAM leakage risk.
Optionally, when it fails to match, in the code compilation stage by morphological analysis and syntactic analysis come to generation to be detected Code file carries out complete analysis
When it fails to match, in the code compilation stage by morphological analysis and syntactic analysis come in code file to be detected Inner classes and/or anonymous class identified;
If analyzing result instruction, there are codes lack of standardization to write logic, it is determined that code file to be detected exists at runtime RAM leakage risk includes:
If analyzing result instruction, there are nonstandard inner classes and/or anonymous class, it is determined that code file to be detected is being transported There are RAM leakage risks when row.
Further, the present invention also provides a kind of terminal, which includes processor, memory, communication bus;
Communication bus is for realizing the connection communication between processor, memory;
Processor is for executing one or more program stored in memory, to realize above-mentioned RAM leakage risk The step of detection method.
Further, the present invention also provides a kind of computer readable storage medium, which is deposited One or more program is contained, one or more program can be executed by one or more processor, above-mentioned to realize The step of RAM leakage risk checking method.
Beneficial effect
The present invention provides a kind of RAM leakage risk checking method, terminal and computer readable storage medium, for existing Hidden danger could be checked in technology when the code operation phase RAM leakage mistake occurring, caused cannot avoid completely The defect of Memory Leaks when on-line running, the RAM leakage risk checking method include: that acquisition is input to code development The code file to be detected of the application program of tool;According to the preset code characteristic data with RAM leakage risk to be checked Code file is surveyed to be matched;In successful match, determine that code file to be detected has RAM leakage risk at runtime.? Code development phase is to be matched according to the code characteristic data with RAM leakage risk to code to be measured, thus split The RAM leakage error code that hair personnel are easy carelessness is discovered and seized, and RAM leakage hidden danger has fundamentally been prevented, and is reduced interior A possibility that leakage problem is broken out after on-line running is deposited, the working efficiency of exploitation and the usage experience of user are improved.
Detailed description of the invention
Present invention will be further explained below with reference to the attached drawings and examples, in attached drawing:
The hardware structural diagram of Fig. 1 each embodiment one optional mobile terminal to realize the present invention;
Fig. 2 is the wireless communication system schematic diagram of mobile terminal as shown in Figure 1;
Fig. 3 is the basic flow chart for the RAM leakage risk checking method that first embodiment of the invention provides;
Fig. 4 is the refined flow chart for the RAM leakage risk checking method that second embodiment of the invention provides;
Fig. 5 is the refined flow chart for the RAM leakage risk checking method that third embodiment of the invention provides;
Fig. 6 is the structural schematic diagram for the terminal that fourth embodiment of the invention provides.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
In subsequent description, it is only using the suffix for indicating such as " module ", " component " or " unit " of element Be conducive to explanation of the invention, itself there is no a specific meaning.Therefore, " module ", " component " or " unit " can mix Ground uses.
Terminal can be implemented in a variety of manners.For example, terminal described in the present invention may include such as mobile phone, plate Computer, laptop, palm PC, personal digital assistant (Personal Digital Assistant, PDA), portable Media player (Portable Media Player, PMP), navigation device, wearable device, Intelligent bracelet, pedometer etc. move The fixed terminals such as dynamic terminal, and number TV, desktop computer.
It will be illustrated by taking mobile terminal as an example in subsequent descriptions, it will be appreciated by those skilled in the art that in addition to special Except element for moving purpose, the construction of embodiment according to the present invention can also apply to the terminal of fixed type.
Referring to Fig. 1, a kind of hardware structural diagram of its mobile terminal of each embodiment to realize the present invention, the shifting Dynamic terminal 100 may include: RF (Radio Frequency, radio frequency) unit 101, WiFi module 102, audio output unit 103, A/V (audio/video) input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, the components such as memory 109, processor 110 and power supply 111.It will be understood by those skilled in the art that shown in Fig. 1 Mobile terminal structure does not constitute the restriction to mobile terminal, and mobile terminal may include components more more or fewer than diagram, Perhaps certain components or different component layouts are combined.
It is specifically introduced below with reference to all parts of the Fig. 1 to mobile terminal:
Radio frequency unit 101 can be used for receiving and sending messages or communication process in, signal sends and receivees, specifically, by base station Downlink information receive after, to processor 110 handle;In addition, the data of uplink are sent to base station.In general, radio frequency unit 101 Including but not limited to antenna, at least one amplifier, transceiver, coupler, low-noise amplifier, duplexer etc..In addition, penetrating Frequency unit 101 can also be communicated with network and other equipment by wireless communication.Any communication can be used in above-mentioned wireless communication Standard or agreement, including but not limited to GSM (Global System of Mobile communication, global system for mobile telecommunications System), GPRS (General Packet Radio Service, general packet radio service), CDMA2000 (Code Division Multiple Access 2000, CDMA 2000), WCDMA (Wideband Code Division Multiple Access, wideband code division multiple access), TD-SCDMA (Time Division-Synchronous Code Division Multiple Access, TD SDMA), FDD-LTE (Frequency Division Duplexing-Long Term Evolution, frequency division duplex long term evolution) and TDD-LTE (Time Division Duplexing-Long Term Evolution, time division duplex long term evolution) etc..
WiFi belongs to short range wireless transmission technology, and mobile terminal can help user to receive and dispatch electricity by WiFi module 102 Sub- mail, browsing webpage and access streaming video etc., it provides wireless broadband internet access for user.Although Fig. 1 shows Go out WiFi module 102, but it is understood that, and it is not belonging to must be configured into for mobile terminal, it completely can be according to need It to omit within the scope of not changing the essence of the invention.
Audio output unit 103 can be in call signal reception pattern, call mode, record mould in mobile terminal 100 When under the isotypes such as formula, speech recognition mode, broadcast reception mode, by radio frequency unit 101 or WiFi module 102 it is received or The audio data stored in memory 109 is converted into audio signal and exports to be sound.Moreover, audio output unit 103 Audio output relevant to the specific function that mobile terminal 100 executes can also be provided (for example, call signal receives sound, disappears Breath receives sound etc.).Audio output unit 103 may include loudspeaker, buzzer etc..
A/V input unit 104 is for receiving audio or video signal.A/V input unit 104 may include graphics processor (Graphics Processing Unit, GPU) 1041 and microphone 1042, graphics processor 1041 is in video acquisition mode Or the image data of the static images or video obtained in image capture mode by image capture apparatus (such as camera) carries out Reason.Treated, and picture frame may be displayed on display unit 106.Through graphics processor 1041, treated that picture frame can be deposited Storage is sent in memory 109 (or other storage mediums) or via radio frequency unit 101 or WiFi module 102.Mike Wind 1042 can connect in telephone calling model, logging mode, speech recognition mode etc. operational mode via microphone 1042 Quiet down sound (audio data), and can be audio data by such acoustic processing.Audio that treated (voice) data can To be converted to the format output that can be sent to mobile communication base station via radio frequency unit 101 in the case where telephone calling model. Microphone 1042 can be implemented various types of noises elimination (or inhibition) algorithms and send and receive sound to eliminate (or inhibition) The noise generated during frequency signal or interference.
Mobile terminal 100 further includes at least one sensor 105, such as optical sensor, motion sensor and other biographies Sensor.Specifically, optical sensor includes ambient light sensor and proximity sensor, wherein ambient light sensor can be according to environment The light and shade of light adjusts the brightness of display panel 1061, and proximity sensor can close when mobile terminal 100 is moved in one's ear Display panel 1061 and/or backlight.As a kind of motion sensor, accelerometer sensor can detect in all directions (general For three axis) size of acceleration, it can detect that size and the direction of gravity when static, can be used to identify the application of mobile phone posture (such as horizontal/vertical screen switching, dependent game, magnetometer pose calibrating), Vibration identification correlation function (such as pedometer, percussion) etc.; The fingerprint sensor that can also configure as mobile phone, pressure sensor, iris sensor, molecule sensor, gyroscope, barometer, The other sensors such as hygrometer, thermometer, infrared sensor, details are not described herein.
Display unit 106 is for showing information input by user or being supplied to the information of user.Display unit 106 can wrap Display panel 1061 is included, liquid crystal display (Liquid Crystal Display, LCD), Organic Light Emitting Diode can be used Forms such as (Organic Light-Emitting Diode, OLED) configure display panel 1061.
User input unit 107 can be used for receiving the number or character information of input, and generate the use with mobile terminal Family setting and the related key signals input of function control.Specifically, user input unit 107 may include touch panel 1071 with And other input equipments 1072.Touch panel 1071, also referred to as touch screen collect the touch operation of user on it or nearby (for example user uses any suitable objects or attachment such as finger, stylus on touch panel 1071 or in touch panel 1071 Neighbouring operation), and corresponding attachment device is driven according to preset formula.Touch panel 1071 may include touch detection Two parts of device and touch controller.Wherein, the touch orientation of touch detecting apparatus detection user, and detect touch operation band The signal come, transmits a signal to touch controller;Touch controller receives touch information from touch detecting apparatus, and by it It is converted into contact coordinate, then gives processor 110, and order that processor 110 is sent can be received and executed.In addition, can To realize touch panel 1071 using multiple types such as resistance-type, condenser type, infrared ray and surface acoustic waves.In addition to touch panel 1071, user input unit 107 can also include other input equipments 1072.Specifically, other input equipments 1072 can wrap It includes but is not limited in physical keyboard, function key (such as volume control button, switch key etc.), trace ball, mouse, operating stick etc. It is one or more, specifically herein without limitation.
Further, touch panel 1071 can cover display panel 1061, when touch panel 1071 detect on it or After neighbouring touch operation, processor 110 is sent to determine the type of touch event, is followed by subsequent processing device 110 according to touch thing The type of part provides corresponding visual output on display panel 1061.Although in Fig. 1, touch panel 1071 and display panel 1061 be the function that outputs and inputs of realizing mobile terminal as two independent components, but in certain embodiments, it can The function that outputs and inputs of mobile terminal is realized so that touch panel 1071 and display panel 1061 is integrated, is not done herein specifically It limits.
Interface unit 108 be used as at least one external device (ED) connect with mobile terminal 100 can by interface.For example, External device (ED) may include wired or wireless headphone port, external power supply (or battery charger) port, wired or nothing Line data port, memory card port, the port for connecting the device with identification module, audio input/output (I/O) end Mouth, video i/o port, ear port etc..Interface unit 108 can be used for receiving the input from external device (ED) (for example, number It is believed that breath, electric power etc.) and the input received is transferred to one or more elements in mobile terminal 100 or can be with For transmitting data between mobile terminal 100 and external device (ED).
Memory 109 can be used for storing software program and various data.Memory 109 can mainly include storing program area The storage data area and, wherein storing program area can (such as the sound of application program needed for storage program area, at least one function Sound playing function, image player function etc.) etc.;Storage data area can store according to mobile phone use created data (such as Audio data, phone directory etc.) etc..In addition, memory 109 may include high-speed random access memory, it can also include non-easy The property lost memory, a for example, at least disk memory, flush memory device or other volatile solid-state parts.
Processor 110 is the control centre of mobile terminal, utilizes each of various interfaces and the entire mobile terminal of connection A part by running or execute the software program and/or module that are stored in memory 109, and calls and is stored in storage Data in device 109 execute the various functions and processing data of mobile terminal, to carry out integral monitoring to mobile terminal.Place Managing device 110 may include one or more processing units;Preferably, processor 110 can integrate application processor and modulatedemodulate is mediated Manage device, wherein the main processing operation system of application processor, user interface and application program etc., modem processor is main Processing wireless communication.It is understood that above-mentioned modem processor can not also be integrated into processor 110.
Mobile terminal 100 can also include the power supply 111 (such as battery) powered to all parts, it is preferred that power supply 111 Can be logically contiguous by power-supply management system and processor 110, to realize management charging by power-supply management system, put The functions such as electricity and power managed.
Although Fig. 1 is not shown, mobile terminal 100 can also be including bluetooth module etc., and details are not described herein.
Embodiment to facilitate the understanding of the present invention, the communications network system that mobile terminal of the invention is based below into Row description.
Referring to Fig. 2, Fig. 2 is a kind of communications network system architecture diagram provided in an embodiment of the present invention, the communication network system System is the LTE system of universal mobile communications technology, which includes UE (User Equipment, the use of successively communication connection Family equipment) (the land Evolved UMTS Terrestrial Radio Access Network, evolved UMTS 201, E-UTRAN Ground wireless access network) 202, EPC (Evolved Packet Core, evolved packet-based core networks) 203 and operator IP operation 204。
Specifically, UE201 can be above-mentioned terminal 100, and details are not described herein again.
E-UTRAN202 includes eNodeB2021 and other eNodeB2022 etc..Wherein, eNodeB2021 can be by returning Journey (backhaul) (such as X2 interface) is connect with other eNodeB2022, and eNodeB2021 is connected to EPC203, ENodeB2021 can provide the access of UE201 to EPC203.
EPC203 may include MME (Mobility Management Entity, mobility management entity) 2031, HSS (Home Subscriber Server, home subscriber server) 2032, other MME2033, SGW (Serving Gate Way, Gateway) 2034, PGW (PDN Gate Way, grouped data network gateway) 2035 and PCRF (Policy and Charging Rules Function, policy and rate functional entity) 2036 etc..Wherein, MME2031 be processing UE201 and The control node of signaling, provides carrying and connection management between EPC203.HSS2032 is all to manage for providing some registers Such as the function of home location register (not shown) etc, and preserves some related service features, data rates etc. and use The dedicated information in family.All customer data can be sent by SGW2034, and PGW2035 can provide the IP of UE 201 Address distribution and other functions, PCRF2036 are strategy and the charging control strategic decision-making of business data flow and IP bearing resource Point, it selects and provides available strategy and charging control decision with charge execution function unit (not shown) for strategy.
IP operation 204 may include internet, Intranet, IMS (IP Multimedia Subsystem, IP multimedia System) or other IP operations etc..
Although above-mentioned be described by taking LTE system as an example, those skilled in the art should know the present invention is not only Suitable for LTE system, be readily applicable to other wireless communication systems, such as GSM, CDMA2000, WCDMA, TD-SCDMA with And the following new network system etc., herein without limitation.
Based on above-mentioned mobile terminal hardware configuration and communications network system, each embodiment of the method for the present invention is proposed.
First embodiment
To solve in the prior art to check hidden danger when the code operation phase RAM leakage mistake occurring, institute The defect of caused Memory Leaks when cannot avoid on-line running completely, present embodiments provides a kind of RAM leakage wind Dangerous detection method, is illustrated in figure 3 the basic flow chart of RAM leakage risk checking method provided in this embodiment, which lets out Reveal risk checking method specifically includes the following steps:
S301, acquisition are input to the code file to be detected of the application program of code-development tool.
Code-development tool namely programming language developing instrument in the present embodiment, developing instrument here can be code Editing machine can also be code encoder, be used for source code for generating the program documentaion namely source code that people can read It is converted into machine language, can directly be run by the central processing unit of computer namely executable code.
Optionally, the code file to be detected for obtaining the application program for being input to code-development tool includes: to obtain in generation Code edit phase is input to the code file of the application program of code editor;And/or it obtains and is input in the code compilation stage The code file of the application program of code encoder.
Specifically, code file to be detected is incorporated into real time by developer in an embodiment of the present embodiment The code file to be detected of code-development tool namely developer's code that real-time edition generates in code editor, or The code imported in real time in code encoder.In practical applications, in order to guarantee the comprehensive of RAM leakage hidden troubles removing, The acquisition of code file to be detected can be carried out in Code Edit stage and code compilation stage, and correspond to and execute subsequent inspection It surveys.
Optionally, the code file to be detected for obtaining the application program for being input to code-development tool includes: to obtain application The installation file of program;After carrying out reverse-engineering processing to installation file, it is input to the code file of code-development tool It is determined as code file to be detected.
Specifically, code file to be detected can also be through reverse work in the another embodiment of the present embodiment The obtained code of journey processing, reverse-engineering are also known as reversal technique or reverse engineering, refer to and pass through solution to executable program or application The methods of close, dis-assembling, decompiling dismantling and analysis software or structure, algorithm and the code of application program etc., in the present embodiment The source code file that application program is generated by a variety of implementation methods such as dis-assembling, decompiling, then makees source code file Code-development tool, which is input to, for code file to be detected executes subsequent detection.
Optionally, the code file to be detected for obtaining the application program for being input to code-development tool includes: from being input to In all code files of the application program of code-development tool, code file segment is intercepted according to preset rules;By code text Part segment is determined as code file to be detected.
Specifically, in practical applications, coding engineering is usually made huge, it is divided into multiple modules, has again between module If desired nesting etc. detects all code files of application program totally, then then need to be checked sentence by sentence, so that The efficiency for searching the code of initiation RAM leakage mistake is lower, and leads to height of detection instrument when running to terminal operating resource It occupies, is based on this, specific code snippet is intercepted in the present embodiment in whole code files only as code text to be detected Part, so as to there is the high code snippet of RAM leakage hidden danger that intercepts of directive property to be detected, and not to no memory The code of leakage hidden danger is detected, and can effectively improve detection efficiency.
Optionally, it from all code files for the application program for being input to code-development tool, is cut according to preset rules Replacing code file fragment includes: from all code files for the application program for being input to code-development tool, according to performed Task type intercept code file segment.
Specifically, all code files of application program are divided according to the type of performed task in the present embodiment For different code snippets, then selects specific code snippet as code to be measured from these code snippets, here may be used Being selected according to pre-set rule default, it is also possible to the selection of developer's real-time perfoming.Such as at one It draws a lottery in source code program, it comprises a large amount of code files, and the task that all code files can execute includes following Four: handling received information and filtering phone number, the preparation before broadcast broadcast information, terminate to broadcast, to press Task performed by its code file, whole source code can be divided into four code snippets: processing code snippet prepares code Segment broadcasts code snippet, end code segment, is usually executing the received information of processing and filtering phone number task When, occur RAM leakage a possibility that it is higher, so as to only will processing code snippet as code file to be detected, and for Other three code snippets do not need then to be detected.
S302, according to the preset code characteristic data with RAM leakage risk to code file to be detected carry out Match.
Specifically, presetting RAM leakage rule file in the present embodiment, in terminal, protected in the RAM leakage rule file There are the code characteristic data with RAM leakage risk, the code characteristic data with RAM leakage risk here are used for table It levies nonstandard code and writes logic, so that code file to be detected is checked based on the code characteristic data, thus It determines in code file to be detected with the presence or absence of the writing nonstandard problem of logic.
Optionally, code characteristic data comprise at least one of the following: class built in keyword, Software Development Kit SDK.
Specifically, in practical applications, there are many scenes for generally occurring within RAM leakage, it is based on this, in the present embodiment Code characteristic data can also be selected specifically according to actual needs.For example, being carried out to the object registered Registration, but not counter registered and cause this concrete scene of memory overflow, related java class may only can include Listener, registered, and and do not include unRegistered;And class example to be released is quoted for static variable and is caused This concrete scene of memory overflow is generally basede on static keyword and the general type of Java to be matched;In addition, Service has executed task, and the concrete scene that do not destroyed immediately to it can then be related to onDestory, unBind, stop Equal keywords, and correlation Service class;In addition, times for needing to wait is added into MessageQueue using Handler Business causes the case where memory overflow, then needs to pay close attention to Handler, MessageQueue, Runnable etc..In complicated memory It reveals under scene, RAM leakage code can be checked in conjunction with Multiple Code characteristic, proposed in the present embodiment Keyword and built-in class be only two kinds of preferable examples, should not be considered limited to both in practical applications.
S303, in successful match, determine that code file to be detected has RAM leakage risk at runtime.
Specifically, carrying out aforementioned code spy to code file in Code Edit stage or code compilation stage in the present embodiment When levying the matching of data, and exporting the result of successful match, then illustrate in code file to be detected to include with RAM leakage The code of risk, to then be easy to cause RAM leakage when the code file on-line running to be detected.In practical applications, it is examining Code file is measured there are when RAM leakage risk, can to it is positioned the problem of code prompt, such as generate code inspection Announcement is observed and predicted, can inform quantity, specific location of developer's problem code etc., in order to which developer is subsequent to problem code It modifies.
Optionally, code file to be detected is being carried out according to the preset code characteristic data with RAM leakage risk After matching, further includes: when it fails to match, in the code compilation stage by morphological analysis and syntactic analysis come to generation to be detected Code file carries out complete analysis;If analyzing result instruction, there are codes lack of standardization to write logic, it is determined that code file to be detected There is RAM leakage risk at runtime.
Specifically, in practical applications, not in all cases, can pass through code characteristic Data Matching above-mentioned The code with RAM leakage risk is effectively checked to realize.Based on this, the present embodiment is proposed, for passing through code spy The problem of mode of sign Data Matching can not position, can be in the code compilation stage, according to the morphology point by code encoder Analysis and syntactic analysis and syntax tree carry out complete analysis for item code, to progress the problem of may cause memory overflow It reports an error, interrupts compiling.
Optionally, when it fails to match, in the code compilation stage by morphological analysis and syntactic analysis come to generation to be detected Code file carry out complete analysis include: when it fails to match, the code compilation stage by morphological analysis and syntactic analysis come pair Inner classes and/or anonymous class in code file to be detected are identified;If analyzing result instruction, there are code lack of standardization writings Logic, it is determined that if it includes: that analysis result instruction presence is not advised that code file to be detected has RAM leakage risk at runtime The inner classes and/or anonymous class of model, it is determined that code file to be detected has RAM leakage risk at runtime.
In practical applications, for can implicitly hold their outer categories with non-static inner classes and anonymous class Reference and cause the scene of memory overflow, due to without obvious keyword, so that code characteristic data above-mentioned can not be passed through The mode matched positions the code with RAM leakage risk, then needs in the compilation phase, by the realizations of analysis classes, And subordinate relation is to determine whether be inner classes or anonymous class, to further check related hidden danger.
The present invention provides a kind of RAM leakage risk checking method, in the prior art the code operation phase occur in Hidden danger could be checked when depositing leakage mistake, caused Memory Leaks when cannot avoid on-line running completely Defect, the RAM leakage risk checking method include: the code to be detected for obtaining the application program for being input to code-development tool File;Code file to be detected is matched according to the preset code characteristic data with RAM leakage risk;It is matching When success, determine that code file to be detected has RAM leakage risk at runtime.It is interior according to having in code development phase The code characteristic data of disclosure risk are deposited to match to code to be measured, to be easy the RAM leakage of carelessness to developer Error code is discovered and seized, and has fundamentally prevented RAM leakage hidden danger, it is quick-fried after on-line running to reduce Memory Leaks A possibility that hair, improves the working efficiency of exploitation and the usage experience of user.
Second embodiment
In order to better understand the present invention, the present embodiment with a specific example to memory disclosure risk detection method into Row explanation, Fig. 4 are the refined flow chart for the RAM leakage risk checking method that second embodiment of the invention provides, the RAM leakage Risk checking method includes:
S401, in the Code Edit stage, from all code files for the application program for being input to code editor, according to The type of performed task intercepts corresponding code file segment.
S402, using the code file segment intercepted as code file to be detected.
Specific code snippet only is intercepted as to be detected in whole code files in editing machine in the present embodiment Code file, so as to there is the high code snippet of RAM leakage hidden danger that intercepts of directive property to be detected, and it is not right The code of no RAM leakage hidden danger is detected, and can effectively improve detection efficiency.Also, based on performed in the present embodiment The type of task chooses corresponding code file segment from whole code files.
It should be noted that the RAM leakage risk supervision process in the present embodiment performed by the Code Edit stage, It can be the real-time perfoming in editing process to execute, be also possible to execute the process after integrally editor finishes.
S403, according to the preset code characteristic data with RAM leakage risk to code file to be detected carry out Match.
Code characteristic data in the present embodiment may include following at least one: keyword, Software Development Kit SDK Built-in class, namely code to be measured is checked based on specific keyword and built-in class.
S404, determine whether to be matched to the code characteristic data from code file to be detected;If so, S405 is executed, If it is not, then executing S406.
S405, determine that code file to be detected has RAM leakage risk at runtime.
S406, determining code file to be detected, there is no RAM leakage risks.
For example, for the InputManager class in AndroidSDK, developer has invoked in code After registerInputManagerListener () method, it can detect whether in the Code Edit stage for same target UnregisterInputManagerListener () calling is carried out in life cycle methodology appropriate, if it is not, saying The logic of bright write code is lack of standardization, and in on-line running, there are RAM leakage risks, otherwise can be determined as no hidden danger Code.
S407, output code examining report.
Output code examining report is gone back in the present embodiment after detection finishes, to inform developer's testing result, and And when there are RAM leakage risk, quantity, specific location of developer's problem code etc. can also be informed, in order to open Hair personnel are subsequent to modify to problem code.
The present invention provides a kind of RAM leakage risk checking method, in the Code Edit stage from the code in code editor Code snippet is intercepted in file as code file to be detected, come pair further according to the code characteristic data with RAM leakage risk Code to be measured is matched, and whether there is RAM leakage risk with this to determine code file to be detected at runtime.To right The RAM leakage error code that developer is easy carelessness is discovered and seized, and has fundamentally been prevented RAM leakage hidden danger, has been reduced A possibility that Memory Leaks are broken out after on-line running improves the working efficiency of exploitation and the usage experience of user.
3rd embodiment
In order to better understand the present invention, the present embodiment is with another specific example to memory disclosure risk detection method It is illustrated, Fig. 5 is the refined flow chart for the RAM leakage risk checking method that third embodiment of the invention provides, which lets out Revealing risk checking method includes:
S501, acquisition are input to the code file to be detected of the application program of code-development tool.
S502, according to the preset code characteristic data with RAM leakage risk to code file to be detected carry out Match.
Here developing instrument can be in code editor or code encoder namely the present embodiment can appoint in the two Meaning one, or both carries out the matching detection of code characteristic data simultaneously.Wherein, code characteristic data may include with down toward Few one kind: class built in keyword, Software Development Kit SDK.
S503, when not being matched to the code characteristic data from code file to be detected, pass through in the code compilation stage Morphological analysis and syntactic analysis to carry out complete analysis to code file to be detected.
S504, it is determined in code file to be detected based on the analysis results and writes logic with the presence or absence of code lack of standardization;If so, S505 is then executed, if it is not, then executing S506.
S505, determine that code file to be detected has RAM leakage risk at runtime.
S506, determining code file to be detected, there is no RAM leakage risks.
S507, output code examining report.
In practical applications, not in all cases, it can be realized by code characteristic Data Matching above-mentioned Code with RAM leakage risk is effectively checked.Based on this, the present embodiment is proposed, for passing through code characteristic data The problem of matched mode can not position, can be in the code compilation stage, according to the morphological analysis and language for relying on code encoder Method analysis and syntax tree carry out complete analysis for item code, report an error to the problem of may cause memory overflow, in Disconnected compiling.One of typically application is then, for can implicitly hold one with non-static inner classes and anonymous class The reference of their outer categories and the scene for causing memory overflow passes through the realization and subordinate relation of analysis classes in the compilation phase To determine whether being inner classes or anonymous class, to further check related hidden danger.
The present invention provides a kind of RAM leakage risk checking method, obtains code file to be detected in code development phase, Code to be measured is matched further according to the code characteristic data with RAM leakage risk, and carries out RAM leakage risk Preliminary detection, it is further logical in the code compilation stage when not being matched to the code characteristic data from code file to be detected Cross morphological analysis and syntactic analysis to carry out complete analysis to code file to be detected, so based on the analysis results it is final determine to Detection code file whether there is RAM leakage risk at runtime.To be easy the RAM leakage mistake of carelessness to developer Code is discovered and seized comprehensively, has fundamentally prevented RAM leakage hidden danger, it is quick-fried after on-line running to reduce Memory Leaks A possibility that hair, improves the working efficiency of exploitation and the usage experience of user.
Fourth embodiment
A kind of terminal is present embodiments provided, it is shown in Figure 6, including processor 601, memory 602, communication bus 603;
Communication bus 603 is for realizing the connection communication between processor 601, memory 602;
Memory 602 is for storing one or more programs, and processor 601 is for executing one stored in memory 602 A or multiple programs, the step of to realize RAM leakage risk checking method shown in the various embodiments described above, herein not It repeats again.
5th embodiment
The present invention also provides a kind of computer readable storage medium, one is stored in the computer readable storage medium Or multiple programs, which can be executed by one or more processor, to realize the various embodiments described above Shown in RAM leakage risk checking method the step of, details are not described herein.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or device.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in a storage medium In (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal (can be mobile phone, computer, service Device, air conditioner or network equipment etc.) execute method described in each embodiment of the present invention.
The embodiment of the present invention is described with above attached drawing, but the invention is not limited to above-mentioned specific Embodiment, the above mentioned embodiment is only schematical, rather than restrictive, those skilled in the art Under the inspiration of the present invention, without breaking away from the scope protected by the purposes and claims of the present invention, it can also make very much Form, all of these belong to the protection of the present invention.

Claims (10)

1. a kind of RAM leakage risk checking method, which is characterized in that the RAM leakage risk checking method includes:
Obtain the code file to be detected for being input to the application program of code-development tool;
The code file to be detected is matched according to the preset code characteristic data with RAM leakage risk;
In successful match, determine that the code file to be detected has RAM leakage risk at runtime.
2. RAM leakage risk checking method as described in claim 1, which is characterized in that the acquisition is input to code development The code file to be detected of the application program of tool includes:
It obtains and is input to the code file of the application program of code editor in the Code Edit stage;
And/or it obtains and is input to the code file of the application program of code encoder in the code compilation stage.
3. RAM leakage risk checking method as described in claim 1, which is characterized in that the acquisition is input to code development The code file to be detected of the application program of tool includes:
Obtain the installation file of application program;
Will to the installation file carry out reverse-engineering processing after, be input to code-development tool code file be determined as to Detect code file.
4. RAM leakage risk checking method as described in claim 1, which is characterized in that the acquisition is input to code development The code file to be detected of the application program of tool includes:
From all code files for the application program for being input to code-development tool, code file piece is intercepted according to preset rules Section;
The code file segment is determined as code file to be detected.
5. RAM leakage risk checking method as claimed in claim 4, which is characterized in that described from being input to code development work In all code files of the application program of tool, intercepting code file segment according to preset rules includes:
From all code files for the application program for being input to code-development tool, intercepted according to the type of performed task Code file segment.
6. the RAM leakage risk checking method as described in any one of claims 1 to 5, which is characterized in that the code is special Sign data comprise at least one of the following: class built in keyword, Software Development Kit SDK.
7. the RAM leakage risk checking method as described in any one of claims 1 to 5, which is characterized in that according to default The code characteristic data with RAM leakage risk the code file to be detected is matched after, further includes:
When it fails to match, the code compilation stage by morphological analysis and syntactic analysis come to the code file to be detected into Row complete analysis;
If analyzing result instruction, there are codes lack of standardization to write logic, it is determined that the code file to be detected exists at runtime RAM leakage risk.
8. RAM leakage risk checking method as claimed in claim 7, which is characterized in that it is described when it fails to match, in generation The code compilation phase includes: to carry out complete analysis to the code file to be detected by morphological analysis and syntactic analysis
When it fails to match, in the code compilation stage by morphological analysis and syntactic analysis come in the code file to be detected Inner classes and/or anonymous class identified;
If there are codes lack of standardization to write logic for the analysis result instruction, it is determined that the code file to be detected is at runtime There are RAM leakage risks to include:
If analyzing result instruction, there are nonstandard inner classes and/or anonymous class, it is determined that the code file to be detected is being transported There are RAM leakage risks when row.
9. a kind of terminal, which is characterized in that the terminal includes processor, memory, communication bus;
The communication bus is for realizing the connection communication between processor, memory;
The processor is for executing one or more program stored in memory, to realize as appointed in claim 1 to 8 The step of RAM leakage risk checking method described in one.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage have one or Multiple programs, one or more of programs can be executed by one or more processor, to realize such as claim 1 to 8 Any one of described in RAM leakage risk checking method the step of.
CN201811420317.5A 2018-11-26 2018-11-26 RAM leakage risk checking method, terminal and computer readable storage medium Pending CN109829298A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811420317.5A CN109829298A (en) 2018-11-26 2018-11-26 RAM leakage risk checking method, terminal and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811420317.5A CN109829298A (en) 2018-11-26 2018-11-26 RAM leakage risk checking method, terminal and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN109829298A true CN109829298A (en) 2019-05-31

Family

ID=66859789

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811420317.5A Pending CN109829298A (en) 2018-11-26 2018-11-26 RAM leakage risk checking method, terminal and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109829298A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287110A (en) * 2019-06-19 2019-09-27 北京三快在线科技有限公司 The code detection method and device of application program
CN111638990A (en) * 2020-06-04 2020-09-08 网易(杭州)网络有限公司 Memory leak processing method and device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6367068B1 (en) * 1998-11-13 2002-04-02 Microsoft Corporation Dynamic parsing
CN102117242A (en) * 2009-12-30 2011-07-06 新奥特(北京)视频技术有限公司 Method and device for detecting internal memory leakage
CN103577324A (en) * 2013-10-30 2014-02-12 北京邮电大学 Static detection method for privacy information disclosure in mobile applications
CN106548076A (en) * 2015-09-23 2017-03-29 百度在线网络技术(北京)有限公司 Method and apparatus of the detection using bug code
KR20180010053A (en) * 2016-07-20 2018-01-30 주식회사 이븐스타 Extraction system and method of risk code for vulnerability analysis
CN108416216A (en) * 2018-02-28 2018-08-17 阿里巴巴集团控股有限公司 leak detection method, device and computing device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6367068B1 (en) * 1998-11-13 2002-04-02 Microsoft Corporation Dynamic parsing
CN102117242A (en) * 2009-12-30 2011-07-06 新奥特(北京)视频技术有限公司 Method and device for detecting internal memory leakage
CN103577324A (en) * 2013-10-30 2014-02-12 北京邮电大学 Static detection method for privacy information disclosure in mobile applications
CN106548076A (en) * 2015-09-23 2017-03-29 百度在线网络技术(北京)有限公司 Method and apparatus of the detection using bug code
KR20180010053A (en) * 2016-07-20 2018-01-30 주식회사 이븐스타 Extraction system and method of risk code for vulnerability analysis
CN108416216A (en) * 2018-02-28 2018-08-17 阿里巴巴集团控股有限公司 leak detection method, device and computing device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287110A (en) * 2019-06-19 2019-09-27 北京三快在线科技有限公司 The code detection method and device of application program
CN111638990A (en) * 2020-06-04 2020-09-08 网易(杭州)网络有限公司 Memory leak processing method and device and storage medium
CN111638990B (en) * 2020-06-04 2023-04-28 网易(杭州)网络有限公司 Memory leakage processing method and device and storage medium

Similar Documents

Publication Publication Date Title
CN105404585B (en) Obtain the method and device of code coverage
CN106708554B (en) Program operating method and device
CN109960584A (en) CPU frequency modulation control method, terminal and computer readable storage medium
CN108762876A (en) A kind of input method switching method, mobile terminal and computer storage media
CN105740145B (en) The method and device of element in orient control
CN109274437A (en) A kind of camera anti-interference method, equipment and computer readable storage medium
CN108595203A (en) Application function executes method, mobile terminal and computer readable storage medium
CN107291586A (en) The analysis method and device of a kind of application program
CN110011846A (en) Micro services construction method, device, mobile terminal and storage medium
CN109829298A (en) RAM leakage risk checking method, terminal and computer readable storage medium
CN108762829A (en) A kind of method, client and terminal for image beautification
CN108196968A (en) Mobile terminal restarts localization method, mobile terminal and computer readable storage medium
CN107493396A (en) Button screen method, terminal and computer-readable recording medium
CN110418004A (en) Screenshot processing method, terminal and computer readable storage medium
CN110278481A (en) Picture-in-picture implementing method, terminal and computer readable storage medium
CN110191465A (en) Authority control method, mobile terminal and computer readable storage medium
CN110086925A (en) A kind of application processing method and mobile terminal
CN109309762A (en) Message treatment method, device, mobile terminal and storage medium
CN109062643A (en) A kind of display interface method of adjustment, device and terminal
CN108924352A (en) Sound quality method for improving, terminal and computer readable storage medium
CN108255631A (en) Mobile terminal restarts localization method, mobile terminal and computer readable storage medium
CN109582565A (en) Prevent the method, terminal and computer storage medium of application crashes
CN110188249A (en) A kind of global search method, equipment and computer readable storage medium
CN108900696A (en) A kind of data processing method, terminal and computer readable storage medium
CN109947519A (en) Hardware-accelerated control method, terminal and computer readable storage medium

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190531

RJ01 Rejection of invention patent application after publication