CN110347407A - A kind of method, apparatus, computer equipment and medium obtaining EMS memory occupation amount - Google Patents
A kind of method, apparatus, computer equipment and medium obtaining EMS memory occupation amount Download PDFInfo
- Publication number
- CN110347407A CN110347407A CN201910638175.8A CN201910638175A CN110347407A CN 110347407 A CN110347407 A CN 110347407A CN 201910638175 A CN201910638175 A CN 201910638175A CN 110347407 A CN110347407 A CN 110347407A
- Authority
- CN
- China
- Prior art keywords
- function
- occupation amount
- ems memory
- memory occupation
- hook
- 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
Links
- 230000015654 memory Effects 0.000 title claims abstract description 324
- 238000000034 method Methods 0.000 title claims abstract description 97
- 230000006870 function Effects 0.000 claims abstract description 750
- 238000012544 monitoring process Methods 0.000 claims abstract description 107
- 230000008569 process Effects 0.000 claims abstract description 49
- 238000002347 injection Methods 0.000 claims abstract description 44
- 239000007924 injection Substances 0.000 claims abstract description 44
- 238000004590 computer program Methods 0.000 claims description 14
- 238000003860 storage Methods 0.000 claims description 13
- 238000004364 calculation method Methods 0.000 claims description 4
- 238000010586 diagram Methods 0.000 description 10
- 238000012545 processing Methods 0.000 description 7
- 239000011800 void material Substances 0.000 description 4
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 239000008186 active pharmaceutical agent Substances 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 238000012163 sequencing technique Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000000243 solution Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/3644—Software debugging by instrumenting at runtime
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
- G06F8/4434—Reducing the memory space required by the program code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
Abstract
The embodiment of the present invention provides a kind of method for obtaining EMS memory occupation amount, comprising: obtains function information all in program module;Hook is carried out using starting point of first Hook Function to each function, by the starting point of the first monitoring function call injection to each function;Hook is carried out using end point of second Hook Function to each function, by the end point of the second monitoring function call injection to each function;When monitoring at the beginning of each function executes using the first monitoring function, the corresponding first EMS memory occupation amount of each function is obtained;When monitoring the finish time that each function executes using the second monitoring function, the corresponding second EMS memory occupation amount of each function is obtained;Each function used EMS memory occupation amount in the process of implementation is determined according to corresponding first EMS memory occupation amount and corresponding second EMS memory occupation amount;In this way, the EMS memory occupation amount that can learn which function uses is bigger, and then pointedly optimizes to the function, it is ensured that the operational efficiency of program.
Description
Technical field
The invention belongs to technical field of software development more particularly to a kind of method, apparatus for obtaining EMS memory occupation amount, calculate
Machine equipment and medium.
Background technique
In program development, the use of memory is very crucial index for program operation, in program operation,
If EMS memory occupation amount greatly, will affect the operational efficiency of entire program very much.
It is the service condition for constantly removing to obtain current memory by one timer of setting in the prior art, to monitor
The usage amount of memory, however such method can only monitor memory usage amount, and optimization direction can not be provided for developer, is caused out
Hair personnel cannot pointedly optimize EMS memory occupation, and then can not also improve program operational efficiency.
Summary of the invention
In view of the problems of the existing technology, the embodiment of the invention provides a kind of methods for obtaining EMS memory occupation amount, dress
It sets, computer equipment and medium, when EMS memory occupation amount is bigger, in the prior art can not for solving in program development
Optimization direction is provided for developer, causes developer that cannot pointedly optimize to EMS memory occupation, and then lead to journey
The technical issues of operational efficiency of sequence cannot be guaranteed.
The embodiment of the present invention provides a kind of method for obtaining EMS memory occupation amount, which comprises
Obtain function information all in program module;
Hook is carried out using starting point of preset first Hook Function to each function, by preset first monitoring function note
Enter to the starting point of each function;
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring letter
Number is injected into the end point of each function;
When monitoring at the beginning of each function executes using the first monitoring function, each function is obtained
Corresponding first EMS memory occupation amount;
When monitoring the finish time that each function executes using the second monitoring function, obtain described each
The corresponding second EMS memory occupation amount of function;
Each letter is determined according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
Used EMS memory occupation amount, the EMS memory occupation amount are the second EMS memory occupation amount and described first to number in the process of implementation
The difference of EMS memory occupation amount.
In above scheme, in the acquisition program module after all function informations, comprising:
Each function information is stored in the function chained list pre-established according to pre-set function structure;Its
In,
The corresponding function structure of each function, the function structure includes: the String for recording function name
Name, for the first parameter string module of logging program module title, for recording the starting point of described program module
Second parameter DWORD dwbase of location, for recording third of the function relative to the start offset amount of described program module
Parameter DWORD dwstart, it is described for recording for recording the 4th parameter DWORD dwsize of function memory itself
Function is in the 5th parameter Long dwmemory for executing start time corresponding first EMS memory occupation amount.
It is described to carry out hook using starting point of preset first Hook Function to each function in above scheme, it will preset
First monitoring function call injection to each function starting point include:
The initial address for obtaining the corresponding program module of each function one by one and each function are relative to corresponding journey
The start offset amount of sequence module;
According to the initial address of corresponding program module and each function relative to the corresponding program module
Start offset amount determines the starting memory address of each function;
The starting of function call injection to each function is monitored by pre-establish first using first Hook Function
At memory address, the current thread where each function is updated, completes the hook to each function starting point.
It is described to carry out hook using end point of preset second Hook Function to each function in above scheme, it will preset
Second monitoring function call injection to each function end point include:
The initial address of the corresponding program module of each function, the memory of each function itself and described are obtained one by one
Start offset amount of each function relative to corresponding program module;
It is inclined relative to the starting of corresponding program module according to the memory of each function itself and each function
Shifting amount determines the end memory address of each function;
The end of function call injection to each function is monitored by pre-establish second using second Hook Function
At memory address, the current thread where each function is updated, completes the hook to each function end point.
It is described to carry out hook using end point of preset second Hook Function to each function in above scheme, it will
After preset second monitoring function call injection to the end point of each function, comprising:
Obtain the handle of the current process where each function;
When each function starts to execute, based on the handle of the current process, function is obtained using memory usage amount and is obtained
Take each function corresponding first EMS memory occupation amount at the beginning of execution;
Each first EMS memory occupation amount is assigned to the 5th parameter of respective function structure respectively.
It is described when being monitored at the beginning of each function executes using the first monitoring function in above scheme,
Obtain the corresponding first EMS memory occupation amount of each function, comprising:
When being monitored at the beginning of each function executes using the first monitoring function, by each function
Current starting memory address is matched one by one with the starting memory address of all functions in the function chained list;
If when successful match, corresponding first memory of each function is obtained from the function structure of successful match
Occupancy.
It is described when the finish time for monitoring each function execution using the second monitoring function in above scheme
When, obtain the corresponding second EMS memory occupation amount of each function, comprising:
Obtain the handle of the current process where each function;
When monitoring the finish time of objective function execution using the second monitoring function, it is based on the current process
Handle, using memory usage amount obtain function obtain each function within the finish time corresponding described second of execution
Deposit occupancy.
The embodiment of the present invention also provides a kind of device for obtaining EMS memory occupation amount, and described device includes:
First acquisition unit, for obtaining function information all in program module;
Injection unit will be preset for carrying out hook using starting point of preset first Hook Function to each function
First monitors the starting point of function call injection to each function;
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring letter
Number is injected into the end point of each function;
Second acquisition unit, at the beginning of monitoring each function using the first monitoring function and executing
When, obtain the corresponding first EMS memory occupation amount of each function;
Third acquiring unit, at the end of monitoring each function using the second monitoring function and executing
When quarter, the corresponding second EMS memory occupation amount of each function is obtained;
Determination unit, for true according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
Used EMS memory occupation amount, the EMS memory occupation amount are second EMS memory occupation to fixed each function in the process of implementation
The difference of amount and the first EMS memory occupation amount.
The embodiment of the present invention also provides a kind of computer readable storage medium, is stored thereon with computer program, feature
It is, which realizes method described in any of the above embodiments when being executed by processor.
The embodiment of the present invention also provides a kind of computer equipment, including memory, processor and storage are on a memory simultaneously
The computer program that can be run on a processor, which is characterized in that the processor is realized any of the above-described when executing described program
Method described in.
The embodiment of the invention provides a kind of method, apparatus, computer equipment and server for obtaining EMS memory occupation amount, institutes
The method of stating includes: to obtain function information all in program module;Starting using preset first Hook Function to each function
Point carries out hook, by the starting point of preset first monitoring function call injection to each function;Utilize preset second Hook Function
Hook is carried out to the end point of each function, by the end point of preset second monitoring function call injection to each function;
When monitoring at the beginning of each function executes using the first monitoring function, each function corresponding the is obtained
One EMS memory occupation amount;When monitoring the finish time that each function executes using the second monitoring function, institute is obtained
State the corresponding second EMS memory occupation amount of each function;According in the corresponding first EMS memory occupation amount and corresponding described second
Deposit occupancy determine each function in the process of implementation used in EMS memory occupation amount, the EMS memory occupation amount is described the
The difference of two EMS memory occupation amounts and the first EMS memory occupation amount;In this way, being executed for each function in each function
Start time gets the first EMS memory occupation amount of function when executing start time using the first Hook Function;In the knot of execution
The beam moment gets the second EMS memory occupation amount of function when executing finish time, the second EMS memory occupation using the first Hook Function
The difference of amount and the first EMS memory occupation amount is the EMS memory occupation amount that the function uses in the process of implementation;It in this way can be clearly
Obtain each function EMS memory occupation amount required for implementation procedure, then developer can apparent which function make
EMS memory occupation amount is bigger, and then can pointedly optimize to the function, it is ensured that the operational efficiency of program.
Detailed description of the invention
Fig. 1 is the method flow schematic diagram for the acquisition EMS memory occupation amount that the embodiment of the present invention one provides;
Fig. 2 is the apparatus structure schematic diagram provided by Embodiment 2 of the present invention for obtaining EMS memory occupation amount;
Fig. 3 is the computer media structural schematic diagram for the acquisition EMS memory occupation amount that the embodiment of the present invention three provides;
Fig. 4 is the computer media device structure schematic diagram for the acquisition EMS memory occupation amount that the embodiment of the present invention four provides.
Specific embodiment
In order to solve in program development, when EMS memory occupation amount is bigger, can not be mentioned in the prior art for developer
For optimizing direction, cause developer that cannot pointedly optimize to EMS memory occupation, and then lead to the operational efficiency of program
The technical issues of cannot being guaranteed, the present invention provides it is a kind of obtain the method, apparatus of EMS memory occupation amount, computer equipment and
Server, method include: to obtain function information all in program module;Using preset first Hook Function to each function
Starting point carries out hook, by the starting point of preset first monitoring function call injection to each function;Utilize preset second hook
Function carries out hook to the end point of each function, by the end of preset second monitoring function call injection to each function
Point;When monitoring at the beginning of each function executes using the first monitoring function, it is corresponding to obtain each function
The first EMS memory occupation amount;When monitoring the finish time that each function executes using the second monitoring function, obtain
Take the corresponding second EMS memory occupation amount of each function;According to the corresponding first EMS memory occupation amount and corresponding described
Two EMS memory occupation amounts determine each function used EMS memory occupation amount in the process of implementation, and the EMS memory occupation amount is institute
State the difference of the second EMS memory occupation amount Yu the first EMS memory occupation amount.
Technical solution of the present invention is described in further detail below by drawings and the specific embodiments.
Embodiment one
The present embodiment provides a kind of methods for obtaining EMS memory occupation amount, as shown in Figure 1, method includes:
S110 obtains function information all in program module;
Here, program module may include a variety of, and the method for obtaining function information for every kind of program module is different
's.Program module in the present embodiment includes: self defining programm module, third hair program module and the included program module of system
(hereinafter referred to as system program modules).
As a kind of optional embodiment, when described program module is self defining programm module, function is customized journey
When function in sequence module, function information all in program module is obtained, may include:
The corresponding mapped file map of the self defining programm module is obtained, the mapped file is when compiling custom block
It is automatically generated;
The function information of the function is obtained according to mapped file;It wherein, include the letter of all functions in mapped file
Number information, function information includes: the memory of function name, function itself and the start offset amount relative to program module.
As a kind of optional embodiment, when program module is third party's program module or system program modules, function is
Function in third party's program module or for system program modules function when, obtain function letter all in program module
Breath, comprising:
The file format for obtaining third party's program module or system program modules, using decompiling instrument to file format into
Row parsing, obtains the function information of function.Wherein, decompiling instrument may include: IDAPro tool.
Here, in order to subsequent convenient for searching each function, after obtaining function information all in program module, comprising:
By each function information be stored in the function chained list pre-established according to pre-set function structure;Wherein,
Because function include it is multiple, so each function correspond to a function structure, by each function information according to pre-set function
When structure is stored in the function chained list pre-established, the function letter that a function is often got according to acquisition sequence can be
It after breath, is stored immediately in function list, is also possible to after obtaining the function information of all functions, then be collectively stored in function
In list.
Function structure includes: the String name for recording function name, and first for logging program module title
Parameter string module, the second parameter DWORD dwbase of the initial address for recording described program module, for remembering
Third parameter DWORD dwstart of the function relative to the start offset amount of described program module is recorded, it is described for recording
4th parameter DWORD dwsize of function memory itself is being executed in start time corresponding first for recording the function
Deposit the 5th parameter Long dwmemory of occupancy.Specific function structure is as follows:
Struct funcinfo{
String name;For recording the title of function.
string module;Title for logging program module.
DWORD dwbase;Initial address for logging program module.
DWORD dwstart is used to record the start offset relative to program module of function.
DWORD dwsize is used to record the memory of function itself.
Long dwmemory is for recording first EMS memory occupation amount memory of the function when executing start time.
}
The function information of each function is stored in function chained list according to function structure, and the function chained list of this paper is as follows:
Std::list<funcinfo>funclist;
For example, if function program module is the function of self defining programm module, the map text of the program module is obtained
Part, by reading the function structure of the map file generated function, function structure is as follows:
Funcinfo Func1;Create a function structure.
Func1.module=network;This module is network module.
Func1.name=" send ";This function is to send network data function.
Func1.dwstart=0x120;The start offset that this function is equivalent to network module is 0x120.
Func1.dwsize=0x200;The memory of this function itself is 0x200 byte.
Func1.dwmemory=0;The the first EMS memory occupation amount for first initializing this function is 0.
The function information of this function is stored in function chained list Funclist:
Funclist.push_back(func1);
It is to make that corresponding function information is stored in function chained list Funclist in the same way for other functions
In, details are not described herein again.
S111 carries out hook using starting point of preset first Hook Function to each function, preset first is monitored
Function call injection to each function starting point;It is carried out using end point of preset second Hook Function to each function
Hook, by the end point of preset second monitoring function call injection to each function;
Here, because not every function when being executed needed for EMS memory occupation amount it is all bigger, for fairly simple
For function, when being executed, many memories that have more than is needed are accounted in fact, the operational efficiency of entire program will not be caused very big
It influences, therefore in order to reduce the occupancy to resource, for this kind of function, does not need to carry out hook to it.
Hook so is being carried out using starting point of preset first Hook Function to each function, preset first is being monitored
Before function call injection to the starting point of each function, can also include:
Obtain the lines of code of each function;
When the lines of code of function is less than preset threshold value, then the function is filtered out, hook is not carried out to it;Its
In, preset threshold value can be 3~5 rows.
After the function information for getting each function, the hook tool based on system utilizes preset first Hook Function
Hook is carried out to the starting point of each function, by the starting point of preset first monitoring function call injection to each function, can utilize
At the beginning of first monitoring function monitors function execution.The end of each function is clicked through using preset second Hook Function
Row hook, by the end point of preset second monitoring function call injection to each function, can be supervised using the second monitoring function
Control the finish time of function execution.Wherein, the first Hook Function in the present embodiment and the second Hook Function are hook tool
Hook function.
As a kind of optional embodiment, hook is carried out using starting point of preset first Hook Function to each function,
By the starting point of preset first monitoring function call injection to each function, comprising:
Traverse function chained list, obtain one by one the corresponding program module of each function initial address and each function relative to
The start offset amount of corresponding program module;
Start offset according to the initial address of corresponding program module and each function relative to corresponding program module
Amount determines the starting memory address of each function;
The starting memory for monitoring function call injection to each function for pre-establish first using first Hook Function
At address, the current thread where each function is updated, completes the hook to each function starting point.
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring letter
Number is injected into the end point of each function, comprising:
The initial address of the corresponding program module of each function, the memory of each function itself and described are obtained one by one
Start offset amount of each function relative to corresponding program module;
It is inclined relative to the starting of corresponding program module according to the memory of each function itself and each function
Shifting amount determines the end memory address of each function;
The end memory for monitoring function call injection to each function for pre-establish second using the second Hook Function
At address, the current thread where each function is updated, completes the hook to each function end point.
It here, is the starting point and knot according to the function order in function chained list to function when carrying out hook to function
Beam spot carries out hook's.I.e. to the starting point of current function and the equal hook of end point after, then the starting to next function
Point and end point carry out hook.
Program specifically is accomplished by
Traverse function chained list:
For (auto it=Funclist.begin ();it!=Funclist.end ();++it){
DWORD dwbase=GetModuleHandle (it.module);Corresponding journey is obtained first for each function
The initial address of sequence module:
It.dwbase=dwbase;The the second parameter initial address of program module being assigned in function structure.
DWORD address_start=dwbase+it.dwstart;The starting memory address calculating process of function.
DWORD address_end=dwbase+it.dwstart+it.dwsize;The end memory address meter of the function
Calculation process.
DetourTransactionBegin();The starting point of function and end are clicked through using the hoook tool of system
Row hook.
DetourUpdateThread(GetCurrentThread());Call the function of hoook tool detous
DetourTransactionBegin is ready to carry out hook: the first Hook Function is injected into the starting memory address of each function
Place, the second Hook Function is injected at the end memory address of each function.
Then the renewal function DetourUpdateThread of API is called to carry out the current thread where renewal function.
DetourAttach(address_start,watchfuncstart);It is supervised at the beginning of being executed to function
Control.
DetourAttach(address_end,watchfuncend);The finish time executed to function is monitored.
DetourTransactionCommit();
}
In above procedure realization, address_start is the starting memory address of function, and dwbase is program module
Initial address, dwstart are start offset amount of the function relative to described program module, and dwsize is the memory of function itself.
Here, the above method is that applicable, described here generic function refers to function not to function for generic function
The function itself being called.And for special function (such as the function for needing to be called itself), hook is carried out to it
When, in addition to the position of hook is different, other processing modes are identical.
Specifically, when carrying out hook to special function (such as recursive function), first determine what calling function itself started
First Hook Function, is then injected into and function itself is called to start by memory address and the memory address for calling function itself to terminate
Memory address at, the second Hook Function is injected into and is called at the memory address that terminates of function itself.
As a kind of optional embodiment, carried out using end point of preset second Hook Function to each function
After hook, comprising:
Obtain the handle of the current process where each function;
When each function starts to execute, the handle based on current process obtains function using memory usage amount and obtains often
A function corresponding first EMS memory occupation amount at the beginning of execution;
First EMS memory occupation amount is stored in preset storage variable;
Each first EMS memory occupation amount in storage variable is assigned to the 5th parameter of respective function structure respectively.
It is implemented as follows:
Long GetMeory(){
HANDLE handle=GetCurrentProcess ();The handle of current process is obtained first.
PROCESS_MEMORY_COUNTERS pmc;One is defined for storing the storage variable of the first EMS memory occupation amount.
BOOLWINAPIGetProcessMemoryInfo(
HANDLE Process,
PPROCESS_MEMORY_COUNTERS ppsmemCounters,
DWORD cb
);Function etProcessMemoryInfo is obtained using memory usage amount to obtain the first EMS memory occupation amount.
GetProcessMemoryInfo(handle,&pmc,sizeof(pmc));First EMS memory occupation amount is stored in
In variable pmc.
Here, parameter Process is the handle of current process, PPROCESS_MEMORY_
COUNTERSppsmemCounters is the structure for the first EMS memory occupation amount that returns, and cb is the size of the structure.
S112 is obtained described every when being monitored at the beginning of each function executes using the first monitoring function
The corresponding first EMS memory occupation amount of a function;When the end for monitoring each function execution using the second monitoring function
When the moment, the corresponding second EMS memory occupation amount of each function is obtained;
Here, because the first occupancy that all functions use at the beginning of execution is transferred in each function structure
5th parameter, therefore in function implementation procedure, need to obtain the first EMS memory occupation amount from corresponding function structure.
When at the beginning of monitoring each function using first Hook Function and execute, each function is obtained
Corresponding first EMS memory occupation amount, comprising:
When at the beginning of monitoring each function using first Hook Function and execute, by the current of each function
Starting memory address is matched one by one with the starting memory address of all functions in the function chained list;
If when successful match, corresponding first memory of each function is obtained from the function structure of successful match
Occupancy.Wherein, first monitoring function in include each function current starting memory address, currently terminate memory address and
The information such as function name.
Specific code is accomplished by
Void watchfuncstart(DWORD address){
For (auto it=Funclist.begin ();it!=Funclist.end ();++it){
If (it.address_start+it.dwbase==address) is { by the current starting memory of each function
The starting memory address of all functions is matched in the and function chained list of location.
It.dwmemory=GetMeory ();
}
Here, the acquisition modes of the second EMS memory occupation amount and the acquisition modes of the first EMS memory occupation amount are different, and work as benefit
When monitoring the finish time that each function executes with the second monitoring function, each function corresponding the is obtained
Two EMS memory occupation amounts, comprising:
Obtain the handle of the current process where each function;
When monitoring the finish time of objective function execution using the second monitoring function, it is based on the current process
Handle, using memory usage amount obtain function obtain each function within the finish time corresponding described second of execution
Deposit occupancy.
After getting the second EMS memory occupation amount because the second EMS memory occupation amount includes many, in order to can with it is determined that
Second EMS memory occupation amount of which function, therefore also need each function currently terminating memory address and the functional-link
The end memory address of all functions is matched one by one in table, can accurately correspond to the second committed memory amount to each letter
Number.
S113 is determined described every according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
A function in the process of implementation used in EMS memory occupation amount, the EMS memory occupation amount be the second EMS memory occupation amount with it is described
The difference of first EMS memory occupation amount;
After the first EMS memory occupation amount of each function and the second EMS memory occupation amount are got, according to corresponding described
Used in first EMS memory occupation amount and the corresponding second EMS memory occupation amount determine each function in the process of implementation
EMS memory occupation amount, the EMS memory occupation amount are the difference of the second EMS memory occupation amount and the first EMS memory occupation amount.Specifically
Code is accomplished by
Void watchfuncsend(DWORD address){
For (auto it=Funclist.begin ();it!=Funclist.end ();++it){
Each function { is currently terminated memory address by If (it.address_end+it.dwbase==address)
The end memory address of all functions is matched in and function chained list.
Long memory=GetMeory ();
Dwmemory=memory-it.dwmemory;
}
}
In above-mentioned code, memory is the second EMS memory occupation amount, and it.dwmemory is the first EMS memory occupation amount,
Dwmemory is the two difference.
Each function used EMS memory occupation amount in the process of implementation, root can be clearly checked in order to facilitate developer
Determine that each function was executing according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
After EMS memory occupation amount used in journey, comprising:
Memory using system ranking functions sort function, according to sequence from big to small to each function in the process of implementation
Occupancy is ranked up.Code is accomplished by
Sort (Funclist.begin (), Funclist.end ());
Specifically, than if any tri- functions of A, B, C, the EMS memory occupation amount of A function is the EMS memory occupation amount of 200, B function
It is 300, the EMS memory occupation amount of C function is 100, then last ranking results are (300) B, A (200), C (100).
It can learn that the EMS memory occupation amount of B function is the largest from ranking results, preferentially B function can be optimized.
In this way, each function EMS memory occupation amount required for implementation procedure can be clearly followed that, then developer can be light
The EMS memory occupation amount for easily learning which function uses is bigger, can pointedly optimize to the function, and then ensure journey
The operational efficiency of sequence.
Based on same inventive concept, a kind of device for obtaining EMS memory occupation amount, detailed in Example two is also provided herein.
The present embodiment provides a kind of devices for obtaining EMS memory occupation amount, as shown in Fig. 2, device includes: first acquisition unit
21, injection unit 22, second acquisition unit 23, third acquiring unit 24, determination unit 25 and sequencing unit 26;Wherein,
Here, program module may include a variety of, and the method for obtaining function information for every kind of program module is different
's.Program module in the present embodiment includes: self defining programm module, third hair program module and the included program module of system
(hereinafter referred to as system program modules).
As a kind of optional embodiment, when described program module is self defining programm module, function is customized journey
When function in sequence module, first acquisition unit 21 is used for:
The corresponding mapped file map of the self defining programm module is obtained, the mapped file is when compiling custom block
It is automatically generated;
The function information of the function is obtained according to mapped file;It wherein, include the letter of all functions in mapped file
Number information, function information includes: the memory of function name, function itself and the start offset amount relative to program module.
As a kind of optional embodiment, when program module is third party's program module or system program modules, function is
Function in third party's program module or for system program modules function when, first acquisition unit 21 is used for:
The file format for obtaining third party's program module or system program modules, using decompiling instrument to file format into
Row parsing, obtains the function information of function.Wherein, decompiling instrument may include: IDAPro tool.
Here, in order to subsequent convenient for searching each function, after obtaining function information all in program module, comprising:
By each function information be stored in the function chained list pre-established according to pre-set function structure;Wherein,
Because function include it is multiple, so each function correspond to a function structure, by each function information according to pre-set function
When structure is stored in the function chained list pre-established, the function letter that a function is often got according to acquisition sequence can be
It after breath, is stored immediately in function list, is also possible to after obtaining the function information of all functions, then be collectively stored in function
In list.
Function structure includes: the String name for recording function name, and first for logging program module title
Parameter string module, the second parameter DWORD dwbase of the initial address for recording described program module, for remembering
Third parameter DWORD dwstart of the function relative to the start offset amount of described program module is recorded, it is described for recording
4th parameter DWORD dwsize of function memory itself is being executed in start time corresponding first for recording the function
Deposit the 5th parameter Longdwmemory of occupancy.Specific function structure is as follows:
Struct funcinfo{
String name;For recording the title of function.
string module;Title for logging program module.
DWORD dwbase;Initial address for logging program module.
DWORD dwstart is used to record the start offset relative to program module of function.
DWORD dwsize is used to record the memory of function itself.
Long dwmemory is for recording first EMS memory occupation amount memory of the function when executing start time.
}
The function information of each function is stored in function chained list according to function structure, and the function chained list of this paper is as follows:
Std::list<funcinfo>funclist;
For example, if function program module is the function of self defining programm module, the map text of the program module is obtained
Part, by reading the function structure of the map file generated function, function structure is as follows:
Funcinfo Func1;Create a function structure.
Func1.module=network;This module is network module.
Func1.name=" send ";This function is to send network data function.
Func1.dwstart=0x120;The start offset that this function is equivalent to network module is 0x120.
Func1.dwsize=0x200;The memory of this function itself is 0x200 byte.
Func1.dwmemory=0;The the first EMS memory occupation amount for first initializing this function is 0.
The function information of this function is stored in function chained list Funclist:
Funclist.push_back(func1);
It is to make that corresponding function information is stored in function chained list Funclist in the same way for other functions
In, details are not described herein again.
Here, because not every function when being executed needed for EMS memory occupation amount it is all bigger, for fairly simple
For function, when being executed, many memories that have more than is needed are accounted in fact, the operational efficiency of entire program will not be caused very big
It influences, therefore in order to reduce the occupancy to resource, for this kind of function, does not need to carry out hook to it.
So injection unit 22 is carrying out hook using starting point of preset first Hook Function to each function, will preset
First monitoring function call injection to the starting point of each function before, be also used to:
Obtain the lines of code of each function;
When the lines of code of function is less than preset threshold value, then the function is filtered out, hook is not carried out to it;Its
In, preset threshold value can be 3~5 rows.
After the function information for getting each function, hook tool of the injection unit 22 based on system utilizes preset
One Hook Function carries out hook to the starting point of each function, by the starting of preset first monitoring function call injection to each function
Point, at the beginning of it can monitor function execution using the first monitoring function.Using preset second Hook Function to each letter
Several end point carries out hook, by the end point of preset second monitoring function call injection to each function, can utilize the
Two monitoring functions monitor the finish time of function execution.Wherein, the first Hook Function in the present embodiment and the second hook letter
Number is the hook function of hook tool.
As a kind of optional embodiment, injection unit 22 is using preset first Hook Function to the starting point of each function
Hook is carried out, by the starting point of preset first monitoring function call injection to each function, comprising:
Traverse function chained list, obtain one by one the corresponding program module of each function initial address and each function relative to
The start offset amount of corresponding program module;
Start offset according to the initial address of corresponding program module and each function relative to corresponding program module
Amount determines the starting memory address of each function;
The starting memory for monitoring function call injection to each function for pre-establish first using first Hook Function
At address, the current thread where each function is updated, completes the hook to each function starting point.
Injection unit 22 carries out hook using end point of preset second Hook Function to each function, will be preset
Second monitors the end point of function call injection to each function, comprising:
The initial address of the corresponding program module of each function, the memory of each function itself and described are obtained one by one
Start offset amount of each function relative to corresponding program module;
It is inclined relative to the starting of corresponding program module according to the memory of each function itself and each function
Shifting amount determines the end memory address of each function;
The end memory for monitoring function call injection to each function for pre-establish second using the second Hook Function
At address, the current thread where each function is updated, completes the hook to each function end point.
It here, is the starting point and knot according to the function order in function chained list to function when carrying out hook to function
Beam spot carries out hook's.I.e. to the starting point of current function and the equal hook of end point after, then the starting to next function
Point and end point carry out hook.
Program specifically is accomplished by
Traverse function chained list:
For (auto it=Funclist.begin ();it!=Funclist.end ();++it){
DWORD dwbase=GetModuleHandle (it.module);Corresponding journey is obtained first for each function
The initial address of sequence module:
It.dwbase=dwbase;The the second parameter initial address of program module being assigned in function structure.
DWORD address_start=dwbase+it.dwstart;The starting memory address calculating process of function.
DWORD address_end=dwbase+it.dwstart+it.dwsize;The end memory address meter of the function
Calculation process.
DetourTransactionBegin();The starting point of function and end are clicked through using the hoook tool of system
Row hook.
DetourUpdateThread(GetCurrentThread());Call the function of hoook tool detous
DetourTransactionBegin is ready to carry out hook: the first Hook Function is injected into the starting memory address of each function
Place, the second Hook Function is injected at the end memory address of each function.
Then the renewal function DetourUpdateThread of API is called to carry out the current thread where renewal function.
DetourAttach(address_start,watchfuncstart);It is supervised at the beginning of being executed to function
Control.
DetourAttach(address_end,watchfuncend);The finish time executed to function is monitored.
DetourTransactionCommit();
}
In above procedure realization, address_start is the starting memory address of function, and dwbase is program module
Initial address, dwstart are start offset amount of the function relative to described program module, and dwsize is the memory of function itself.
Here, the above method is that applicable, described here generic function refers to function not to function for generic function
The function itself being called.And for special function (such as the function for needing to be called itself), hook is carried out to it
When, in addition to the position of hook is different, other processing modes are identical.
Specifically, injection unit 22 first determines when carrying out hook to special function (such as recursive function) and calls function
The memory address that itself starts and the memory address for calling function itself to terminate, are then injected into calling letter for the first Hook Function
At the memory address that number starts itself, the second Hook Function is injected at the memory address for calling function itself to terminate.
As a kind of optional embodiment, carried out using end point of preset second Hook Function to each function
After hook, second acquisition unit 23 is used for:
Obtain the handle of the current process where each function;
When each function starts to execute, the handle based on current process obtains function using memory usage amount and obtains often
A function corresponding first EMS memory occupation amount at the beginning of execution;
First EMS memory occupation amount is stored in preset storage variable;
Each first EMS memory occupation amount in storage variable is assigned to the 5th parameter of respective function structure respectively.
It is implemented as follows:
Long GetMeory(){
HANDLE handle=GetCurrentProcess ();The handle of current process is obtained first.
PROCESS_MEMORY_COUNTERS pmc;One is defined for storing the storage variable of the first EMS memory occupation amount.
BOOLWINAPIGetProcessMemoryInfo(
HANDLE Process,
PPROCESS_MEMORY_COUNTERS ppsmemCounters,
DWORD cb
);Function etProcessMemoryInfo is obtained using memory usage amount to obtain the first EMS memory occupation amount.
GetProcessMemoryInfo(handle,&pmc,sizeof(pmc));First EMS memory occupation amount is stored in
In variable pmc.
Here, parameter Process is the handle of current process, PPROCESS_MEMORY_
COUNTERSppsmemCounters is the structure for the first EMS memory occupation amount that returns, and cb is the size of the structure.
Here, because the first occupancy that all functions use at the beginning of execution is transferred in each function structure
5th parameter, therefore in function implementation procedure, need to obtain the first EMS memory occupation amount from corresponding function structure.
When second acquisition unit 23 is monitored at the beginning of each function executes using first Hook Function, obtain
Take the corresponding first EMS memory occupation amount of each function, comprising:
When at the beginning of monitoring each function using first Hook Function and execute, by the current of each function
Starting memory address is matched one by one with the starting memory address of all functions in the function chained list;
If when successful match, corresponding first memory of each function is obtained from the function structure of successful match
Occupancy.Wherein, first monitoring function in include each function current starting memory address, currently terminate memory address and
The information such as function name.
Specific code is accomplished by
Void watchfuncstart(DWORD address){
For (auto it=Funclist.begin ();it!=Funclist.end ();++it){
If (it.address_start+it.dwbase==address) is { by the current starting memory of each function
The starting memory address of all functions is matched in the and function chained list of location.
It.dwmemory=GetMeory ();
}
Here, the acquisition modes of the second EMS memory occupation amount and the acquisition modes of the first EMS memory occupation amount are different, when
When three acquiring units 24 monitor the finish time that each function executes using the second monitoring function, obtain described every
The corresponding second EMS memory occupation amount of a function, comprising:
Obtain the handle of the current process where each function;
When monitoring the finish time of objective function execution using the second monitoring function, it is based on the current process
Handle, using memory usage amount obtain function obtain each function within the finish time corresponding described second of execution
Deposit occupancy.
After getting the second EMS memory occupation amount because the second EMS memory occupation amount includes many, in order to can with it is determined that
Second EMS memory occupation amount of which function, therefore also need each function currently terminating memory address and the functional-link
The end memory address of all functions is matched one by one in table, can accurately correspond to the second committed memory amount to each letter
Number.
After the first EMS memory occupation amount of each function and the second EMS memory occupation amount are got, 25 basis of determination unit
The corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount determine each function in implementation procedure
Used in EMS memory occupation amount, the EMS memory occupation amount is the second EMS memory occupation amount and the first EMS memory occupation amount
Difference.Specific code is accomplished by
Void watchfuncsend(DWORD address){
For (auto it=Funclist.begin ();it!=Funclist.end ();++it){
Each function { is currently terminated memory address by If (it.address_end+it.dwbase==address)
The end memory address of all functions is matched in and function chained list.
Long memory=GetMeory ();
Dwmemory=memory-it.dwmemory;
}
}
In above-mentioned code, memory is the second EMS memory occupation amount, and it.dwmemory is the first EMS memory occupation amount,
Dwmemory is the two difference.
Each function used EMS memory occupation amount in the process of implementation, root can be clearly checked in order to facilitate developer
Determine that each function was executing according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
After EMS memory occupation amount used in journey, sequencing unit 26 is used for:
Memory using system ranking functions sort function, according to sequence from big to small to each function in the process of implementation
Occupancy is ranked up.Code is accomplished by
Sort (Funclist.begin (), Funclist.end ());
Specifically, than if any tri- functions of A, B, C, the EMS memory occupation amount of A function is the EMS memory occupation amount of 200, B function
It is 300, the EMS memory occupation amount of C function is 100, then last ranking results are (300) B, A (200), C (100).
The method and device energy bring beneficial effect provided in an embodiment of the present invention for obtaining EMS memory occupation amount is at least:
The embodiment of the present invention provides a kind of method, apparatus, computer equipment and medium for obtaining EMS memory occupation amount, the side
Method includes: to obtain function information all in program module;The starting of each function is clicked through using preset first Hook Function
Row hook, by the starting point of preset first monitoring function call injection to each function;Using preset second Hook Function to institute
The end point for stating each function carries out hook, by the end point of preset second monitoring function call injection to each function;Work as benefit
When being monitored at the beginning of each function executes with the first monitoring function, obtain in each function corresponding first
Deposit occupancy;When monitoring the finish time that each function executes using the second monitoring function, obtain described every
The corresponding second EMS memory occupation amount of a function;It is accounted for according to the corresponding first EMS memory occupation amount and corresponding second memory
Dosage determines each function used EMS memory occupation amount in the process of implementation, and the EMS memory occupation amount is in described second
Deposit the difference of occupancy Yu the first EMS memory occupation amount.In this way, for each function, in the beginning that each function executes
Moment gets the first EMS memory occupation amount of function when executing start time using the first Hook Function;Execution at the end of
Carve, using the first Hook Function get execute finish time when function the second EMS memory occupation amount, the second EMS memory occupation amount and
The difference of first EMS memory occupation amount is the EMS memory occupation amount that the function uses in the process of implementation;It can clearly follow that in this way
Each function EMS memory occupation amount required for implementation procedure, then developer can apparent which function use
EMS memory occupation amount is bigger, can pointedly optimize to the function, and then ensure the operational efficiency of program.
Embodiment three
The present embodiment provides a kind of computer equipments, as shown in figure 3, including memory 310, processor 320 and being stored in
On memory 310 and the computer program 311 that can run on the processor 320, when processor 320 executes computer program 311
It performs the steps of
Obtain function information all in program module;
Hook is carried out using starting point of preset first Hook Function to each function, by preset first monitoring function note
Enter to the starting point of each function;
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring letter
Number is injected into the end point of each function;
When monitoring at the beginning of each function executes using the first monitoring function, each function is obtained
Corresponding first EMS memory occupation amount;
When monitoring the finish time that each function executes using the second monitoring function, obtain described each
The corresponding second EMS memory occupation amount of function;
Each letter is determined according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
Used EMS memory occupation amount, the EMS memory occupation amount are the second EMS memory occupation amount and described first to number in the process of implementation
The difference of EMS memory occupation amount.
In the specific implementation process, it when processor 320 executes computer program 311, may be implemented any in embodiment one
Embodiment.
Since the computer equipment that the present embodiment is introduced is a kind of opening direct broadcasting room page in implementation the embodiment of the present application one
Equipment used by the method in face, so based on method described in the embodiment of the present application one, those skilled in the art
The specific embodiment and its various change form that the computer equipment of the present embodiment can be understood, so herein for the clothes
How business device realizes that the method in the embodiment of the present application is no longer discussed in detail.As long as those skilled in the art implement the application
Equipment used by method in embodiment belongs to the range to be protected of the application.
Based on the same inventive concept, this application provides the corresponding storage medium of embodiment one, detailed in Example four.
Example IV
The present embodiment provides a kind of computer readable storage mediums 400, as shown in figure 4, being stored thereon with computer program
411, which performs the steps of when being executed by processor
Obtain function information all in program module;
Hook is carried out using starting point of preset first Hook Function to each function, by preset first monitoring function note
Enter to the starting point of each function;
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring letter
Number is injected into the end point of each function;
When monitoring at the beginning of each function executes using the first monitoring function, each function is obtained
Corresponding first EMS memory occupation amount;
When monitoring the finish time that each function executes using the second monitoring function, obtain described each
The corresponding second EMS memory occupation amount of function;
Each letter is determined according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
Used EMS memory occupation amount, the EMS memory occupation amount are the second EMS memory occupation amount and described first to number in the process of implementation
The difference of EMS memory occupation amount.
In the specific implementation process, it when which is executed by processor, may be implemented any in embodiment one
Embodiment.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Although preferred embodiments of the present invention have been described, it is created once a person skilled in the art knows basic
Property concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted as
It selects embodiment and falls into all change and modification of the scope of the invention.
The foregoing is only a preferred embodiment of the present invention, is not intended to limit the scope of the present invention, it is all
Made any modifications, equivalent replacements, and improvements etc. within the spirit and principles in the present invention, should be included in protection of the invention
Within the scope of.
Claims (10)
1. a kind of method for obtaining EMS memory occupation amount, which is characterized in that the described method includes:
Obtain function information all in program module;
Hook is carried out using starting point of preset first Hook Function to each function, extremely by preset first monitoring function call injection
The starting point of each function;
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring function note
Enter to the end point of each function;
When monitoring at the beginning of each function executes using the first monitoring function, it is corresponding to obtain each function
The first EMS memory occupation amount;
When monitoring the finish time that each function executes using the second monitoring function, each function is obtained
Corresponding second EMS memory occupation amount;
Determine that each function exists according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
EMS memory occupation amount used in implementation procedure, the EMS memory occupation amount are the second EMS memory occupation amount and first memory
The difference of occupancy.
2. the method as described in claim 1, which is characterized in that in the acquisition program module after all function informations, packet
It includes:
Each function information is stored in the function chained list pre-established according to pre-set function structure;Wherein,
The corresponding function structure of each function, the function structure includes: the String name for recording function name,
For the first parameter string module of logging program module title, for recording the initial address of described program module
Second parameter DWORD dwbase, for recording third parameter of the function relative to the start offset amount of described program module
DWORD dwstart, for recording the 4th parameter DWORD dwsize of function memory itself, for recording the function
In the 5th parameter Long dwmemory for executing start time corresponding first EMS memory occupation amount.
3. the method as described in claim 1, which is characterized in that described to be risen using preset first Hook Function to each function
Initial point carries out hook, and the starting point by preset first monitoring function call injection to each function includes:
The initial address for obtaining the corresponding program module of each function one by one and each function are relative to corresponding program mould
The start offset amount of block;
Starting according to the initial address of corresponding program module and each function relative to the corresponding program module
Offset determines the starting memory address of each function;
The starting memory for monitoring function call injection to each function for pre-establish first using first Hook Function
At address, the current thread where each function is updated, completes the hook to each function starting point.
4. the method as described in claim 1, which is characterized in that it is described using preset second Hook Function to the knot of each function
Beam spot carries out hook, and the end point by preset second monitoring function call injection to each function includes:
The initial address of the corresponding program module of each function, the memory of each function itself and described each are obtained one by one
Start offset amount of the function relative to corresponding program module;
Start offset amount according to the memory of each function itself and each function relative to corresponding program module
Determine the end memory address of each function;
The end memory for monitoring function call injection to each function for pre-establish second using second Hook Function
At address, the current thread where each function is updated, completes the hook to each function end point.
5. method according to claim 2, which is characterized in that described to utilize preset second Hook Function to each function
End point carry out hook, by it is preset second monitoring function call injection to the end point of each function after, comprising:
Obtain the handle of the current process where each function;
When each function starts to execute, based on the handle of the current process, function is obtained using memory usage amount and obtains institute
State each function corresponding first EMS memory occupation amount at the beginning of execution;
Each first EMS memory occupation amount is assigned to the 5th parameter of respective function structure respectively.
6. method as claimed in claim 5, which is characterized in that described to monitor each letter using the first monitoring function
When at the beginning of number execution, the corresponding first EMS memory occupation amount of each function is obtained, comprising:
When being monitored at the beginning of each function executes using the first monitoring function, by the current of each function
Starting memory address is matched one by one with the starting memory address of all functions in the function chained list;
If when successful match, corresponding first EMS memory occupation of each function is obtained from the function structure of successful match
Amount.
7. the method as described in claim 1, which is characterized in that described described every when being monitored using the second monitoring function
When the finish time that a function executes, the corresponding second EMS memory occupation amount of each function is obtained, comprising:
Obtain the handle of the current process where each function;
When monitoring the finish time of objective function execution using the second monitoring function, the sentence based on the current process
Handle obtains each function using memory usage amount acquisition function and accounts in finish time corresponding second memory of execution
Dosage.
8. a kind of device for obtaining EMS memory occupation amount, which is characterized in that described device includes:
First acquisition unit, for obtaining function information all in program module;
Injection unit, for carrying out hook using starting point of preset first Hook Function to each function, by preset first
Monitor the starting point of function call injection to each function;
Hook is carried out using end point of preset second Hook Function to each function, by preset second monitoring function note
Enter to the end point of each function;
Second acquisition unit, for obtaining when being monitored at the beginning of each function executes using the first monitoring function
Take the corresponding first EMS memory occupation amount of each function;
Third acquiring unit, for when the finish time for monitoring each function execution using the second monitoring function
When, obtain the corresponding second EMS memory occupation amount of each function;
Determination unit, for determining institute according to the corresponding first EMS memory occupation amount and the corresponding second EMS memory occupation amount
State each function in the process of implementation used in EMS memory occupation amount, the EMS memory occupation amount be the second EMS memory occupation amount with
The difference of the first EMS memory occupation amount.
9. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is held by processor
Claim 1 to 7 described in any item methods are realized when row.
10. a kind of computer equipment including memory, processor and stores the meter that can be run on a memory and on a processor
Calculation machine program, which is characterized in that the processor realizes the described in any item methods of claim 1 to 7 when executing described program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910638175.8A CN110347407A (en) | 2019-07-16 | 2019-07-16 | A kind of method, apparatus, computer equipment and medium obtaining EMS memory occupation amount |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910638175.8A CN110347407A (en) | 2019-07-16 | 2019-07-16 | A kind of method, apparatus, computer equipment and medium obtaining EMS memory occupation amount |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110347407A true CN110347407A (en) | 2019-10-18 |
Family
ID=68175399
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910638175.8A Pending CN110347407A (en) | 2019-07-16 | 2019-07-16 | A kind of method, apparatus, computer equipment and medium obtaining EMS memory occupation amount |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110347407A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111104104A (en) * | 2019-11-04 | 2020-05-05 | 珠海亿智电子科技有限公司 | Method and device for visualizing function call time and statistical result and readable medium |
CN112579295A (en) * | 2020-12-25 | 2021-03-30 | 百果园技术(新加坡)有限公司 | Image memory analysis method and device, electronic equipment and storage medium |
CN112817838A (en) * | 2019-11-18 | 2021-05-18 | 迈普通信技术股份有限公司 | Memory leak information processing method and device, electronic equipment and storage medium |
CN113190235A (en) * | 2021-05-27 | 2021-07-30 | 武汉斗鱼鱼乐网络科技有限公司 | Code analysis method and device, electronic terminal and storage medium |
CN113821439A (en) * | 2021-09-23 | 2021-12-21 | 成都欧珀通信科技有限公司 | Method, device, storage medium and terminal for registering function to probe point |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1632761A (en) * | 2003-12-24 | 2005-06-29 | 华为技术有限公司 | Method for traversing and accessing object in tested application program |
CN105303114A (en) * | 2015-10-26 | 2016-02-03 | 浪潮电子信息产业股份有限公司 | Windows based system service function calling method and apparatus |
CN106909458A (en) * | 2015-12-23 | 2017-06-30 | 北京奇虎科技有限公司 | EMS memory management process and device |
CN107168857A (en) * | 2017-03-31 | 2017-09-15 | 武汉斗鱼网络科技有限公司 | The method and component of a kind of function call in statistics application program |
-
2019
- 2019-07-16 CN CN201910638175.8A patent/CN110347407A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1632761A (en) * | 2003-12-24 | 2005-06-29 | 华为技术有限公司 | Method for traversing and accessing object in tested application program |
CN105303114A (en) * | 2015-10-26 | 2016-02-03 | 浪潮电子信息产业股份有限公司 | Windows based system service function calling method and apparatus |
CN106909458A (en) * | 2015-12-23 | 2017-06-30 | 北京奇虎科技有限公司 | EMS memory management process and device |
CN107168857A (en) * | 2017-03-31 | 2017-09-15 | 武汉斗鱼网络科技有限公司 | The method and component of a kind of function call in statistics application program |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111104104A (en) * | 2019-11-04 | 2020-05-05 | 珠海亿智电子科技有限公司 | Method and device for visualizing function call time and statistical result and readable medium |
CN112817838A (en) * | 2019-11-18 | 2021-05-18 | 迈普通信技术股份有限公司 | Memory leak information processing method and device, electronic equipment and storage medium |
CN112579295A (en) * | 2020-12-25 | 2021-03-30 | 百果园技术(新加坡)有限公司 | Image memory analysis method and device, electronic equipment and storage medium |
CN113190235A (en) * | 2021-05-27 | 2021-07-30 | 武汉斗鱼鱼乐网络科技有限公司 | Code analysis method and device, electronic terminal and storage medium |
CN113190235B (en) * | 2021-05-27 | 2022-05-10 | 武汉斗鱼鱼乐网络科技有限公司 | Code analysis method and device, electronic terminal and storage medium |
CN113821439A (en) * | 2021-09-23 | 2021-12-21 | 成都欧珀通信科技有限公司 | Method, device, storage medium and terminal for registering function to probe point |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110347407A (en) | A kind of method, apparatus, computer equipment and medium obtaining EMS memory occupation amount | |
CN104699601B (en) | For the method and system for the injection for performing state machine driving | |
CN102360328B (en) | Programmed monitoring device and programmed monitoring method | |
CN106383764B (en) | A kind of collecting method and equipment | |
US20180246653A1 (en) | Capacity forecasting based on capacity policies and transactions | |
CN103838672A (en) | Automated testing method and device for all-purpose financial statements | |
CN104778124A (en) | Automatic testing method for software application | |
CN106293891B (en) | Multidimensional investment index monitoring method | |
CN104268291A (en) | Data consistency processing method and system | |
CN110378617A (en) | A kind of sample mask method, device, storage medium and equipment | |
CN109684332A (en) | A kind of wide table generating method of data, apparatus and system | |
CN107733710A (en) | Construction method, device, computer equipment and the storage medium of link call relation | |
CN110096420A (en) | A kind of data processing method, system and device | |
CN110991871A (en) | Risk monitoring method, device, equipment and computer readable storage medium | |
CN108427709B (en) | Multi-source mass data processing system and method | |
CN110275760A (en) | Process based on fictitious host computer processor hangs up method and its relevant device | |
CN111190814B (en) | Method and device for generating software test case, storage medium and terminal | |
CN110134646B (en) | Knowledge platform service data storage and integration method and system | |
CN107315652B (en) | Data backup method and cloud HDFS system | |
CN110322153A (en) | Monitor event processing method and system | |
WO2024032781A1 (en) | Algorithm testing method and apparatus, and storage medium | |
CN102546235A (en) | Performance diagnosis method and system of web-oriented application under cloud computing environment | |
CN106776275B (en) | A kind of testing process automatic generation method based on Packet Multiplexing | |
CN115668895A (en) | Resource configuration determining method and device of cloud service system | |
CN108334524A (en) | A kind of storm daily records error analysis methodology and device |
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: 20191018 |
|
RJ01 | Rejection of invention patent application after publication |