[go: up one dir, main page]

CN119046007A - Memory release method, device, equipment, storage medium and program product - Google Patents

Memory release method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN119046007A
CN119046007A CN202411195247.3A CN202411195247A CN119046007A CN 119046007 A CN119046007 A CN 119046007A CN 202411195247 A CN202411195247 A CN 202411195247A CN 119046007 A CN119046007 A CN 119046007A
Authority
CN
China
Prior art keywords
memory
target
range
target memory
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411195247.3A
Other languages
Chinese (zh)
Inventor
朴英敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202411195247.3A priority Critical patent/CN119046007A/en
Publication of CN119046007A publication Critical patent/CN119046007A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本公开涉及计算机技术领域,公开了内存释放方法、装置、设备、存储介质及程序产品,该方法包括:获取业务进程在系统内存中申请的目标内存范围,以及业务进程的调用栈;查询目标内存范围中被迁移至交换空间的目标内存信息;基于目标内存信息确定内存使用情况;若内存使用情况表征目标内存范围中存在处于闲置状态的内存,则将调用栈上报至服务端,调用栈用于服务端确定目标内存范围中待释放的内存。本公开能够解决物理内存不足的问题。

The present disclosure relates to the field of computer technology, and discloses a memory release method, device, equipment, storage medium and program product, the method comprising: obtaining a target memory range applied for by a business process in a system memory, and a call stack of the business process; querying target memory information migrated to a swap space in the target memory range; determining memory usage based on the target memory information; if the memory usage indicates that there is idle memory in the target memory range, reporting the call stack to a server, and the call stack is used by the server to determine the memory to be released in the target memory range. The present disclosure can solve the problem of insufficient physical memory.

Description

Memory release method, device, equipment, storage medium and program product
Technical Field
The present disclosure relates to the field of computer technology, and in particular, to a memory release method, apparatus, device, storage medium, and program product.
Background
At present, as functions of service applications become more and more complex, demands for memory become larger and larger, if memory of terminal equipment such as mobile phones is exhausted, system blocking and service application breakdown on the terminal equipment can be caused. Although the popularization of 64-bit terminal devices is accompanied by a relaxation of the restrictions on virtual memory. But with the consequent problem of physical memory starvation becoming increasingly pronounced.
Disclosure of Invention
In view of the above, the present disclosure provides a memory release method, apparatus, device, storage medium and program product to solve the problem of insufficient physical memory.
In a first aspect, the present disclosure provides a memory release method, where the method includes:
acquiring a target memory range applied by a business process in a system memory and a call stack of the business process;
inquiring target memory information migrated to a switching space in the target memory range;
Determining the memory use condition based on the target memory information;
If the memory usage represents that the memory in the idle state exists in the target memory range, the call stack is reported to the server, and the call stack is used for determining the memory to be released in the target memory range by the server.
In a second aspect, the present disclosure provides a memory release method, where the method includes:
receiving a call stack of a target business process reported by a client, wherein the call stack is reported when a memory in an idle state exists in a target memory range represented by a memory use condition of the client, the target memory range is applied for by the target business process in a system memory, and the memory use condition is determined by the client based on target memory information migrated to a switching space in the target memory range;
Determining the target memory range applied by the target business process and the corresponding target memory information based on the call stack;
determining a memory to be released in the target memory range based on the target memory information;
And sending a memory release instruction to the client based on the memory to be released, so that the client responds to the memory release instruction to release the memory to be released.
In a third aspect, the present disclosure provides a memory release device, the device comprising:
The process information acquisition module is used for acquiring a target memory range applied by a business process in a system memory and a call stack of the business process;
The memory information inquiry module is used for inquiring the target memory information migrated to the exchange space in the target memory range;
the use condition determining module is used for determining the use condition of the memory based on the target memory information;
And the abnormal information reporting module is used for reporting the call stack to a server side if the memory usage condition indicates that the memory in the idle state exists in the target memory range, and the call stack is used for determining the memory to be released in the target memory range by the server side.
In a fourth aspect, the present disclosure provides a memory release device, the device including:
the system comprises a report information acquisition module, a report information acquisition module and a report information processing module, wherein the report information acquisition module is used for receiving a call stack of a target business process reported by a client, the call stack is reported when a memory in an idle state exists in a target memory range represented by a memory use condition of the client, the target memory range is applied for by the target business process in a system memory, and the memory use condition is determined by the client based on target memory information migrated to a switching space in the target memory range;
The memory information acquisition module is used for determining the target memory range applied by the target business process and the corresponding target memory information based on the call stack;
The memory to be released determining module is used for determining the memory to be released in the target memory range based on the target memory information;
and the release instruction sending module is used for sending a memory release instruction to the client based on the memory to be released, so that the client responds to the memory release instruction to release the memory to be released.
In a fifth aspect, the present disclosure provides an electronic device, including a memory and a processor, where the memory and the processor are communicatively connected to each other, and the memory stores computer instructions, and the processor executes the computer instructions, thereby executing the memory release method in the first aspect or the second aspect.
In a sixth aspect, the present disclosure provides a computer readable storage medium having stored thereon computer instructions for causing a computer to perform the memory release method of the first or second aspect described above.
In a seventh aspect, the present disclosure provides a computer program product comprising computer instructions for causing a computer to perform the memory release method of the first or second aspect above.
The memory release method provided by the embodiment of the disclosure obtains a target memory range applied by a business process in a system memory and a call stack of the business process. And then, inquiring the target memory information migrated to the exchange space in the target memory range, thereby determining the memory use condition of the target memory range by utilizing the characteristic that the operating system migrates the unusual memory to the exchange space when the system memory is insufficient. If the memory usage represents that the memory in the idle state exists in the target memory range, the call stack is reported to the server, so that the server determines the memory to be released in the target memory range according to the call stack, and the memory to be released is released. Therefore, the memory in the idle state in the system memory can be released, so that the problem of insufficient physical memory is relieved to a certain extent, and the normal operation of service application is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the prior art, the drawings that are required in the detailed description or the prior art will be briefly described, it will be apparent that the drawings in the following description are some embodiments of the present disclosure, and other drawings may be obtained according to the drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a flow chart of a memory release method according to an embodiment of the disclosure;
FIG. 2 is a flow chart of another memory release method according to an embodiment of the disclosure;
FIG. 3 is a flow chart of a memory release by a business application according to an embodiment of the disclosure;
FIG. 4 is a block diagram of a memory release device according to an embodiment of the present disclosure;
FIG. 5 is a block diagram of another memory release device according to an embodiment of the present disclosure;
Fig. 6 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. Based on the embodiments in this disclosure, all other embodiments that a person skilled in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
It will be appreciated that prior to using the technical solutions disclosed in the embodiments of the present disclosure, the user should be informed and authorized of the type, usage range, usage scenario, etc. of the personal information related to the present disclosure in an appropriate manner according to the relevant legal regulations.
For example, in response to receiving an active request from a user, a prompt is sent to the user to explicitly prompt the user that the operation it is requesting to perform will require personal information to be obtained and used with the user. Thus, the user can autonomously select whether to provide personal information to software or hardware such as an electronic device, an application program, a server or a storage medium for executing the operation of the technical scheme of the present disclosure according to the prompt information.
As an alternative but non-limiting implementation, in response to receiving an active request from a user, the manner in which the prompt information is sent to the user may be, for example, a popup, in which the prompt information may be presented in a text manner. In addition, a selection control for the user to select to provide personal information to the electronic device in a 'consent' or 'disagreement' manner can be carried in the popup window.
It will be appreciated that the above-described notification and user authorization process is merely illustrative and not limiting of the implementations of the present disclosure, and that other ways of satisfying relevant legal regulations may be applied to the implementations of the present disclosure.
It will be appreciated that the data (including but not limited to the data itself, the acquisition or use of the data) involved in the present technical solution should comply with the corresponding legal regulations and the requirements of the relevant regulations.
At present, as functions of service applications become more and more complex, demands for memory become larger and larger, if memory of terminal equipment such as mobile phones is exhausted, system blocking and service application breakdown on the terminal equipment can be caused. With the popularization of 64-bit terminal devices, the limitation of virtual memory is relaxed. But with the consequent problem of physical memory starvation becoming increasingly pronounced. For example, the physical memory of the mainstream mobile phone is generally 2GB, 4GB or 8GB, the limitation of the virtual memory is relaxed, and the business application can use the memory according to the requirement. Business applications often suffer from performance degradation due to insufficient physical memory and even forced shutdown by the system.
As can be seen, the problem of insufficient physical memory in the related art needs to be solved.
In view of the foregoing, it will be appreciated that in accordance with embodiments of the present disclosure, there is provided a memory release method embodiment in which the steps illustrated in the flowcharts of the figures may be performed in a computer system, such as a set of computer executable instructions, and that in some cases the steps illustrated or described may be performed in a different order than shown in the flowcharts, although a logical order is illustrated in the flowcharts.
In this embodiment, a memory release method is provided, which may be used for a client of a service application, and fig. 1 is a schematic flow chart of a memory release method according to an embodiment of the disclosure, as shown in fig. 1, where the flow chart includes the following steps:
step S101, a target memory range applied by a business process in a system memory and a call stack of the business process are obtained.
Specifically, a business process is a process used by a business application to execute different business logic, for example, a process used by business logic such as opening a menu, sliding a video, and the like. The business process calls a memory application function to apply a memory in the system memory for storing business data of corresponding business logic.
Specifically, the proxy function of the memory application function can be configured, so that when the service process calls the memory application function, the proxy function is executed, the proxy function records the target memory range of the service process application and the call stack of the service process, and then the memory application function is accessed to apply the memory of the target memory range in the system memory.
Step S102, inquiring the target memory information migrated to the exchange space in the target memory range.
It should be noted that in the Linux operating system, swap is a virtual memory mechanism, and the operating system uses disk space to expand the available memory of the operating system. When the system memory is insufficient, the Swap may temporarily write some unusual memory blocks into the Swap space on the disk to make room for the running program. When the system memory usage approaches or exceeds the physical memory size, the operating system selects some unusual memory pages to write into the swap space according to a certain algorithm. When the memory pages migrated to the swap space need to be accessed, the operating system reads the memory pages to be accessed from the swap space back to the system memory.
In addition, considering that the efficiency of reading and writing the magnetic disk is low, the running efficiency of the program can be seriously affected, so zram technology is introduced to realize the function of the Swap. Wherein zram is a compressed random access memory (RandomAccess Memory, abbreviated as RAM) block device driver in the Linux kernel, thereby providing a virtual swap space for the operating system. zram compress and store the data in the system memory, so that more data can be accommodated in the limited physical memory space. Compared with the traditional disk-based exchange space, zram provides a memory-based exchange space, which has higher access speed.
Therefore, the information of the target memory migrated to the exchange space by the operating system in the target memory range can be queried through the information such as the memory mapping table recorded by the operating system, so as to determine whether the unusual memory blocks exist in the target memory range.
It should be noted that the switching space in the above step S102 includes at least one of zram memory-based switching space and Swap disk-based switching space.
Step S103, determining the memory use condition based on the target memory information.
It should be noted that the memory usage is the usage of the memory in the target memory range.
It can be understood that if the target memory information migrated to the exchange space exists in the target memory range, it indicates that there is an unusual memory block in the target memory range, that is, there is a memory in an idle state in the target memory range. If the target memory information migrated to the exchange space does not exist in the target memory range, the target memory range is indicated to have no memory blocks which are not commonly used, namely the target memory range does not have the memory in the idle state.
Step S104, if the memory usage represents that the memory in the idle state exists in the target memory range, the call stack is reported to the server, and the call stack is used for determining the memory to be released in the target memory range by the server.
Specifically, if the memory in the idle state exists in the target memory range, the call stack is reported to the server, so that the server determines the service logic corresponding to the call stack, and the memory to be released (i.e. the memory in the idle state) in the target memory range, so as to inform the service application of the determination of the correction by the related personnel who process the service logic. For example, a person concerned is alerted whether or not the memory to be released needs to be released. Or the server generates a corresponding memory release instruction according to a certain strategy so as to release the memory to be released in the target memory range while keeping the memory commonly used in the target memory range.
The memory release method provided by the embodiment obtains the target memory range applied by the service process in the system memory and the call stack of the service process. And then, inquiring the target memory information migrated to the exchange space in the target memory range, thereby determining the memory use condition of the target memory range by utilizing the characteristic that the operating system migrates the unusual memory to the exchange space when the system memory is insufficient. If the memory usage represents that the memory in the idle state exists in the target memory range, the call stack is reported to the server, so that the server determines the memory to be released in the target memory range according to the call stack, and the memory to be released is released. Therefore, the memory in the idle state in the system memory can be released, so that the problem of insufficient physical memory is relieved to a certain extent, and the normal operation of service application is ensured.
In some optional embodiments, the obtaining the target memory range applied by the business process in the system memory in step S101 and the call stack of the business process include:
Step a1, configuring an agent function of a memory application function, wherein the memory application function is used for applying memory for a business process.
Specifically, the malloc function and mmap function are two commonly used memory application functions. Wherein, malloc function is used for applying for the heap memory of application, is maintained by heap management module, and malloc function relies on mmap function. The mmap function is a system call function, and can apply a larger address space for service logic. Therefore, the memory range of all business logic applications in the business application can be obtained by configuring proxy functions of the malloc function and the mmap function.
Specifically, the step a1 includes:
Step a11, obtaining a first address of a memory application function recorded in a global offset table, wherein the global offset table is used for storing addresses of external functions called by a business process, and the external functions comprise the memory application function and an agent function.
It should be noted that the global offset table (Global Offset Table, GOT for short) is a code injection technology commonly used in the "Hook" technology (also called Hook technology), and is mainly applied to executable files or shared libraries in executable and linkable formats (Executable and Linkable Format, ELF for short). The global offset table is an important component of dynamic link, and is used for storing the actual address of the external function referenced by the program (such as business process). When a business process calls an external function (such as a memory application function), the address of the function is searched through the global offset table, and then the corresponding function is executed by jumping to the address. The principle of Hook of the global offset table is to modify the address of the function in the global offset table to point to a custom function implementation instead of the original function. Therefore, when the functions are called by the business application, the custom functions of the Hook can be actually executed, so that the purposes of code injection or function hijacking are realized.
Based on the above, before the proxy function of the memory application function is configured, the first address of the memory application function recorded in the global offset table can be obtained, so that the first address is replaced by the second address of the proxy function, and thus, when the proxy function is utilized to obtain the target memory range of the application and the call stack of the business process when the business process calls the memory application function.
Step a12, configuring the proxy function of the memory application function and recording and storing the second address of the proxy function.
Specifically, the proxy function of the memory application function can be configured through Hook technology, and the second address of the proxy function is recorded and stored.
Step a13, replacing the first address of the memory application function in the global offset table with the second address.
It can be understood that, when the business process calls the memory application function, the business process needs to search the global offset table for the first address of the memory application function, and then jump and execute the first address to the memory application function. Therefore, the first address of the memory application function in the global offset table can be replaced by the second address, so that the business process searches the second address of the proxy function in the global offset table when calling the memory application function, and the proxy function is skipped and executed according to the second address. And acquiring a target memory range of the business process application by using the proxy function and capturing a call stack of the business process.
And a2, if the service process calls the memory application function to apply for the memory, acquiring a target memory range and a call stack of the service process application based on the proxy function.
Specifically, the step a2 includes:
Step a21, obtaining the target memory range of the business process application based on the proxy function.
It can be appreciated that, since the service process accesses the proxy function when calling the memory application function according to the global offset table, the target memory range of the service process application can be obtained through the proxy function.
Specifically, the target memory range includes a memory start address and a memory end address applied by the service process.
Step a22, determining the size of the target memory corresponding to the target memory range.
It can be appreciated that after the target memory range is determined, the target memory size of the business process application can be determined according to the target memory range.
Step a23, grabbing a call stack based on the proxy function if the target memory size is greater than the first preset memory threshold.
Optionally, the first preset memory threshold is 1MB.
It should be noted that the first preset memory threshold may be selected according to actual requirements. Considering that the number of small memories with smaller memory ranges in the system memory is more, and the number of large memories with larger memory ranges is less, if the call stack is grabbed for each memory with smaller memory ranges, more time is consumed, so that the operation efficiency of the service application is affected. Therefore, a suitable first preset memory threshold value can be set, when the size of the target memory is larger than the first preset memory threshold value, the call stack of the service process is grabbed again, for example, if the size of the applied target memory is larger than 1MB, logic for grabbing the call stack is triggered again, and the grabbed call stack and the corresponding target memory range are recorded, so that the influence on the running efficiency of the service application can be reduced.
According to the memory release method provided by the embodiment, the proxy function of the memory application function is configured, so that the proxy function can be utilized to effectively acquire the target memory range of the business process application. And capturing a call stack of the business process based on the proxy function only when the size of the target memory corresponding to the target memory range is larger than a first preset memory threshold value. Therefore, the proxy function can be utilized to grab the call stack to release the memory which is not commonly used, so as to relieve the problem of insufficient physical memory. And meanwhile, the influence on the operation efficiency of the service application caused by frequent grabbing of the call stack is avoided.
In some optional embodiments, the target memory information migrated to the swap space in the query target memory range in step S102 includes:
step b1, obtaining a memory mapping file, wherein the memory mapping file comprises memory information which is migrated to a exchanging space in different memory ranges.
Specifically, the step b1 includes obtaining a memory map file if the remaining memory of the system memory does not meet the preset memory usage condition.
Specifically, whether the remaining memory of the system memory does not meet the preset memory usage condition may be determined through information of the operating system or a notification event of the registration system.
It should be noted that, the preset memory usage condition may be determined according to the remaining memory that can ensure the normal operation of the service application. For example, the preset memory usage condition is that the remaining memory is less than a preset minimum memory threshold.
And b2, searching the target memory information in the memory mapping file based on the target memory range.
It should be noted that, when the system memory is insufficient, the operating system will migrate the memory that is not commonly used in the memory to the swap space. Meanwhile, the operating system records the memory address, the memory size, the physical memory actually allocated and the physical memory size migrated to the exchange space corresponding to the memory in the memory mapping file. Therefore, the memory range corresponding to the memory migrated to the exchange space can be searched in the memory mapping file, and then the searched memory range is matched with the pre-recorded target memory range, so as to determine whether target memory information migrated to the exchange space exists in each target memory range.
Specifically, in the memory map file, the physical memory size that is migrated to the Swap space within the current memory range is typically characterized by Swap and SwapPss fields. For example, swap:16kB, means that physical memory of 16kB within the current memory range is migrated to the Swap space, i.e., there is unusual memory within the current memory range.
In the memory release method provided in this embodiment, if the remaining memory in the system memory does not meet the preset memory usage condition, a memory mapping file is obtained, and the target memory information is searched in the memory mapping file based on the target memory range. Therefore, the memory mapping file can be prevented from being accessed frequently when judging whether the unusual memory exists in the target memory range by using the memory mapping file, so that the normal operation of the business application is ensured.
In some optional embodiments, determining the memory usage based on the target memory information in step S103 includes:
Step c1, determining the first abnormal memory size based on the target memory information.
And c2, if the first abnormal memory size is larger than a second preset memory threshold value, determining that the memory usage condition is that the memory in the idle state exists in the target memory range.
It should be noted that the second preset memory threshold may be determined according to an actual situation.
In the memory release method provided in this embodiment, if the first abnormal memory size in the target memory range is greater than the second preset memory threshold, the memory usage condition is determined as that there is a memory in an idle state in the target memory range. Therefore, the frequently-allocated memory can be prevented from being adjusted, and the normal operation of the business application is ensured.
In other optional embodiments, the determining the memory usage based on the target memory information in step S103 includes:
step d1, determining the second abnormal memory size based on the target memory information.
Step d2, determining the abnormal memory duty ratio based on the ratio of the second abnormal memory size to the target memory size corresponding to the target memory range.
And d3, if the abnormal memory duty ratio is larger than the preset duty ratio threshold value, determining that the memory usage condition is that the memory in the idle state exists in the target memory range.
In the memory release method provided in this embodiment, if the duty ratio of the second abnormal memory size in the target memory range is greater than the preset duty ratio threshold, the memory usage condition is determined as that there is a memory in an idle state in the target memory range. Therefore, the frequently-allocated memory can be prevented from being adjusted, and the normal operation of the business application is ensured.
In some alternative embodiments, the memory release method of the present disclosure further includes releasing memory within the target memory range in response to a release instruction for the target memory range.
Specifically, in response to a release instruction for a target memory range, a memory release function is invoked to release memory within the target memory range.
Specifically, the memory release function includes at least one of unmmap functions and free functions.
It should be noted that, after the memory within the target memory range is released, the target memory range and the record of the corresponding call stack may be discarded, so as to reduce memory occupation.
In this embodiment, another memory release method is provided, which may be used for a service end of a service application, and fig. 2 is a schematic flow chart of another memory release method according to an embodiment of the disclosure, as shown in fig. 2, where the flow includes the following steps:
Step S201, receiving a call stack of a target business process reported by a client, wherein the call stack is reported when a memory in an idle state exists in a target memory range represented by a memory usage condition of the client, the target memory range is applied for by the target business process in a system memory, and the memory usage condition is determined by the client based on target memory information migrated to a switching space in the target memory range.
Step S202, determining a target memory range and corresponding target memory information of a target business process application based on a call stack.
Step S203, determining the memory to be released in the target memory range based on the target memory information.
Step S204, based on the memory to be released, a memory release instruction is sent to the client, so that the client responds to the memory release instruction to release the memory to be released.
According to the memory release method provided by the embodiment, a client acquires a target memory range applied by a business process in a system memory and a call stack of the business process. Then, the client queries the target memory information migrated to the exchange space in the target memory range, so as to determine the memory use condition of the target memory range by utilizing the characteristic that the operating system migrates the unusual memory to the exchange space when the system memory is insufficient. If the memory usage represents that the memory in the idle state exists in the target memory range, the client reports the call stack to the server. And the server determines the memory to be released in the target memory range according to the call stack, thereby releasing the memory to be released. Therefore, the memory in the idle state in the system memory can be released, so that the problem of insufficient physical memory is relieved to a certain extent, and the normal operation of service application is ensured.
In some optional embodiments, the memory release method further comprises the steps of determining memory occupation ratios of the memories to be released in each target memory range based on target memory information under the condition that the number of call stacks reported by the client is larger than 1, and sending memory release instructions to the client sequentially based on the memories to be released according to the sequence of the memory occupation ratios from large to small.
For example, the memory to be released is released with a memory ratio of 80% and then the memory to be released with a memory ratio of 60% is released.
Illustratively, as shown in FIG. 3, the overall flow of the memory release method of the present disclosure is as follows, the client obtains the global offset table. The client configures the proxy function of the memory application function and replaces the first address of the memory application function in the global offset table with the second address of the proxy function. When a business process calls a memory application function, a client calls a proxy function, and a target memory range of the business process application and a call stack of the business process are obtained. Then, the client adds the obtained target memory range and the call stack to a local database. On the one hand, the client can respond to a release instruction of the server for the target memory range, release the memory of the target memory range, and delete the target memory range and the call stack recorded in the local database. On the other hand, under the condition of insufficient system memory, the client acquires the memory mapping file to read the memory range of the memory information which is migrated to the exchange space. The client loads the target memory range from the local database and compares the target memory range with the read memory range of the memory information which is migrated to the exchange space, so as to determine the target memory range of the memory which is not commonly used. Furthermore, the client loads a call stack corresponding to the target memory range and reports the call stack to the server. The server side can inform relevant personnel of the corresponding business process/business logic to carry out rectification according to the call stack so as to release the memory which is not commonly used, thereby relieving the problem of insufficient physical memory.
As a specific application example, a client of a service application is installed on a mobile phone, and the client of the service application can adopt the memory release method disclosed by the disclosure to release the memory which is not commonly used in the memory applied by the service process, so as to relieve the problem of insufficient physical memory and ensure the normal operation of the service application.
The embodiment also provides a memory release device, which is used for implementing the above embodiment and the preferred implementation, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a memory release device, as shown in fig. 4, including:
the process information obtaining module 401 is configured to obtain a target memory range applied by a service process in a system memory, and a call stack of the service process;
the memory information query module 402 is configured to query target memory information migrated to the exchange space in the target memory range;
A usage determining module 403, configured to determine a memory usage based on the target memory information;
the abnormal information reporting module 404 is configured to report a call stack to the server if the memory usage represents that the memory in the idle state exists in the target memory range, where the call stack is used by the server to determine the memory to be released in the target memory range.
In some alternative embodiments, the process information acquisition module 401 includes:
The proxy function configuration unit is used for configuring a proxy function of a memory application function, and the memory application function is used for applying memory for a business process;
the process information acquisition unit is used for acquiring a target memory range and a call stack of the service process application based on the proxy function if the service process calls the memory application function to apply for the memory.
In some alternative embodiments, the proxy function configuration unit includes:
The address acquisition subunit is used for acquiring a first address of a memory application function recorded in a global offset table, wherein the global offset table is used for storing addresses of external functions called by a business process, and the external functions comprise the memory application function;
the function configuration subunit is used for configuring the proxy function of the memory application function and recording and storing the second address of the proxy function;
And the address replacing subunit is used for replacing the first address of the memory application function in the global offset table with the second address.
In some alternative embodiments, the process information acquisition unit includes:
The memory range acquisition subunit is used for acquiring a target memory range of the business process application based on the proxy function;
the memory size determining subunit is used for determining the target memory size corresponding to the target memory range;
and the call stack grabbing subunit is used for grabbing the call stack based on the proxy function if the size of the target memory is larger than a first preset memory threshold value.
In some alternative embodiments, the memory information query module 402 includes:
the mapping file acquisition unit is used for acquiring a memory mapping file, wherein the memory mapping file comprises memory information which is migrated to a exchanging space in different memory ranges;
And the memory information acquisition unit is used for searching the target memory information in the memory mapping file based on the target memory range.
In some alternative embodiments, the mapping file acquiring unit includes:
and the mapping file acquisition subunit is used for acquiring the memory mapping file if the residual memory of the system memory does not meet the preset memory use condition.
In some alternative embodiments, the usage determination module 403 includes:
the first memory size determining unit is used for determining a first abnormal memory size based on the target memory information;
The first usage analysis unit is configured to determine that the memory usage is that there is a memory in an idle state in the target memory range if the first abnormal memory size is greater than the second preset memory threshold.
In some alternative embodiments, the usage determination module 403 includes:
the second memory size determining unit is used for determining the second abnormal memory size based on the target memory information;
The abnormal memory occupation ratio analysis unit is used for determining the abnormal memory occupation ratio based on the ratio of the second abnormal memory size to the target memory size corresponding to the target memory range;
and the second service condition analysis unit is used for determining that the memory service condition is that the memory in the idle state exists in the target memory range if the abnormal memory duty ratio is larger than the preset duty ratio threshold value.
In some alternative embodiments, the memory release device of the present disclosure further comprises:
And the target memory release module is used for responding to the release instruction aiming at the target memory range and releasing the memory in the target memory range.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The memory release device in this embodiment is presented as a functional unit, where the unit refers to an ASIC (Application SPECIFIC INTEGRATED Circuit) Circuit, a processor and a memory that execute one or more software or firmware programs, and/or other devices that can provide the above functions.
The embodiment also provides a memory release device, which is used for implementing the above embodiment and the preferred implementation, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a memory release device, as shown in fig. 5, including:
The report information obtaining module 501 is configured to receive a call stack of a target service process reported by a client, where the call stack is reported when a memory in an idle state exists in a target memory range represented by a memory usage situation of the client, the target memory range is applied for by the target service process in a system memory, and the memory usage situation is determined by the client based on target memory information migrated to a swap space in the target memory range;
The memory information obtaining module 502 is configured to determine a target memory range and corresponding target memory information applied by the target business process based on the call stack;
A to-be-released memory determining module 503, configured to determine a memory to be released in the target memory range based on the target memory information;
And the release instruction sending module 504 is configured to send a memory release instruction to the client based on the memory to be released, so that the client responds to the memory release instruction to release the memory to be released.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The memory release device in this embodiment is presented as a functional unit, where the unit refers to an ASIC (Application SPECIFIC INTEGRATED Circuit) Circuit, a processor and a memory that execute one or more software or firmware programs, and/or other devices that can provide the above functions.
The embodiment of the disclosure also provides an electronic device having the memory releasing device shown in fig. 4 or fig. 5.
Referring to fig. 6, fig. 6 is a block diagram of an electronic device according to an alternative embodiment of the present disclosure, and as shown in fig. 6, the electronic device includes one or more processors 601, a memory 602, and interfaces for connecting components, including a high-speed interface and a low-speed interface. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 601 is illustrated in fig. 6.
The processor 601 may be a central processor, a network processor, or a combination thereof. The processor 601 may further comprise a hardware chip, among other things. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 602 stores instructions executable by the at least one processor 601 to cause the at least one processor 601 to perform a method for implementing the embodiments described above.
The memory 602 may include a storage program area that may store an operating system, application programs required for at least one function, and a storage data area that may store data created according to the use of the electronic device, etc. In addition, the memory 602 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 602 may optionally include memory located remotely from processor 601, such remote memory being connectable to the electronic device through 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 memory 602 may include volatile memory, such as random access memory, nonvolatile memory, such as flash memory, hard disk, or solid state disk, and the memory 602 may also include combinations of the above.
The electronic device further comprises input means 603 and output means 604. The processor 601, memory 602, input device 603 and output device 604 may be connected by a bus or otherwise, for example in fig. 6.
The input device 603 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, pointer stick, one or more mouse buttons, trackball, joystick, and the like. The output means 604 may include a display device, auxiliary lighting means (e.g., LEDs), tactile feedback means (e.g., vibration motors), and the like. Such display devices include, but are not limited to, liquid crystal displays, light emitting diodes, displays and plasma displays. In some alternative implementations, the display device may be a touch screen.
The presently disclosed embodiments also provide a computer readable storage medium, and the methods described above according to the presently disclosed embodiments may be implemented in hardware, firmware, or as recordable storage medium, or as computer code downloaded over a network that is originally stored in a remote storage medium or a non-transitory machine-readable storage medium and is to be stored in a local storage medium, such that the methods described herein may be stored on such software processes on a storage medium using a general purpose computer, special purpose processor, or programmable or dedicated hardware. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random-access memory, a flash memory, a hard disk, a solid state disk, or the like, and further, the storage medium may further include a combination of the above types of memories. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Portions of the present disclosure may be applied as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present disclosure by way of operation of the computer. Those skilled in the art will appreciate that the existence of computer program instructions in a computer-readable medium includes, but is not limited to, source files, executable files, installation package files, and the like, and accordingly, the manner in which computer program instructions are executed by a computer includes, but is not limited to, the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled programs, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed programs. Herein, a computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by a computer.
Although embodiments of the present disclosure have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the disclosure, and such modifications and variations are within the scope defined by the appended claims.

Claims (15)

1. A memory release method, the method comprising:
acquiring a target memory range applied by a business process in a system memory and a call stack of the business process;
inquiring target memory information migrated to a switching space in the target memory range;
Determining the memory use condition based on the target memory information;
If the memory usage represents that the memory in the idle state exists in the target memory range, the call stack is reported to the server, and the call stack is used for determining the memory to be released in the target memory range by the server.
2. The memory release method according to claim 1, wherein the obtaining the target memory range applied by the service process in the system memory and the call stack of the service process includes:
Configuring an agent function of a memory application function, wherein the memory application function is used for applying memory for the business process;
And if the service process calls the memory application function to apply for memory, acquiring a target memory range of the service process application and the call stack based on the proxy function.
3. The memory release method according to claim 2, wherein the configuring the proxy function of the memory application function includes:
Acquiring a first address of the memory application function recorded in a global offset table, wherein the global offset table is used for storing an address of an external function called by the business process, and the external function comprises the memory application function;
Configuring a proxy function of the memory application function and recording and storing a second address of the proxy function;
And replacing the first address of the memory application function in the global offset table with the second address.
4. The memory release method according to claim 2, wherein the obtaining, based on the proxy function, the target memory range of the business process application and the call stack includes:
acquiring a target memory range of the business process application based on the proxy function;
determining the size of a target memory corresponding to the target memory range;
And if the target memory size is larger than a first preset memory threshold value, grabbing the call stack based on the proxy function.
5. The memory release method according to claim 1, wherein the querying the target memory information migrated to the swap space in the target memory range includes:
acquiring a memory mapping file, wherein the memory mapping file comprises memory information which is migrated to the exchange space in different memory ranges;
and searching the target memory information in the memory mapping file based on the target memory range.
6. The memory release method according to claim 5, wherein the obtaining the memory map file includes:
and if the residual memory of the system memory does not meet the preset memory use condition, acquiring the memory mapping file.
7. The memory release method according to claim 1, wherein the determining a memory usage condition based on the target memory information includes:
Determining a first abnormal memory size based on the target memory information;
If the first abnormal memory size is larger than a second preset memory threshold, determining that the memory usage condition is that the memory in the idle state exists in the target memory range.
8. The memory release method according to claim 1, wherein the determining a memory usage condition based on the target memory information includes:
Determining a second abnormal memory size based on the target memory information;
Determining an abnormal memory duty cycle based on a ratio of the second abnormal memory size to a target memory size corresponding to the target memory range;
And if the abnormal memory duty ratio is larger than a preset duty ratio threshold, determining that the memory usage condition is that the memory in the idle state exists in the target memory range.
9. The memory release method according to claim 1, wherein the method comprises:
And responding to a release instruction aiming at the target memory range, and releasing the memory in the target memory range.
10. A memory release method, the method comprising:
receiving a call stack of a target business process reported by a client, wherein the call stack is reported when a memory in an idle state exists in a target memory range represented by a memory use condition of the client, the target memory range is applied for by the target business process in a system memory, and the memory use condition is determined by the client based on target memory information migrated to a switching space in the target memory range;
Determining the target memory range applied by the target business process and the corresponding target memory information based on the call stack;
determining a memory to be released in the target memory range based on the target memory information;
And sending a memory release instruction to the client based on the memory to be released, so that the client responds to the memory release instruction to release the memory to be released.
11. A memory release device, the device comprising:
The process information acquisition module is used for acquiring a target memory range applied by a business process in a system memory and a call stack of the business process;
The memory information inquiry module is used for inquiring the target memory information migrated to the exchange space in the target memory range;
the use condition determining module is used for determining the use condition of the memory based on the target memory information;
And the abnormal information reporting module is used for reporting the call stack to a server side if the memory usage condition indicates that the memory in the idle state exists in the target memory range, and the call stack is used for determining the memory to be released in the target memory range by the server side.
12. A memory release device, the device comprising:
the system comprises a report information acquisition module, a report information acquisition module and a report information processing module, wherein the report information acquisition module is used for receiving a call stack of a target business process reported by a client, the call stack is reported when a memory in an idle state exists in a target memory range represented by a memory use condition of the client, the target memory range is applied for by the target business process in a system memory, and the memory use condition is determined by the client based on target memory information migrated to a switching space in the target memory range;
The memory information acquisition module is used for determining the target memory range applied by the target business process and the corresponding target memory information based on the call stack;
The memory to be released determining module is used for determining the memory to be released in the target memory range based on the target memory information;
and the release instruction sending module is used for sending a memory release instruction to the client based on the memory to be released, so that the client responds to the memory release instruction to release the memory to be released.
13. An electronic device, comprising:
A memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the memory release method of any one of claims 1 to 9 or to perform the memory release method of claim 10.
14. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the memory release method of any one of claims 1 to 9 or to perform the memory release method of claim 10.
15. A computer program product comprising computer instructions for causing a computer to perform the memory release method of any one of claims 1 to 9 or to perform the memory release method of claim 10.
CN202411195247.3A 2024-08-28 2024-08-28 Memory release method, device, equipment, storage medium and program product Pending CN119046007A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411195247.3A CN119046007A (en) 2024-08-28 2024-08-28 Memory release method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411195247.3A CN119046007A (en) 2024-08-28 2024-08-28 Memory release method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN119046007A true CN119046007A (en) 2024-11-29

Family

ID=93575460

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411195247.3A Pending CN119046007A (en) 2024-08-28 2024-08-28 Memory release method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN119046007A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120371724A (en) * 2025-06-26 2025-07-25 浪潮电子信息产业股份有限公司 Memory allocation method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120371724A (en) * 2025-06-26 2025-07-25 浪潮电子信息产业股份有限公司 Memory allocation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110865888B (en) Resource loading method and device, server and storage medium
CN107832100B (en) APK plug-in loading method and terminal thereof
WO2014012504A1 (en) Method, device, and mobile terminal for api interception
WO2018040270A1 (en) Method and device for loading linux-system elf file in windows system
CN112148699B (en) Log management method, device, equipment and medium
CN110928720A (en) Core dump file generation method and device based on Linux system
CN119046007A (en) Memory release method, device, equipment, storage medium and program product
CN111708715B (en) Memory allocation method, memory allocation device and terminal equipment
CN110765394A (en) So file loading method and device, storage medium and terminal equipment
JP2016533588A (en) Storage processing method, apparatus and terminal
CN115481052A (en) A data exchange method and device
CN113254470A (en) Data change method and device, computer equipment and storage medium
CN109408265B (en) IOS abnormal operation protection method and device, terminal equipment and storage medium
CN104298922A (en) Method and device of stopping vulnerability exploiting
CN115202904A (en) Dependent object sharing method, device, equipment and storage medium
CN107844360A (en) A kind of hard disk performs the method and device of application code
CN111258676B (en) Module preloading method, device, equipment and readable storage medium
US9684660B2 (en) File processing method and system
CN115509741B (en) Memory management system, out-of-range detection method and storage medium
CN117708070B (en) File compression method and electronic equipment
EP4528529A1 (en) File processing method and electronic device
CN105610908B (en) A kind of samba service implementing method and system based on Android device
CN119201276B (en) A method, apparatus, storage medium, and electronic device for loading a singleton object.
US20060230190A1 (en) Method and apparatus for executing application in system having NAND flash memory
CN111026452A (en) Method and system for injecting remote 32-bit process into 64-bit process

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