CN111209062A - Information acquisition method and device, electronic equipment and computer storage medium - Google Patents

Information acquisition method and device, electronic equipment and computer storage medium Download PDF

Info

Publication number
CN111209062A
CN111209062A CN202010030672.2A CN202010030672A CN111209062A CN 111209062 A CN111209062 A CN 111209062A CN 202010030672 A CN202010030672 A CN 202010030672A CN 111209062 A CN111209062 A CN 111209062A
Authority
CN
China
Prior art keywords
dynamic memory
information
dynamic
operation instruction
file
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.)
Granted
Application number
CN202010030672.2A
Other languages
Chinese (zh)
Other versions
CN111209062B (en
Inventor
关乃轩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010030672.2A priority Critical patent/CN111209062B/en
Publication of CN111209062A publication Critical patent/CN111209062A/en
Application granted granted Critical
Publication of CN111209062B publication Critical patent/CN111209062B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation 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/5016Allocation 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation 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/5022Mechanisms to release resources
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides an information acquisition method, an information acquisition device, electronic equipment and a computer storage medium. The information acquisition method comprises the following steps: intercepting the dynamic memory operation instruction through the first callable file, and converting the dynamic memory operation instruction into a dynamic memory calling function so as to execute the dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory calling function; and acquiring the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file. By the scheme provided by the embodiment, the information of the dynamic memory can be determined without modifying the source code, and the accuracy of the information of the dynamic memory can be improved.

Description

Information acquisition method and device, electronic equipment and computer storage medium
Technical Field
The embodiment of the application relates to the technical field of data processing, in particular to an information acquisition method and device, electronic equipment and a computer storage medium.
Background
In general, in order to determine the usage of the dynamic memory of the application program, the source code of the application program needs to be rewritten to call the memory allocation/release interface of the application program, and further, to acquire the usage information of the dynamic memory of the application program.
However, this approach requires modification of the application and would fail completely if there were no application source code. Even if the source code of the application program is rewritten, the method can increase the workload of the dynamic memory implementation of the application program and the complexity of the code implementation.
Therefore, what is needed in the art is to provide a flexible solution for implementing dynamic memory processing and information acquisition of an application program.
Disclosure of Invention
In view of the above, an embodiment of the present disclosure provides an information acquisition method, an information acquisition apparatus, an electronic device, and a computer storage medium, which overcome or alleviate some of the problems in the prior art.
The embodiment of the application provides an information acquisition method, which comprises the following steps: intercepting a dynamic memory operation instruction through a first callable file, and converting the dynamic memory operation instruction into a dynamic memory calling function so as to execute the dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory calling function; and acquiring the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file.
An embodiment of the present application provides an information acquisition apparatus, which includes: the intercepting module is used for intercepting a dynamic memory operation instruction through a first callable file and converting the dynamic memory operation instruction into a dynamic memory calling function so as to execute the dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory calling function; and the obtaining module is used for obtaining the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file.
An embodiment of the present application provides an electronic device, including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus; the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the information acquisition method.
An embodiment of the present application provides a computer storage medium, on which a computer program is stored, which when executed by a processor implements the information acquisition method as described above.
In the solution provided in this embodiment, a dynamic memory operation instruction is intercepted by a first callable file and is converted into a dynamic memory call function, so as to execute a dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory call function, so that the execution of the dynamic memory operation is implemented by a first callable file, and therefore, no source code needs to be modified, because the first callable file can be called by a process or another callable file corresponding to the process, a dynamic memory operation instruction of the process or another callable file corresponding to the process can be intercepted by the first callable file, and a dynamic memory operation indicated by the instruction is executed, and when information of the dynamic memory determined according to an operation result of the dynamic memory operation is obtained by the first callable file, the dynamic memory information can also be information of the dynamic memory corresponding to the process or another callable file corresponding to the process, the method is not limited by the process, and the accuracy of the information of the dynamic memory is improved.
Drawings
Some specific embodiments of the present application will be described in detail hereinafter by way of illustration and not limitation with reference to the accompanying drawings. The same reference numbers in the drawings identify the same or similar elements or components. Those skilled in the art will appreciate that the drawings are not necessarily drawn to scale. In the drawings:
fig. 1 is a schematic flowchart of an information acquisition method according to a first embodiment of the present application;
fig. 2a is a schematic flowchart of an information acquisition method in the second embodiment of the present application;
fig. 2b is a schematic flowchart illustrating a method for executing a dynamic memory operation according to a second embodiment of the present application;
fig. 2c is a schematic flowchart illustrating a method for obtaining a physical memory size according to a second embodiment of the present application;
fig. 3a is a schematic structural diagram of an operating system in the third embodiment of the present application;
fig. 3b is a schematic flow chart of an information acquisition method in the third embodiment of the present application;
fig. 3c is a schematic flow chart illustrating adding or deleting dynamic memory information according to a third embodiment of the present application;
fig. 3d is a schematic flow chart illustrating outputting of dynamic memory information according to a third embodiment of the present application;
fig. 4 is a schematic structural diagram of an information acquisition apparatus in a fourth embodiment of the present application;
fig. 5 is a schematic diagram of a hardware structure of some electronic devices that execute the information acquisition method according to the present application.
Detailed Description
It is not necessary for any particular embodiment of the invention to achieve all of the above advantages at the same time.
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application shall fall within the scope of the protection of the embodiments in the present application.
The following further describes specific implementations of embodiments of the present application with reference to the drawings of the embodiments of the present application.
Fig. 1 is a schematic flowchart of an information acquisition method according to a first embodiment of the present application; as shown in fig. 1, it comprises the following steps:
s102, intercepting a dynamic memory operation instruction through a first callable file, converting the dynamic memory operation instruction into a dynamic memory calling function, and executing the dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory calling function.
The dynamic memory is a dynamic memory allocated to a process by an operating system in which the process is located in the process running process. The process may specifically be an application running in an operating system. The dynamic memory operation instruction is used to instruct a process to perform an operation on the dynamic memory, and the dynamic memory operation instruction may include a dynamic memory allocation instruction, a dynamic memory release instruction, a dynamic memory query instruction, and the like, which is not limited in this embodiment. Correspondingly, the dynamic memory operation may include: the dynamic memory allocation operation performed by calling the dynamic memory allocation interface, the dynamic memory release operation performed by calling the dynamic memory release interface, and the like. The dynamic memory allocation interface is used for allocating dynamic memory, and the dynamic memory release interface is used for releasing the allocated dynamic memory.
In addition, the dynamic memory operation instruction may be generated by a process, or may be generated by another callable file corresponding to the process, which is not limited in this embodiment.
The callable file is a file that can be called by a process or an operating system, and the callable file includes, but is not limited to, various library files, such as a static library file, a dynamic library file, and the like. By means of the callable file, the callable file can be supplemented well when the caller does not have some functionality by himself. And the callable file can be called by different callers to help the callers to realize corresponding functions. Therefore, the realization cost of the caller is greatly reduced.
The callable file can include functions, data and data channels for realizing different functions, and the process can call the functions or use the data to realize the corresponding functions. Moreover, the callable file does not need to be added into the source code of the process, so that the callable file is more flexible and simpler to use.
Intercepting the dynamic memory operation instruction through the first callable file, and converting the intercepted dynamic memory operation instruction into a dynamic memory calling function in the first callable file, so that the dynamic memory operation is executed according to the dynamic memory calling function, the dynamic memory operation instruction is executed by the first callable file, and the first callable file obtains an execution result of the dynamic memory operation instruction.
Because the dynamic memory operation instruction is obtained by intercepting the first callable file, the dynamic memory operation instruction may not be an instruction that can be directly executed by the first callable file, and therefore, the dynamic memory operation instruction is converted into a corresponding dynamic memory call function in the first callable file, so that the first callable file can directly execute the dynamic memory operation according to the dynamic memory call function.
For example, if the dynamic memory operation indicated by the dynamic memory operation instruction may include a dynamic memory allocation operation or a dynamic memory release operation, and the interface called for executing the two operations is provided by the base library corresponding to the process, rather than the first callable file, the first callable file may not be able to directly execute the dynamic memory operation instruction after the dynamic memory operation instruction is intercepted. At this time, the dynamic memory call function in the first callable file may be obtained through conversion according to an interface called by the dynamic memory operation instruction (for example, an interface called by a dynamic memory allocation operation or a dynamic memory release operation), and the dynamic memory operation may be executed according to a corresponding interface in the dynamic memory call function call base.
In addition, in the embodiment, the source program of the process does not need to be modified when the first callable file is added, so that the determination of the dynamic memory information is more flexible and convenient.
And S104, acquiring the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file.
For example, the operation result of the dynamic memory operation may include a first result corresponding to the dynamic memory allocation operation and/or a second result corresponding to the dynamic memory release operation. After the first callable file executes the dynamic memory operation instruction, a corresponding first result and/or a second result can be obtained.
After the dynamic memory allocation operation is executed, a first result corresponding to the dynamic memory allocation operation may be determined, where the first result may include information such as the size and address of the dynamic memory allocated to execute the current operation; after the dynamic memory release operation is executed, a second result of the dynamic memory release operation may be determined, where the second result may include whether the dynamic memory release operation successfully releases the dynamic memory, and the like. It should be noted that, after the dynamic memory release operation is executed, data may not be returned, and at this time, the second result may be defaulted to be that the dynamic memory release is successful.
Of course, the first result and the second result are only exemplary and are not limited in the present application, and if other dynamic memory allocation operations are executed through the first callable file, corresponding operation results may also be obtained.
Because the dynamic memory operation instruction is executed through the first callable file, the first callable file can be randomly called by the process, or called by other callable files (e.g., static library file, dynamic library file, etc.) corresponding to the process except the basic library, and the basic library is used for being called to execute the dynamic memory operation without interception, the dynamic memory operation instruction intercepted through the first callable file is not limited to the process itself, but also includes other callable files corresponding to the process, and can acquire the corresponding operation result, so that the information of the dynamic memory determined by the scheme provided by the embodiment is more complete and accurate.
The information of the dynamic memory obtained through the first callable file may include information of the dynamic memory determined according to a first result or a second result, for example, the information of the dynamic memory determined according to the first result may be obtained through the first callable file after the first result is determined by performing a dynamic memory allocation operation once.
In addition, the information of the dynamic memory obtained through the first callable file may also include information of the dynamic memory comprehensively determined according to a plurality of first results and/or second results, for example, the information of the dynamic memory may be determined according to all the first results and/or second results within a period of time, which is not limited in this embodiment.
The information of the dynamic memory obtained through the first callable file may include information of the dynamic memory corresponding to each first result and/or each second result, or may include statistical information obtained after the first result and/or the second result is counted, for example, the statistical information may include information of sizes of all dynamic memories being occupied, and the embodiment does not limit this.
In the solution provided in this embodiment, a dynamic memory operation instruction is intercepted by a first callable file and is converted into a dynamic memory call function, so as to execute a dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory call function, so that the execution of the dynamic memory operation is implemented by a first callable file, and therefore, no source code needs to be modified, because the first callable file can be called by a process or another callable file corresponding to the process, a dynamic memory operation instruction of the process or another callable file corresponding to the process can be intercepted by the first callable file, and a dynamic memory operation indicated by the instruction is executed, and when information of the dynamic memory determined according to an operation result of the dynamic memory operation is obtained by the first callable file, the dynamic memory information can also be information of the dynamic memory corresponding to the process or another callable file corresponding to the process, the method is not limited by the process, and the accuracy of the information of the dynamic memory is improved.
The information acquisition method of the present embodiment may be executed by any suitable electronic device having data processing capabilities, including but not limited to: mobile terminals (such as tablet computers, mobile phones and the like), PCs, servers and the like.
Fig. 2a is a schematic flowchart of an information acquisition method in the second embodiment of the present application; in this embodiment, an application is taken as an example for explanation, and as shown in fig. 2a, the method includes the following steps:
and S202, carrying out real-time monitoring on the dynamic memory operation instruction of the application program.
The real-time monitoring of the dynamic memory operation instruction of the application program comprises not only the dynamic memory operation instruction generated by the application program itself, but also the dynamic memory operation instruction generated by other callable files called by the application program.
By monitoring the dynamic memory operation instruction of the application program in real time, the dynamic memory operation instruction can be processed in time, and delay is avoided.
The dynamic memory operation instruction may be executed by calling a corresponding basic library function in the basic library, and the dynamic memory operation instruction may include a dynamic memory allocation instruction, a dynamic memory release instruction, and the like, and the basic library functions called by different instructions are different, for example, the basic library function called by the dynamic memory allocation instruction may be a malloc function and a realloc function, and the basic library function called by the dynamic memory release instruction may be a free function, and in addition, the basic library function involved by the dynamic memory operation instruction may further include a calloc function, a realloc function, a memalign function, an aligned _ alloc function, a valloc function, a pvvalloc function, a posix _ memalign function, and the like.
Since the operation on the dynamic memory is still to be implemented by the basic library function of the system, in a feasible manner, the callable file loaded by the application program may be set by the environment variable, so that the application program loads the first callable file before loading the required basic library. Therefore, the dynamic memory operation can be realized through the first callable file, so that the high-efficiency realization of the dynamic memory operation can be realized, and the phenomenon that the application program or other callable files called by the application program cannot realize the dynamic memory operation when needed can be avoided.
Taking the Linux system as an example, if the basic library of the application App in the Linux system may be Libc, the callable file loaded by the application App may be adjusted through the LD _ PRELOAD environment variable, so that the application App loads the first callable file, which is Libhook in this example, before loading the required basic library Libc. The first callable file Libhook may include a DynMemHook function for monitoring a dynamic memory operation instruction of an application program calling a function in the basic library Libc in real time. The dynamic memory operation instruction monitored in real time can be generated by the application program App or Other callable files (Other libs) corresponding to the application program App, and the dynamic memory operation instruction can include a dynamic memory allocation instruction memory allocate or a dynamic memory release instruction memory free.
In addition, in order to perform real-time monitoring on the dynamic memory operation instruction through the first callable file, the DynMemHook function can be implemented through the hook function hook in the first callable file, so that the real-time monitoring is implemented through the DynMemHook function.
And S204, after the dynamic memory operation instruction is monitored, intercepting the dynamic memory operation instruction through a first callable file, converting the dynamic memory operation instruction into a dynamic memory calling function, and executing the dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory calling function.
The implementation manner of this step can refer to step S102 in the first embodiment, and this embodiment is not described herein again.
Further, as shown in fig. 2b, the intercepting a dynamic memory operation instruction through a first callable file, and converting the dynamic memory operation instruction into a dynamic memory call function, so as to execute a dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory call function, includes:
s2041, analyzing the intercepted dynamic memory operation instruction, and determining an interface name indicated by the dynamic memory operation instruction.
When the dynamic memory operation instruction is monitored in real time through the hook function hook, the interface name indicated by the dynamic memory operation instruction can be analyzed through the hook function hook, and the interface name can be, for example, an interface name corresponding to a malloc function, an interface name corresponding to a realloc function, an interface name corresponding to a free function, and the like.
S2042, generating a corresponding dynamic memory calling function in the first callable file according to the interface name.
After determining the interface name, the generated dynamic memory call function may be dlsym (RTLD _ NEXT, "xxfunc"), where "xxfunc" is determined according to the interface name. Of course, dlsym () is described here as an example, and is not intended to limit the present application, and other functions that can be used for lookup can be used in the present scheme as well.
S2043, calling a function through the dynamic memory, and searching a basic library function corresponding to the interface name in a basic library to execute the dynamic memory operation indicated by the dynamic memory operation instruction through the basic library function.
In this embodiment, after the dynamic memory call function dlsym (RTLD _ NEXT, "xxfunc") is generated, the base library function corresponding to the interface name "xxfunc" may be searched for in the base library through the dynamic memory call function dlsym, and the dynamic memory operation indicated by the dynamic memory operation instruction may be executed through the base library function, and a result of the dynamic memory operation may be returned through the dynamic memory call function.
For example, if the interface is called by the dynamic memory allocation function, the dynamic memory allocation function in the basic library may be called by the dynamic memory allocation function, the dynamic memory allocation operation is executed, and a first result corresponding to the dynamic memory allocation operation is obtained; if the function is called by the dynamic memory call function as a dynamic memory release interface, the dynamic memory release function in the basic library can be called by the dynamic memory allocation function, the dynamic memory release operation is executed, and a second result corresponding to the dynamic memory release operation is obtained.
For example, a dynamic memory allocation interface or a dynamic memory release interface provided by the base library Libc may be called through a dynamic memory call function in the first callable file Libhook, and after the interface in the base library Libc is called, a dynamic memory allocation operation or a dynamic memory release operation may be executed by the base library Libc, or a system call may be performed through the base library Libc, and a user state is converted into a kernel state, and then a system kernel Linux kernel allocates a dynamic memory or releases the dynamic memory through brk, mmap, and the like.
Of course, the above is only exemplified by the Linux system, and the solution provided in this embodiment can be used in other systems as well, which is not limited in this embodiment.
S206, obtaining the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file.
The operation result comprises: a first result corresponding to the dynamic memory allocation operation, and/or a second result corresponding to the dynamic memory release operation.
The information of the dynamic memory may be information of the dynamic memory determined according to one first result or one second result, or may be information of the dynamic memory determined according to a plurality of first results and/or second results.
When the information of the dynamic memory is determined according to a first result or a second result, the information of the dynamic memory may be information of the allocated dynamic memory after performing the dynamic memory allocation operation, or may be information of the dynamic memory released by performing the dynamic memory release operation. When the information of the dynamic memory is the dynamic memory information determined according to the plurality of first results and/or the second results, the plurality of first results and/or the second results may be processed again through the first callable file, and the obtained information of the dynamic memory may be the information of the dynamic memory occupied by the application program.
Optionally, step S206 may include: and acquiring the information of the dynamic memory, which is updated according to the operation result of the dynamic memory operation, from a dynamic memory information state interface in the first callable file through the first callable file.
Specifically, the information of the dynamic memory updated according to the operation result of the dynamic memory operation may be returned to the first callable file through the dynamic memory information status interface in the first callable file, so as to obtain the updated information of the dynamic memory through the first callable file.
When the information of the dynamic memory is the dynamic memory information corresponding to one of the first result and the second result, the information of the dynamic memory corresponding to the first result or the second result is directly stored through the dynamic memory information state interface in the first callable file to implement updating, and the updated information of the dynamic memory is returned to the first callable file, which is not described in detail in this embodiment.
When the information of the dynamic memory is the dynamic memory information corresponding to the plurality of first results and/or the plurality of second results, if the information of the dynamic memory only comprises the related information of the occupied dynamic memory, the information state interface of the dynamic memory can be called according to the first result to add the occupied dynamic memory to the information of the dynamic memory, and the information of the dynamic memory after the information state interface of the dynamic memory returns to be updated can be obtained; or calling the dynamic memory information state interface to delete the occupied dynamic memory in the information of the dynamic memory according to the second result, and obtaining the information of the dynamic memory returned by the dynamic memory information state interface after updating. In addition, the information of the dynamic memory may also include operation records corresponding to the first result and the second result determined each time, the operation records corresponding to the dynamic memory allocation operation may be added to the information of the dynamic memory by calling the dynamic memory information state interface according to the first result, and the information of the dynamic memory after the dynamic memory information state interface returns to update may be obtained; or calling the dynamic memory information state interface according to the second result to add the operation record corresponding to the dynamic memory release operation to the information of the dynamic memory, and obtaining the information of the dynamic memory, which is returned by the dynamic memory information state interface and updated, of the dynamic memory. Of course, the above is merely an exemplary illustration of the information of the dynamic memory, and is not a limitation of the present application.
Specifically, the first callable file may include a dynamic memory information status module DynMemStats and a dynamic memory information status interface corresponding to the dynamic memory information status module, where the DynMemStats module is configured to store information of the dynamic memory and may provide functions of searching, adding, and deleting the dynamic memory information through the dynamic memory information status interface, and after an operation result of the dynamic memory operation is determined, the first callable file may call the dynamic memory information status interface corresponding to the DynMemStats module therein to update information of the dynamic memory according to the operation result of the dynamic memory operation, and may return the updated information of the dynamic memory to the first callable file through the dynamic memory information status interface corresponding to the DynMemStats module.
Because the dynamic memory operation is executed through the first callable file, and the operation result of the dynamic memory operation can also be obtained through the first callable file, after the operation result of the dynamic memory operation is obtained, the dynamic memory information can be directly updated through the dynamic memory information state interface of the first callable file, so that the updating process is simpler and more convenient.
When the updated information of the dynamic memory is obtained, the updated information of the dynamic memory obtained from the dynamic memory information state interface may also be directly output through the dynamic memory output interface in the first callable file. Specifically, the updated information of the dynamic memory may be output by calling a dynamic memory information output interface (an interface corresponding to a dynamic memory output function dynmeshow) of the first callable file.
The information of the dynamic memory comprises an occupied address of the dynamic memory and the length of the dynamic memory.
Optionally, the information of the dynamic memory may further include at least one of the following information: index information (the index information is determined according to the address of the dynamic memory), the size of the occupied dynamic memory and the size of the physical memory corresponding to the occupied dynamic memory.
When the data included in the information of the dynamic memory is different, the output dynamic memory may also be different according to the different update operations, and the following takes the example that the information of the dynamic memory includes the related information of the occupied dynamic memory, and an update process is exemplarily described.
In this example, the information of the dynamic memory may specifically include an address of the occupied dynamic memory and a length of the dynamic memory. Therefore, the physical memory corresponding to the dynamic memory can be directly determined through the address of the dynamic memory, and the size of the dynamic memory occupied by the application program can be directly counted through the length of the occupied dynamic memory.
In addition, in order to conveniently search the information of the dynamic memory, the information of the dynamic memory further comprises index information, and the index information is determined according to the address of the dynamic memory, so that the dynamic memory can be accurately searched through the index information.
In addition, in order to more conveniently determine the information of the dynamic memory corresponding to the plurality of first results and/or the plurality of second results, the information of the dynamic memory can be updated according to the first results and the second results in a manner of maintaining a hash table of the dynamic memory through a dynamic memory information state interface provided by a dynamic memory information state module DynMemStats of the first callable file. In order to achieve more convenient storage, the dynamic memory hash table may be specifically a linked list.
For example, if the determined result is the first result corresponding to the dynamic memory allocation operation, the information of the newly allocated dynamic memory may be added to the dynamic memory hash table according to the first result, and the information of the newly allocated dynamic memory may include the address and the length of the newly allocated dynamic memory, and is stored in the dynamic memory hash table in the form of < addr, len >.
When the dynamic memory information state interface is called, specifically, the method for storing the newly allocated information of the dynamic memory in the dynamic memory hash table through the dynamic memory information state module dynmerstats may be as follows:
a) and generating index information hashkey according to the newly allocated address addr of the dynamic memory.
b) And finding a hash bucket for storing the dynamic memory information according to the index information hash key.
c) And adding the newly allocated address and length of the dynamic memory to the tail part of the linked list of the hash bucket determined in a mode of < addr, len >.
In addition, if the determined result is the second result, the information of the newly released dynamic memory may be deleted from the hash table of the dynamic memory according to the second result, and the information of the newly released dynamic memory may be determined according to the index information corresponding to the address of the dynamic memory.
Specifically, the method for deleting the newly released information of the dynamic memory from the hash table of the dynamic memory through the dynamic memory information state module DynMemStats may be as follows:
a) and generating index information hashkey according to the newly released address addr of the dynamic memory.
b) And finding a hash bucket for storing the dynamic memory information according to the index information hash key.
c) And searching a file in a form of < addr, len > corresponding to the newly released dynamic memory from the determined linked list of the hash bucket, and deleting the file.
Through the two modes, the newly allocated address and length of the dynamic memory can be accurately added into the information of the dynamic memory, and the released address and length of the dynamic memory can be accurately deleted from the information of the dynamic memory, so that the address of the dynamic memory included in the information of the dynamic memory corresponds to the dynamic memory occupied by the application program.
Taking the example that the information of the dynamic memory includes the related information of the dynamic memory being occupied, the following describes an exemplary process of obtaining the information of the dynamic memory through the first callable file.
In this example, the information of the dynamic memory obtained through the first callable file may further include information of an occupied dynamic memory, where the information of the occupied dynamic memory includes at least one of: the size of the occupied dynamic memory and the size of the physical memory corresponding to the occupied dynamic memory.
For the size of the occupied dynamic memory, when updating, it may update the information of the dynamic memory each time according to the first result or the second result. For example, the address and length of the newly allocated dynamic memory may be added to the dynamic memory hash table, or the address and length of the newly released dynamic memory may be deleted from the dynamic memory hash table, and then the new dynamic memory may be updated according to the length of the added or deleted dynamic memory.
During the acquisition, the dynamic memory information output function DynMemShow of the first callable file can be directly called by the application program to acquire the dynamic memory information.
The size of the physical memory corresponding to the occupied dynamic memory can be determined by the first callable file according to the information of the dynamic memory, and the application program can directly call the dynamic memory information output function DynMemShow of the first callable file to obtain the size.
For example, as shown in fig. 2c, the physical memory size corresponding to the occupied dynamic memory may be obtained and output by the following method:
s2061, determining the call execution indicating that the dynamic memory information output function DynMemShow outputs the dynamic memory information.
S2062, calling a dynamic memory information state interface corresponding to the dynamic memory information state module DynMemStats, traversing all the elements < addr and len > in the dynamic memory hash table, and for each element < addr and len > looking up the physical memory size occupied by the dynamic memory corresponding to the element < addr and len > through mincore system calling.
S2063, summing all the determined physical memory sizes, and determining the physical memory size corresponding to the dynamic memory occupied by the application program.
In the solution provided in this embodiment, the dynamic memory information determined by the first callable file may also be information of a dynamic memory corresponding to the application program or other callable files of the application program, and is not limited to the application program itself, so that accuracy of the information of the dynamic memory is improved, and a source code of the application program does not need to be modified, so that the callable file is more flexibly and easily used. Moreover, by the scheme provided by this embodiment, the address of the dynamic memory included in the information of the dynamic memory can be made to correspond to the dynamic memory occupied by the application program, the size of the dynamic memory occupied by the application program can be conveniently counted, the size of the physical memory corresponding to the dynamic memory occupied by the application program can be conveniently determined, and the counting result is more accurate.
The information acquisition method of the present embodiment may be executed by any suitable electronic device having data processing capabilities, including but not limited to: mobile terminals (such as tablet computers, mobile phones and the like), PCs, servers and the like.
Fig. 3a is a schematic structural diagram of an operating system in the third embodiment of the present application, and fig. 3a illustrates an example of Linux, where as shown in fig. 3a, the Linux system includes a system Kernel Linux Kernel, an application App to be run, a base library Libc corresponding to the application App, and Other callable files Other libs corresponding to the application App. And, a first callable file, Libhook.
When the first callable file Libhook is not used, as shown by a dotted line in the figure, the application App itself or Other callable files Other libs may call a dynamic memory allocation interface and a dynamic memory release interface in the base library Libc to perform allocation or release operation of the dynamic memory.
When the first invocation file Libhook is used, the DynMemHook function, the DynMemStats module, and the DynMemShow function are included in the first invocation program. The dynamhook function may be used to perform hook on a dynamic memory allocation interface and a dynamic memory release interface in the application program calling base library Libc to intercept, for example, as shown by a solid line in fig. 3a, an application program App and a dynamic memory allocation instruction memory allocate or a dynamic memory release instruction memory free generated by Other libs of Other callable files may be intercepted, and the intercepted instruction may be converted into a dynamic memory calling function, and Libc may be called according to the dynamic memory calling function to execute the dynamic memory allocation instruction memory allocate or the dynamic memory release instruction memory free; the dynamisstats module may be configured to store information of the dynamic memory, and provide a dynamic memory information state interface, for example, interfaces for searching, increasing, deleting, and the like of the dynamic memory, and specifically, the dynamisstats module may call an interface for increasing, deleting, and the like corresponding to the dynamisstats module according to a dynamic memory allocation instruction memory allocate or a dynamic memory release instruction memory free by using a dynamishook function, and maintain information of the dynamic memory, and since the dynamisstats module not only stores information of the dynamic memory but also provides interfaces for searching, increasing, deleting, and the like, the dynamisstats module is referred to as a module herein, but is not limited to this application; the dynamisshow function may call an interface provided by the dynamisstats module to determine and output information for the dynamic memory.
Referring to fig. 3b, a schematic flow chart of an information obtaining method is exemplarily shown, and in this embodiment, as shown in fig. 3b, the method includes:
s301, the application program generates a dynamic memory operation instruction for calling a dynamic memory allocation/release function.
S302, intercepting a dynamic memory operation instruction.
S303, calling a function through the dynamic memory, and searching a function pointer corresponding to the dynamic memory operation instruction in the basic library Libc to execute the dynamic memory operation according to the function pointer.
The basic library Libc can directly execute dynamic memory allocation operation or dynamic memory release operation, or system calling is carried out through the basic library Libc, a user mode is converted into a kernel mode, and then a system kernel Linux kernel allocates dynamic memory or releases the dynamic memory through brk, mmap and the like.
S304, judging whether the function called by the dynamic memory operation instruction is a memory allocation function.
If yes, step S305 is executed, otherwise, step S306 is executed.
S305, calling an interface corresponding to the DynMemStats module, such as DynMemAdd, and recording the address and length information of the allocated dynamic memory.
And ending the process.
S306, calling an interface corresponding to the DynMemStats module, such as DynMemDel, and deleting the address and length information of the released dynamic memory.
And ending the process.
The above steps S302-S306 may be implemented by DynMemHook function.
Specifically, after the interface corresponding to the DynMemStats module is called, the step S305 or S306 may be implemented by the method shown in fig. 3 c. The method specifically comprises the following steps:
s311, generating index information hashkey according to the address addr of the distributed or released dynamic memory.
S312, finding the hash bucket used for storing the dynamic memory information according to the index information hash key.
S313, judging whether to add the dynamic memory.
If yes, indicating that the address and length information of the allocated dynamic memory needs to be recorded, executing step S314; otherwise, it indicates that the address and length information of the released dynamic memory are deleted, and step S315 is executed.
S314, adding the address addr and the length len of the dynamic memory to the tail part of the linked list of the hash bucket in a form of < addr and len >.
And ending the process.
S315, finding < addr, len > in the hash bucket according to the address addr of the dynamic memory. Step S316 is then performed.
S316, deleting the found < addr, len > from the linked list of the hash bucket.
And ending the process.
The above steps S311-S316 may be implemented by a DynMemStats module.
When the information of the dynamic memory of the application program needs to be acquired, the information of the dynamic memory may be output by a dynamic memory output interface DynMemShow, which may specifically include:
s321, determining that an interface corresponding to the DynMemShow function is called, and indicating the sum of the sizes of the dynamic memories of the returned application programs.
And S322, calling a corresponding interface of the DynMemStats module, traversing the information of the dynamic memory, calling a mincore system call, and checking the size of the physical memory occupied by the dynamic memory.
And S323, outputting the sum of the physical memories occupied by the dynamic memory after traversing is finished.
The above steps S321 to S323 may be implemented by DynMemShow function.
According to the scheme provided by the embodiment, the determined dynamic memory information is not limited by the application program through a DynMemStats module, a DynMemShow function and the like in the first callable file Libhook, so that the accuracy of the information of the dynamic memory is improved, and the source code of the application program does not need to be modified, so that the callable file Libhook is more flexible and simpler to use.
Fig. 4 is a schematic structural diagram of an information acquisition apparatus in a fourth embodiment of the present application; as shown in fig. 4, it includes: an interception module 402 and an acquisition module 404.
The intercepting module 402 is configured to intercept a dynamic memory operation instruction through a first callable file, and convert the dynamic memory operation instruction into a dynamic memory call function, so as to execute a dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory call function.
An obtaining module 404, configured to obtain, through the first callable file, information of the dynamic memory determined according to the operation result of the dynamic memory operation.
Optionally, in any embodiment of the present application, the dynamic memory operation includes: calling a dynamic memory allocation interface to perform dynamic memory allocation operation, and/or calling a dynamic memory release interface to perform dynamic memory release operation; correspondingly, the operation result of the dynamic memory operation includes: a first result corresponding to the dynamic memory allocation operation, and/or a second result corresponding to the dynamic memory release operation.
Optionally, in any embodiment of the present application, the intercepting module 402 includes: the instruction analysis module is used for analyzing the intercepted dynamic memory operation instruction and determining an interface name indicated by the dynamic memory operation instruction; the function generation module is used for generating a corresponding dynamic memory calling function in the first calling file according to the interface name; and the function calling module is used for calling a function through the dynamic memory, searching a basic library function corresponding to the interface name in a basic library, and executing the dynamic memory operation indicated by the dynamic memory operation instruction through the basic library function.
Optionally, in any embodiment of the present application, the apparatus further includes: and the loading module is used for setting the callable file loaded by the application program through the environment variable, so that the first callable file is loaded before the basic library required by the application program is loaded.
Optionally, in any embodiment of the present application, the intercepting module 402 is specifically configured to: and returning the information of the dynamic memory updated according to the operation result of the dynamic memory operation to the first callable file through a dynamic memory information state interface in the first callable file.
Optionally, in any embodiment of the present application, the information of the dynamic memory includes an address of the occupied dynamic memory and a length of the dynamic memory.
Optionally, in any embodiment of the present application, the information of the dynamic memory further includes index information, and the index information is determined according to an address of the dynamic memory.
Optionally, in any embodiment of the present application, the information of the dynamic memory further includes at least one of the following: the size of the occupied dynamic memory and the size of the physical memory corresponding to the occupied dynamic memory.
Optionally, in any embodiment of the present application, the obtaining module 404 is specifically configured to: and outputting the information of the dynamic memory acquired from the dynamic memory information state interface through a dynamic memory output interface in the first callable file.
In the scheme provided in this embodiment, a dynamic memory operation instruction is intercepted by a first callable file and is converted into a dynamic memory call function, so as to execute a dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory call function, so that the execution of the dynamic memory operation is implemented by a first callable file, and therefore, a source code of a process does not need to be modified, and because the first callable file can be called by the process or another callable file corresponding to the process, a dynamic memory operation instruction of the process or another callable file corresponding to the process can be intercepted by the first callable file, and a dynamic memory operation indicated by the instruction is executed, where the dynamic memory operation includes: when the dynamic memory allocation operation is called by the dynamic memory allocation interface and/or the dynamic memory release operation is called by the dynamic memory release interface, and then the information of the dynamic memory determined according to the operation result of the dynamic memory operation is acquired through the first callable file, the dynamic memory information can also be the information of the dynamic memory corresponding to a process or other callable files corresponding to the process, and is not limited by the process, so that the accuracy of the information of the dynamic memory is improved.
Fig. 5 is a schematic diagram of a hardware structure of some electronic devices that execute the information acquisition method according to the present application.
According to fig. 5, the apparatus comprises:
one or more processors 502 and a memory 504, with one processor 502 being an example in FIG. 5.
The apparatus for performing the information acquisition method may further include: a Communications Interface 506, and a Communications bus 508.
A communication interface 506 for communicating with other electronic devices or servers.
The processor 502, memory 504, and communication interface 506 may communicate with each other via a communication bus 508.
The memory 504, which is a non-volatile computer-readable storage medium, may be used to store at least one executable instruction, where the executable instruction may specifically include the program 510, and the program 510 may specifically include a non-volatile software program, a non-volatile computer-executable program, and a module, such as a program instruction/module corresponding to the information acquisition method in the embodiment of the present application. The processor 502 implements the information acquisition method in the above-described method embodiment by executing the program 510 stored in the memory 504.
The memory 504 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the stored data area may store data created according to use of the information acquisition apparatus, and the like. Further, the memory 504 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 504 optionally includes memory located remotely from the processor, which may be connected to the information acquisition device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory and, when executed by the one or more processors, perform the information acquisition method of any of the method embodiments described above.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in the embodiments of the present application.
The electronic device of the embodiments of the present application exists in various forms, including but not limited to:
(1) a mobile communication device: such devices are characterized by mobile communications capabilities and are primarily targeted at providing voice, data communications. Such terminals include: smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer device: the equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include: PDA, MID, and UMPC devices, etc., such as ipads.
(3) A portable entertainment device: such devices can display and play multimedia content. This type of device comprises: audio, video players (e.g., ipods), handheld game consoles, electronic books, and smart toys and portable car navigation devices.
(4) A server: the device for providing the computing service comprises a processor, a hard disk, a memory, a system bus and the like, and the server is similar to a general computer architecture, but has higher requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like because of the need of providing high-reliability service.
(5) And other electronic devices with data interaction functions.
Thus, particular embodiments of the present subject matter have been described. Other embodiments are within the scope of the following claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may be advantageous.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), HDCal, JHDL (Java Hardware Description Language), langue, Lola, HDL, laspam, hardsradware (Hardware Description Language), vhjhd (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular transactions or implement particular abstract data types. The application may also be practiced in distributed computing environments where transactions are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (12)

1. An information acquisition method, comprising:
intercepting a dynamic memory operation instruction through a first callable file, and converting the dynamic memory operation instruction into a dynamic memory calling function so as to execute the dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory calling function;
and acquiring the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file.
2. The method of claim 1, wherein the dynamic memory operation comprises: calling a dynamic memory allocation interface to perform dynamic memory allocation operation, and/or calling a dynamic memory release interface to perform dynamic memory release operation; correspondingly, the operation result of the dynamic memory operation includes: a first result corresponding to the dynamic memory allocation operation, and/or a second result corresponding to the dynamic memory release operation.
3. The method of claim 1, wherein intercepting a dynamic memory operation instruction through a first callable file and converting the dynamic memory operation instruction into a dynamic memory call function, so as to execute a dynamic memory operation indicated by the dynamic memory operation instruction according to the dynamic memory call function, comprises:
analyzing the intercepted dynamic memory operation instruction, and determining an interface name indicated by the dynamic memory operation instruction;
generating a corresponding dynamic memory calling function in the first calling file according to the interface name;
and searching a basic library function corresponding to the interface name in a basic library through the dynamic memory call function so as to execute the dynamic memory operation indicated by the dynamic memory operation instruction through the basic library function.
4. The method of claim 1, wherein the method further comprises:
and setting the callable file loaded by the application program through the environment variable, so that the first callable file is loaded by the application program before the required basic library is loaded.
5. The method according to claim 1, wherein the obtaining, through the first callable file, information of the dynamic memory determined according to the operation result corresponding to the dynamic memory operation includes:
and acquiring the information of the dynamic memory, which is updated according to the operation result of the dynamic memory operation, from a dynamic memory information state interface in the first callable file through the first callable file.
6. The method of claim 5, wherein the information of the dynamic memory comprises an address of the occupied dynamic memory and a length of the dynamic memory.
7. The method according to claim 6, wherein the information of the dynamic memory further comprises index information, and the index information is determined according to an address of the dynamic memory.
8. The method of claim 6, wherein the information of the dynamic memory further comprises at least one of:
the size of the occupied dynamic memory and the size of the physical memory corresponding to the occupied dynamic memory.
9. The method according to any one of claims 5-8, wherein the method further comprises:
and outputting the information of the dynamic memory acquired from the dynamic memory information state interface through a dynamic memory output interface in the first callable file.
10. An information acquisition apparatus comprising:
the intercepting module is used for intercepting a dynamic memory operation instruction through a first callable file and converting the dynamic memory operation instruction into a dynamic memory calling function so as to execute the dynamic memory operation indicated by the dynamic memory operation instruction through the dynamic memory calling function;
and the obtaining module is used for obtaining the information of the dynamic memory determined according to the operation result of the dynamic memory operation through the first callable file.
11. An electronic device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the information acquisition method according to any one of claims 1-9.
12. A computer storage medium on which a computer program is stored, which program, when executed by a processor, implements the information acquisition method according to any one of claims 1 to 9.
CN202010030672.2A 2020-01-11 2020-01-11 Information acquisition method, information acquisition device, electronic equipment and computer storage medium Active CN111209062B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010030672.2A CN111209062B (en) 2020-01-11 2020-01-11 Information acquisition method, information acquisition device, electronic equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010030672.2A CN111209062B (en) 2020-01-11 2020-01-11 Information acquisition method, information acquisition device, electronic equipment and computer storage medium

Publications (2)

Publication Number Publication Date
CN111209062A true CN111209062A (en) 2020-05-29
CN111209062B CN111209062B (en) 2023-04-25

Family

ID=70784254

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010030672.2A Active CN111209062B (en) 2020-01-11 2020-01-11 Information acquisition method, information acquisition device, electronic equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN111209062B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860309A (en) * 2021-01-29 2021-05-28 深圳市趣推科技有限公司 Static library calling method, device, equipment and storage medium based on iOS

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013182006A1 (en) * 2012-06-07 2013-12-12 北京奇虎科技有限公司 Method and device for use in intercepting call for service by application
CN106933733A (en) * 2015-12-30 2017-07-07 华为技术有限公司 A kind of method and apparatus for determining RAM leakage position
WO2017177690A1 (en) * 2016-04-12 2017-10-19 上海斐讯数据通信技术有限公司 Method and system for transferring memory size parameter to linux kernel
CN110659194A (en) * 2018-06-28 2020-01-07 中兴通讯股份有限公司 Dynamic memory detection method, device and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013182006A1 (en) * 2012-06-07 2013-12-12 北京奇虎科技有限公司 Method and device for use in intercepting call for service by application
CN106933733A (en) * 2015-12-30 2017-07-07 华为技术有限公司 A kind of method and apparatus for determining RAM leakage position
WO2017177690A1 (en) * 2016-04-12 2017-10-19 上海斐讯数据通信技术有限公司 Method and system for transferring memory size parameter to linux kernel
CN110659194A (en) * 2018-06-28 2020-01-07 中兴通讯股份有限公司 Dynamic memory detection method, device and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JOHANNES STÜTTGEN等: ""Robust Linux memory acquisition with minimal target impact"" *
汪小林等: ""利用虚拟化平台进行内存泄露探测"" *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860309A (en) * 2021-01-29 2021-05-28 深圳市趣推科技有限公司 Static library calling method, device, equipment and storage medium based on iOS
CN112860309B (en) * 2021-01-29 2024-04-16 深圳市趣推科技有限公司 Static library calling method, device, equipment and storage medium based on iOS

Also Published As

Publication number Publication date
CN111209062B (en) 2023-04-25

Similar Documents

Publication Publication Date Title
US9575864B2 (en) Function-level dynamic instrumentation
CN108173706B (en) Service marking method, device and equipment under multi-service system
CN108628688B (en) Message processing method, device and equipment
CN107577697B (en) Data processing method, device and equipment
CN111241040B (en) Information acquisition method and device, electronic equipment and computer storage medium
CN116305298B (en) Method and device for managing computing power resources, storage medium and electronic equipment
KR20220125198A (en) Data additional writing method, apparatus, electronic device, storage medium and computer programs
CN112181663A (en) Memory scheduling method and device and computer equipment
Courville et al. Understanding storage I/O behaviors of mobile applications
CN110955720A (en) Data loading method, device and system
CN115114071A (en) Memory analysis method, device, equipment and medium
CN109033456B (en) Condition query method and device, electronic equipment and storage medium
CN110888972A (en) Sensitive content identification method and device based on Spark Streaming
CN106156050B (en) Data processing method and device
CN111209062B (en) Information acquisition method, information acquisition device, electronic equipment and computer storage medium
US20120124429A1 (en) Apparatus and method for tracing memory access information
CN113326288A (en) Data processing method and device and electronic equipment
CN112559642A (en) Data classification storage method and device and related products
CN109409037B (en) Method, device and equipment for generating data confusion rule
CN111444117A (en) Method and device for realizing fragmentation of storage space, storage medium and electronic equipment
CN115599588A (en) Method and device for acquiring memory use information, storage medium and electronic device
CN114691496A (en) Unit testing method, unit testing device, computing equipment and medium
CN114416402A (en) Information transmission method, terminal device and storage medium
CN114296986A (en) Memory leak positioning method, device, medium and electronic equipment
CN112306683A (en) Function hijacking method, device, medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40030613

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant