CN111858258A - A memory monitoring method, device, electronic device and storage medium - Google Patents
A memory monitoring method, device, electronic device and storage medium Download PDFInfo
- Publication number
- CN111858258A CN111858258A CN202010745263.0A CN202010745263A CN111858258A CN 111858258 A CN111858258 A CN 111858258A CN 202010745263 A CN202010745263 A CN 202010745263A CN 111858258 A CN111858258 A CN 111858258A
- Authority
- CN
- China
- Prior art keywords
- memory
- application
- data type
- target
- monitoring method
- 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.)
- Withdrawn
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/3034—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a storage system, e.g. DASD based or network based
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- Quality & Reliability (AREA)
- Debugging And Monitoring (AREA)
Abstract
本申请公开了一种内存监控方法、装置及一种电子设备和计算机可读存储介质,该方法包括:当接收到目标数据的内存申请时,识别所述目标数据的数据类型;调用内存申请接口为所述目标数据分配内存,并返回内存分配结果,以便响应所述内存申请;根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,并更新所有已分配内存的总量。本申请提供的内存监控方法,通过拦截内存分配,按数据类型分类统计申请内存大小和所有已分配内存的总量,实现进程内存占用动态跟踪,为内存优化提供参考,提升内存健壮性和稳定性。由此可见,本申请提供的内存监控方法,按数据类型进行内存占用统计,实现了进程内存占用动态跟踪。
The present application discloses a memory monitoring method, device, electronic device and computer-readable storage medium, the method comprising: when receiving a memory application for target data, identifying the data type of the target data; calling a memory application interface to allocate memory for the target data, and returning a memory allocation result to respond to the memory application; updating the requested memory size corresponding to the data type according to the requested memory amount corresponding to the memory application, and updating the total amount of all allocated memory. The memory monitoring method provided in the present application intercepts memory allocation, and counts the requested memory size and the total amount of all allocated memory by data type, so as to achieve dynamic tracking of process memory occupancy, provide a reference for memory optimization, and improve memory robustness and stability. It can be seen that the memory monitoring method provided in the present application performs memory occupancy statistics by data type, so as to achieve dynamic tracking of process memory occupancy.
Description
技术领域technical field
本申请涉及计算机技术领域,更具体地说,涉及一种内存监控方法、装置及一种电子设备和一种计算机可读存储介质。The present application relates to the field of computer technology, and more particularly, to a memory monitoring method and apparatus, an electronic device, and a computer-readable storage medium.
背景技术Background technique
在大数据时代,为实现内存监控功能,在相关技术中修改源码,调用内存监控工具提供的接口以实现内存监控,通过特定工具进行内存占用展示。但上述方案智能提供内存占用总量,无法精细到每种数据类型的内存占用,无法精确进行内存优化,内存占用过高严重影响进程的稳定性和健壮性。In the era of big data, in order to realize the memory monitoring function, the source code is modified in the related technology, the interface provided by the memory monitoring tool is called to realize the memory monitoring, and the memory occupancy display is performed through a specific tool. However, the above solutions intelligently provide the total memory usage, which cannot be refined to the memory usage of each data type, and cannot be precisely optimized for memory. Excessive memory usage will seriously affect the stability and robustness of the process.
因此,如何按数据类型进行内存占用统计,实现进程内存占用动态跟踪是本领域技术人员需要解决的技术问题。Therefore, how to perform memory occupancy statistics by data type and realize dynamic tracking of process memory occupancy is a technical problem to be solved by those skilled in the art.
发明内容SUMMARY OF THE INVENTION
本申请的目的在于提供一种内存监控方法、装置及一种电子设备和一种计算机可读存储介质,按数据类型进行内存占用统计,实现了进程内存占用动态跟踪。The purpose of the present application is to provide a memory monitoring method and device, an electronic device and a computer-readable storage medium, which can perform memory occupancy statistics by data type, and realize dynamic tracking of process memory occupancy.
为实现上述目的,本申请提供了一种内存监控方法,包括:To achieve the above purpose, the present application provides a memory monitoring method, including:
当接收到目标数据的内存申请时,识别所述目标数据的数据类型;When receiving a memory application for target data, identifying the data type of the target data;
调用内存申请接口为所述目标数据分配内存,并返回内存分配结果,以便响应所述内存申请;Call the memory application interface to allocate memory for the target data, and return the memory allocation result, so as to respond to the memory application;
根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,并更新所有已分配内存的总量。The requested memory size corresponding to the data type is updated according to the requested memory amount corresponding to the memory request, and the total amount of all allocated memory is updated.
其中,所述根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,包括:Wherein, the updating of the application memory size corresponding to the data type according to the application memory amount corresponding to the memory application includes:
判断目标存储结构中是否存在所述数据类型;Determine whether the data type exists in the target storage structure;
若是,则根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小;If so, update the requested memory size corresponding to the data type according to the requested memory amount corresponding to the memory request;
若否,则将所述数据类型存储至所述目标存储结构中,并根据所述内存申请对应的申请内存量统计所述数据类型对应的申请内存大小。If not, the data type is stored in the target storage structure, and the application memory size corresponding to the data type is counted according to the application memory amount corresponding to the memory application.
其中,所述目标存储结构为Map结构。Wherein, the target storage structure is a Map structure.
其中,所述返回内存分配结果,包括:Wherein, the returned memory allocation result includes:
若申请成功,则返回所述目标数据对应的内存。If the application is successful, the memory corresponding to the target data is returned.
其中,所述返回内存分配结果,包括:Wherein, the returned memory allocation result includes:
若申请失败,则返回错误类型对应的错误码。If the application fails, the error code corresponding to the error type is returned.
其中,还包括:Among them, it also includes:
当接收到内存统计信息的打印命令时,分别输出每个所述数据类型对应的申请内存大小和所有已分配内存的总量。When receiving the print command of the memory statistics, output the size of the requested memory and the total amount of all allocated memory corresponding to each of the data types.
其中,还包括:Among them, it also includes:
当检测到目标内存的释放动作后,确定所述目标内存存储数据的目标数据类型;After detecting the release action of the target memory, determine the target data type of the data stored in the target memory;
根据所述目标内存的大小更新所述目标数据类型对应的申请内存大小和所有已分配内存的总量。The size of the requested memory corresponding to the target data type and the total amount of all allocated memory are updated according to the size of the target memory.
为实现上述目的,本申请提供了一种内存监控装置,包括:To achieve the above purpose, the present application provides a memory monitoring device, including:
识别模块,用于当接收到目标数据的内存申请时,识别所述目标数据的数据类型;an identification module, configured to identify the data type of the target data when receiving the memory application of the target data;
分配模块,用于调用内存申请接口为所述目标数据分配内存,并返回内存分配结果,以便响应所述内存申请;an allocation module, configured to call a memory application interface to allocate memory for the target data, and return a memory allocation result so as to respond to the memory application;
第一更新模块,用于根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,并更新所有已分配内存的总量。The first update module is configured to update the requested memory size corresponding to the data type according to the requested memory amount corresponding to the memory application, and update the total amount of all allocated memory.
为实现上述目的,本申请提供了一种电子设备,包括:To achieve the above purpose, the present application provides an electronic device, including:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现如上述内存监控方法的步骤。The processor is configured to implement the steps of the above-mentioned memory monitoring method when executing the computer program.
为实现上述目的,本申请提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述内存监控方法的步骤。To achieve the above object, the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned memory monitoring method are implemented.
通过以上方案可知,本申请提供的一种内存监控方法,包括:当接收到目标数据的内存申请时,识别所述目标数据的数据类型;调用内存申请接口为所述目标数据分配内存,并返回内存分配结果,以便响应所述内存申请;根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,并更新所有已分配内存的总量。It can be seen from the above solutions that a memory monitoring method provided by the present application includes: when a memory application for target data is received, identifying the data type of the target data; calling a memory application interface to allocate memory for the target data, and returning memory allocation result in order to respond to the memory application; update the application memory size corresponding to the data type according to the application memory amount corresponding to the memory application, and update the total amount of all allocated memory.
本申请提供的内存监控方法,通过拦截内存分配,按数据类型分类统计申请内存大小和所有已分配内存的总量,实现进程内存占用动态跟踪,为内存优化提供参考,提升内存健壮性和稳定性。由此可见,本申请提供的内存监控方法,按数据类型进行内存占用统计,实现了进程内存占用动态跟踪。本申请还公开了一种内存监控装置及一种电子设备和一种计算机可读存储介质,同样能实现上述技术效果。The memory monitoring method provided by this application, by intercepting memory allocation, and classifying the application memory size and the total amount of all allocated memory by data type, realizes dynamic tracking of process memory usage, provides a reference for memory optimization, and improves memory robustness and stability. . It can be seen that, the memory monitoring method provided by the present application performs memory occupancy statistics according to data types, and realizes dynamic tracking of process memory occupancy. The present application also discloses a memory monitoring device, an electronic device, and a computer-readable storage medium, which can also achieve the above technical effects.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性的,并不能限制本申请。It is to be understood that the foregoing general description and the following detailed description are exemplary only and do not limit the application.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。附图是用来提供对本公开的进一步理解,并且构成说明书的一部分,与下面的具体实施方式一起用于解释本公开,但并不构成对本公开的限制。在附图中:In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort. The accompanying drawings are used to provide a further understanding of the present disclosure, and constitute a part of the specification, and together with the following detailed description, are used to explain the present disclosure, but not to limit the present disclosure. In the attached image:
图1为根据一示例性实施例示出的一种内存监控方法的流程图;1 is a flowchart of a memory monitoring method according to an exemplary embodiment;
图2为根据一示例性实施例示出的一种内存监控装置的结构图;FIG. 2 is a structural diagram of a memory monitoring device according to an exemplary embodiment;
图3为根据一示例性实施例示出的一种电子设备的结构图。FIG. 3 is a structural diagram of an electronic device according to an exemplary embodiment.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
本申请实施例公开了一种内存监控方法,按数据类型进行内存占用统计,实现了进程内存占用动态跟踪。The embodiment of the present application discloses a memory monitoring method, which performs memory occupancy statistics according to data types, and realizes dynamic tracking of process memory occupancy.
参见图1,根据一示例性实施例示出的一种内存监控方法的流程图,如图1所示,包括:Referring to FIG. 1, a flowchart of a memory monitoring method according to an exemplary embodiment, as shown in FIG. 1, includes:
S101:当接收到目标数据的内存申请时,识别所述目标数据的数据类型;S101: when a memory application for target data is received, identify the data type of the target data;
在本实施例中,可以重载内存分配函数,重命名数据类型,此处的数据类型可以包括byte、short、int、long、float、double、boolean、char等,在此不进行具体限定。在具体实施中,可以通过C++语言实现重载内存分配函数和重命名数据类型,当然也可以采用其他语言,本实施例不进行具体限定。In this embodiment, the memory allocation function can be overloaded, and the data type can be renamed. The data type here can include byte, short, int, long, float, double, boolean, char, etc., which is not specifically limited here. In a specific implementation, the overloaded memory allocation function and the renaming of data types can be implemented by using the C++ language. Of course, other languages can also be used, which are not specifically limited in this embodiment.
在本步骤中,客户端程序申请内存时,调用重载的内存分配函数,通过类型解析接口,解析出申请内存的数据类型。In this step, when the client program applies for memory, it calls the overloaded memory allocation function, and parses out the data type of the requested memory through the type analysis interface.
S102:调用内存申请接口为所述目标数据分配内存,并返回内存分配结果,以便响应所述内存申请;S102: Invoke a memory application interface to allocate memory for the target data, and return a memory allocation result, so as to respond to the memory application;
在本步骤中,调用系统提供的内存申请接口进行内存申请并将内存分配结果返回至客户端程序。具体的,若申请成功,则返回所述目标数据对应的内存,若申请失败,则返回错误类型对应的错误码,以便客户端程序进行相应的处理,重新申请或报错。In this step, the memory application interface provided by the system is called to perform memory application and the memory allocation result is returned to the client program. Specifically, if the application is successful, the memory corresponding to the target data is returned, and if the application fails, the error code corresponding to the error type is returned, so that the client program can perform corresponding processing, re-apply or report an error.
S103:根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,并更新所有已分配内存的总量。S103: Update the requested memory size corresponding to the data type according to the requested memory amount corresponding to the memory request, and update the total amount of all allocated memory.
在本步骤中,按数据类型统计内存申请大小,存入目标存储结构中,并累加到已分配内存的总量中,此处的目标存储结构可以为Map结构,即Alloc_Map。当接收到内存统计信息的打印命令时,分别输出每个数据类型对应的申请内存大小和所有已分配内存的总量。In this step, the memory application size is counted according to the data type, stored in the target storage structure, and added to the total amount of allocated memory. The target storage structure here may be a Map structure, namely Alloc_Map. When receiving the print command of memory statistics, output the requested memory size corresponding to each data type and the total amount of all allocated memory.
作为一种可行的实施方式,所述根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小的步骤可以包括:判断目标存储结构中是否存在所述数据类型;若是,则根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小;若否,则将所述数据类型存储至所述目标存储结构中,并根据所述内存申请对应的申请内存量统计所述数据类型对应的申请内存大小。在具体实施中,若首次为某一数据类型的数据申请内存,则将该数据类型存储值目标存储结构中,并统计本次申请的内存大小,下一次为该数据类型的数据申请内存时,进行累加即可。As a feasible implementation manner, the step of updating the application memory size corresponding to the data type according to the application memory amount corresponding to the memory application may include: judging whether the data type exists in the target storage structure; if so, then Update the application memory size corresponding to the data type according to the application memory amount corresponding to the memory application; if not, store the data type in the target storage structure, and store the data type in the target storage structure according to the application memory amount corresponding to the memory application Statistics of the requested memory size corresponding to the data type. In the specific implementation, if memory is applied for data of a certain data type for the first time, the data type is stored in the value target storage structure, and the memory size of this application is counted, and the next time memory is applied for data of this data type, It can be accumulated.
作为一种优选实施方式,本实施例还包括:当检测到目标内存的释放动作后,确定所述目标内存存储数据的目标数据类型;根据所述目标内存的大小更新所述目标数据类型对应的申请内存大小和所有已分配内存的总量。As a preferred implementation manner, this embodiment further includes: after detecting the release action of the target memory, determining the target data type of the data stored in the target memory; updating the corresponding data type of the target memory according to the size of the target memory The requested memory size and the total amount of all allocated memory.
在具体实施中,当程序已申请的内存使用完成后进行释放时,解析出数据类型,在目标存储结构中查找该数据类型对应的申请内存大小,从该数据类型的申请内存大小中减去释放的内存量,从已分配内存的总量减去释放的内存,并调用内存释放函数进行内存释放,实现动态监控内存占用情况,为程序优化提供参考。In the specific implementation, when the memory that has been applied for by the program is released after use, the data type is parsed, the size of the application memory corresponding to the data type is searched in the target storage structure, and the release is subtracted from the size of the application memory of the data type. The amount of memory that has been allocated is subtracted from the total amount of allocated memory, and the memory release function is called to release the memory to dynamically monitor the memory occupancy and provide a reference for program optimization.
本申请实施例提供的内存监控方法,通过拦截内存分配,按数据类型分类统计申请内存大小和所有已分配内存的总量,实现进程内存占用动态跟踪,为内存优化提供参考,提升内存健壮性和稳定性。由此可见,本申请实施例提供的内存监控方法,按数据类型进行内存占用统计,实现了进程内存占用动态跟踪。The memory monitoring method provided by the embodiments of the present application implements dynamic tracking of process memory occupation by intercepting memory allocation, classifying and classifying the size of application memory and the total amount of all allocated memory by data type, providing a reference for memory optimization, and improving memory robustness and performance. stability. It can be seen that, in the memory monitoring method provided by the embodiments of the present application, memory occupancy statistics are performed according to data types, and dynamic tracking of process memory occupancy is realized.
下面介绍本申请提供的一种应用实施例,具体的,客户端程序实现时主要包括以下几个步骤:An application embodiment provided by the present application is described below. Specifically, the implementation of the client program mainly includes the following steps:
步骤1:运行分布式系统和客户端程序;Step 1: Run the distributed system and client program;
步骤2:程序申请内存存储数据时或数据结构初始化时,等待C++内存分配接口返回结果;若内存分配成功,使用内存存取数据;若分配失败,则将返回结果返回给客户端并按返回值进行相应处理;Step 2: When the program applies for memory to store data or initializes the data structure, wait for the C++ memory allocation interface to return the result; if the memory allocation is successful, use the memory to access the data; if the allocation fails, return the returned result to the client and press the return value deal with accordingly;
步骤3:数据不再使用时或要析构释放内存时,调用接口释放内存或调用数据结构自定义接口释放内存;Step 3: When the data is no longer used or when the memory is to be destructed to release the memory, call the interface to release the memory or call the data structure custom interface to release the memory;
步骤4:内存释放完成后,程序持续运行;Step 4: After the memory release is completed, the program continues to run;
步骤5:执行特定命令查看各类型的内存占用情况。Step 5: Execute a specific command to view the memory usage of each type.
内存分配模块处理程序主要包括以下步骤:The memory allocation module handler mainly includes the following steps:
步骤1:重载C++内存分配函数,并重命名数据类型;Step 1: Overload the C++ memory allocation function and rename the data type;
步骤2:收到程序申请内存的动作后,解析数据类型;Step 2: After receiving the action of the program requesting memory, parse the data type;
步骤3:按类型存入到结构Alloc_Map中,并记录该类型申请的内存大小,并累加到内存总量中;Step 3: Store in the structure Alloc_Map by type, record the memory size applied for by this type, and add it to the total memory;
步骤4:调用系统内存申请接口,申请内存;Step 4: Call the system memory application interface to apply for memory;
步骤5:把申请结果或申请到的内存返回给客户端程序;Step 5: Return the application result or the applied memory to the client program;
步骤6:接收到程序释放内存的动作后,解析数据类型;Step 6: After receiving the action of the program to release the memory, parse the data type;
步骤7:在数据结构Alloc_Map中按类型查找相应的内存统计总量;Step 7: Find the corresponding total memory statistics by type in the data structure Alloc_Map;
步骤8:从当前数据类型的内存总量中减去释放的内存量,并更新到Alloc_Map中,从内存总量中减去释放的内存量;Step 8: Subtract the amount of freed memory from the total amount of memory of the current data type, update it to Alloc_Map, and subtract the amount of freed memory from the total amount of memory;
步骤9:调用系统内存释放接口,进行内存释放;Step 9: Call the system memory release interface to release memory;
步骤10:收到客户端打印内存统计信息时,调用打印接口按类型格式化输出各类型对应的内存统计值和总的内存值。Step 10: When receiving the printing memory statistics information of the client, call the printing interface to format and output the memory statistics value and total memory value corresponding to each type according to the type.
下面对本申请实施例提供的一种内存监控装置进行介绍,下文描述的一种内存监控装置与上文描述的一种内存监控方法可以相互参照。The following describes a memory monitoring apparatus provided by an embodiment of the present application, and a memory monitoring apparatus described below and a memory monitoring method described above can be referred to each other.
参见图2,根据一示例性实施例示出的一种内存监控装置的结构图,如图2所示,包括:Referring to FIG. 2, a structural diagram of a memory monitoring device according to an exemplary embodiment, as shown in FIG. 2, includes:
识别模块201,用于当接收到目标数据的内存申请时,识别所述目标数据的数据类型;The
分配模块202,用于调用内存申请接口为所述目标数据分配内存,并返回内存分配结果,以便响应所述内存申请;an
第一更新模块203,用于根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小,并更新所有已分配内存的总量。The
本申请实施例提供的内存监控装置,通过拦截内存分配,按数据类型分类统计申请内存大小和所有已分配内存的总量,实现进程内存占用动态跟踪,为内存优化提供参考,提升内存健壮性和稳定性。由此可见,本申请实施例提供的内存监控装置,按数据类型进行内存占用统计,实现了进程内存占用动态跟踪。The memory monitoring device provided by the embodiment of the present application, by intercepting memory allocation, and classifying the size of the application memory and the total amount of all allocated memory by data type, realizes dynamic tracking of process memory occupation, provides a reference for memory optimization, and improves memory robustness and performance. stability. It can be seen that, the memory monitoring device provided by the embodiment of the present application performs memory occupancy statistics according to data types, and realizes dynamic tracking of process memory occupancy.
在上述实施例的基础上,作为一种优选实施方式,所述第一更新模块203包括:On the basis of the above embodiment, as a preferred implementation manner, the
判断单元,用于判断目标存储结构中是否存在所述数据类型;若是,则启动第一更新单元的工作流程;若否,则启动存储单元的工作流程;a judging unit for judging whether the data type exists in the target storage structure; if so, start the work flow of the first update unit; if not, start the work flow of the storage unit;
第一更新单元,用于根据所述内存申请对应的申请内存量更新所述数据类型对应的申请内存大小;a first updating unit, configured to update the requested memory size corresponding to the data type according to the requested memory amount corresponding to the memory request;
存储单元,用于将所述数据类型存储至所述目标存储结构中,并根据所述内存申请对应的申请内存量统计所述数据类型对应的申请内存大小;a storage unit, configured to store the data type in the target storage structure, and count the application memory size corresponding to the data type according to the application memory amount corresponding to the memory application;
第二更新单元,用更新所有已分配内存的总量。The second update unit is used to update the total amount of all allocated memory.
在上述实施例的基础上,作为一种优选实施方式,所述目标存储结构为Map结构。On the basis of the above embodiment, as a preferred implementation manner, the target storage structure is a Map structure.
在上述实施例的基础上,作为一种优选实施方式,所述分配模块202包括:On the basis of the above embodiment, as a preferred implementation manner, the
分配单元,用于调用内存申请接口为所述目标数据分配内存;an allocation unit for invoking a memory application interface to allocate memory for the target data;
第一返回单元,用于当申请成功时,返回所述目标数据对应的内存;The first returning unit is used to return the memory corresponding to the target data when the application is successful;
第二返回单元,用于当申请失败时,返回错误类型对应的错误码。The second return unit is used to return the error code corresponding to the error type when the application fails.
在上述实施例的基础上,作为一种优选实施方式,还包括:On the basis of the above embodiment, as a preferred implementation, it also includes:
输出模块,用于当接收到内存统计信息的打印命令时,分别输出每个所述数据类型对应的申请内存大小和所有已分配内存的总量。The output module is configured to output the size of the applied memory and the total amount of all allocated memory corresponding to each data type respectively when receiving the print command of the memory statistics information.
在上述实施例的基础上,作为一种优选实施方式,还包括:On the basis of the above embodiment, as a preferred implementation, it also includes:
确定模块,用于当检测到目标内存的释放动作后,确定所述目标内存存储数据的目标数据类型;a determining module, configured to determine the target data type of the data stored in the target memory after detecting the release action of the target memory;
第二更新模块,用于根据所述目标内存的大小更新所述目标数据类型对应的申请内存大小和所有已分配内存的总量。The second update module is configured to update the size of the applied memory corresponding to the target data type and the total amount of all allocated memory according to the size of the target memory.
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the apparatus in the above-mentioned embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be described in detail here.
本申请还提供了一种电子设备,参见图3,本申请实施例提供的一种电子设备300的结构图,如图3所示,可以包括处理器11和存储器12。该电子设备300还可以包括多媒体组件13,输入/输出(I/O)接口14,以及通信组件15中的一者或多者。The present application further provides an electronic device. Referring to FIG. 3 , a structural diagram of an
其中,处理器11用于控制该电子设备300的整体操作,以完成上述的内存监控方法中的全部或部分步骤。存储器12用于存储各种类型的数据以支持在该电子设备300的操作,这些数据例如可以包括用于在该电子设备300上操作的任何应用程序或方法的指令,以及应用程序相关的数据。该存储器12可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,例如静态随机存取存储器(Static Random Access Memory,简称SRAM),电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,简称EEPROM),可擦除可编程只读存储器(Erasable Programmable Read-Only Memory,简称EPROM),可编程只读存储器(Programmable Read-Only Memory,简称PROM),只读存储器(Read-Only Memory,简称ROM),磁存储器,快闪存储器,磁盘或光盘。多媒体组件13可以包括屏幕,例如可以是触摸屏。I/O接口14为处理器11和其他接口模块之间提供接口,上述其他接口模块可以是键盘,鼠标,按钮等。这些按钮可以是虚拟按钮或者实体按钮。通信组件15用于该电子设备300与其他设备之间进行有线或无线通信。无线通信,例如Wi-Fi,蓝牙,近场通信(Near Field Communication,简称NFC),2G、3G或4G,或它们中的一种或几种的组合,因此相应的该通信组件15可以包括:Wi-Fi模块,蓝牙模块,NFC模块。Wherein, the
在一示例性实施例中,电子设备300可以被一个或多个应用专用集成电路(Application Specific Integrated Circuit,简称ASIC)、数字信号处理器(DigitalSignal Processor,简称DSP)、数字信号处理设备(Digital Signal Processing Device,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称PLD)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述的内存监控方法。In an exemplary embodiment, the
在另一示例性实施例中,还提供了一种包括程序指令的计算机可读存储介质,该程序指令被处理器执行时实现上述内存监控方法的步骤。例如,该计算机可读存储介质可以为上述包括程序指令的存储器12,上述程序指令可由电子设备300的处理器11执行以完成上述的内存监控方法。In another exemplary embodiment, there is also provided a computer-readable storage medium including program instructions, the program instructions implementing the steps of the above-mentioned memory monitoring method when executed by a processor. For example, the computer-readable storage medium can be the above-mentioned
说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围内。The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant part can be referred to the description of the method. It should be pointed out that for those of ordinary skill in the art, without departing from the principles of the present application, several improvements and modifications can also be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
还需要说明的是,在本说明书中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should also be noted that, in this specification, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities or operations. There is no such actual relationship or sequence between operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010745263.0A CN111858258A (en) | 2020-07-29 | 2020-07-29 | A memory monitoring method, device, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010745263.0A CN111858258A (en) | 2020-07-29 | 2020-07-29 | A memory monitoring method, device, electronic device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111858258A true CN111858258A (en) | 2020-10-30 |
Family
ID=72946258
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010745263.0A Withdrawn CN111858258A (en) | 2020-07-29 | 2020-07-29 | A memory monitoring method, device, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111858258A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112433911A (en) * | 2020-11-06 | 2021-03-02 | 苏州浪潮智能科技有限公司 | Memory allocation monitoring method, system, medium and equipment |
CN114490042A (en) * | 2022-01-04 | 2022-05-13 | 青岛海信网络科技股份有限公司 | Memory allocation method and traffic network comprehensive monitoring equipment |
Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1512332A (en) * | 2002-12-31 | 2004-07-14 | ����̩ƽ | Processing method for self discribing data object |
CN102662775A (en) * | 2012-03-29 | 2012-09-12 | 奇智软件(北京)有限公司 | Process communication method and process communication device |
CN104102590A (en) * | 2014-07-22 | 2014-10-15 | 浪潮(北京)电子信息产业有限公司 | Heterogeneous memory management method and device |
CN106126359A (en) * | 2016-08-25 | 2016-11-16 | 成都交大光芒科技股份有限公司 | The rapid transmission method of process data sharing |
CN106502707A (en) * | 2016-11-14 | 2017-03-15 | 腾讯科技(深圳)有限公司 | Code generating method and device |
CN107085548A (en) * | 2016-02-16 | 2017-08-22 | 阿里巴巴集团控股有限公司 | A kind of method, device and electronic equipment for monitoring application program internal memory |
CN107391627A (en) * | 2017-06-30 | 2017-11-24 | 北京奇虎科技有限公司 | EMS memory occupation analysis method, device and the server of data |
CN107423220A (en) * | 2017-08-04 | 2017-12-01 | 青岛海信宽带多媒体技术有限公司 | The detection method and device of RAM leakage, electronic equipment |
CN110032440A (en) * | 2018-01-11 | 2019-07-19 | 武汉斗鱼网络科技有限公司 | A kind of EMS memory management process and relevant apparatus |
CN110187967A (en) * | 2019-05-15 | 2019-08-30 | 南瑞集团有限公司 | A memory prediction method and device suitable for dependency analysis tools |
CN110231994A (en) * | 2019-06-20 | 2019-09-13 | 深圳市腾讯网域计算机网络有限公司 | Memory analysis method, apparatus and computer readable storage medium |
CN110609748A (en) * | 2019-09-05 | 2019-12-24 | 青岛海信移动通信技术股份有限公司 | Memory allocation method, electronic equipment and storage medium |
CN111459671A (en) * | 2020-03-30 | 2020-07-28 | 深圳市英威腾电源有限公司 | Data processing method and device, data exchange server and storage medium |
-
2020
- 2020-07-29 CN CN202010745263.0A patent/CN111858258A/en not_active Withdrawn
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1512332A (en) * | 2002-12-31 | 2004-07-14 | ����̩ƽ | Processing method for self discribing data object |
CN102662775A (en) * | 2012-03-29 | 2012-09-12 | 奇智软件(北京)有限公司 | Process communication method and process communication device |
CN104102590A (en) * | 2014-07-22 | 2014-10-15 | 浪潮(北京)电子信息产业有限公司 | Heterogeneous memory management method and device |
CN107085548A (en) * | 2016-02-16 | 2017-08-22 | 阿里巴巴集团控股有限公司 | A kind of method, device and electronic equipment for monitoring application program internal memory |
CN106126359A (en) * | 2016-08-25 | 2016-11-16 | 成都交大光芒科技股份有限公司 | The rapid transmission method of process data sharing |
CN106502707A (en) * | 2016-11-14 | 2017-03-15 | 腾讯科技(深圳)有限公司 | Code generating method and device |
CN107391627A (en) * | 2017-06-30 | 2017-11-24 | 北京奇虎科技有限公司 | EMS memory occupation analysis method, device and the server of data |
CN107423220A (en) * | 2017-08-04 | 2017-12-01 | 青岛海信宽带多媒体技术有限公司 | The detection method and device of RAM leakage, electronic equipment |
CN110032440A (en) * | 2018-01-11 | 2019-07-19 | 武汉斗鱼网络科技有限公司 | A kind of EMS memory management process and relevant apparatus |
CN110187967A (en) * | 2019-05-15 | 2019-08-30 | 南瑞集团有限公司 | A memory prediction method and device suitable for dependency analysis tools |
CN110231994A (en) * | 2019-06-20 | 2019-09-13 | 深圳市腾讯网域计算机网络有限公司 | Memory analysis method, apparatus and computer readable storage medium |
CN110609748A (en) * | 2019-09-05 | 2019-12-24 | 青岛海信移动通信技术股份有限公司 | Memory allocation method, electronic equipment and storage medium |
CN111459671A (en) * | 2020-03-30 | 2020-07-28 | 深圳市英威腾电源有限公司 | Data processing method and device, data exchange server and storage medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112433911A (en) * | 2020-11-06 | 2021-03-02 | 苏州浪潮智能科技有限公司 | Memory allocation monitoring method, system, medium and equipment |
CN114490042A (en) * | 2022-01-04 | 2022-05-13 | 青岛海信网络科技股份有限公司 | Memory allocation method and traffic network comprehensive monitoring equipment |
CN114490042B (en) * | 2022-01-04 | 2024-03-22 | 青岛海信网络科技股份有限公司 | Memory allocation method and traffic network comprehensive monitoring equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8832666B2 (en) | Dynamic instrumentation | |
CN108958844A (en) | A kind of control method and terminal of application program | |
CN108415804B (en) | Method for acquiring information, terminal device and computer readable storage medium | |
US11755744B2 (en) | Application programming interface specification inference | |
US11580228B2 (en) | Coverage of web application analysis | |
CN106528210A (en) | Application program running method and device | |
CN111858258A (en) | A memory monitoring method, device, electronic device and storage medium | |
CN111124544A (en) | Interface display method and device, electronic equipment and storage medium | |
CN111510330A (en) | Interface management device, method and storage medium | |
CN109558145B (en) | Installation package volume optimization method and device for android application | |
US20220342674A1 (en) | Exception stack handling method, system, electronic device and storage medium | |
US11106564B2 (en) | Deframeworking for static program analysis | |
US10783245B2 (en) | Feedback-directed static analysis | |
US10776161B2 (en) | Application code callbacks at regular intervals | |
WO2022206253A1 (en) | Exception handling method and apparatus, device, and storage medium | |
US10528344B2 (en) | Modular points-to analysis | |
CN106383869B (en) | Method and device for acquiring user behavior information | |
CN113553522A (en) | Page display method and device, electronic equipment and storage medium | |
CN111124627A (en) | Method, device, terminal and storage medium for determining application program caller | |
US11354117B2 (en) | Adaptable patching mechanism for mixed memory systems | |
CN114741417A (en) | A multi-database query, data processing method, device and electronic device | |
CN115834688A (en) | Communication middleware, communication method, electronic device, and storage medium | |
US9497253B2 (en) | Authorization review system | |
US20090313628A1 (en) | Dynamically batching remote object model commands | |
US10620946B1 (en) | Dynamic modeling for opaque code during static analysis |
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 | ||
WW01 | Invention patent application withdrawn after publication | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20201030 |