CN108984295B - Memory recovery method, computer device and computer readable storage medium - Google Patents

Memory recovery method, computer device and computer readable storage medium Download PDF

Info

Publication number
CN108984295B
CN108984295B CN201810631223.6A CN201810631223A CN108984295B CN 108984295 B CN108984295 B CN 108984295B CN 201810631223 A CN201810631223 A CN 201810631223A CN 108984295 B CN108984295 B CN 108984295B
Authority
CN
China
Prior art keywords
memory
target buffer
structural body
body data
linked list
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.)
Active
Application number
CN201810631223.6A
Other languages
Chinese (zh)
Other versions
CN108984295A (en
Inventor
李培锋
苏佳佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Allwinner Technology Co Ltd
Original Assignee
Allwinner 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 Allwinner Technology Co Ltd filed Critical Allwinner Technology Co Ltd
Priority to CN201810631223.6A priority Critical patent/CN108984295B/en
Publication of CN108984295A publication Critical patent/CN108984295A/en
Application granted granted Critical
Publication of CN108984295B publication Critical patent/CN108984295B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses a memory recovery method, a computer device and a computer readable storage medium, wherein the method comprises the steps of acquiring information of a target buffer corresponding to an abnormal memory segment when confirming that memory leakage occurs; and searching structural body data corresponding to the target buffer in the isolated memory linked list, and judging whether the leakage frequency in the structural body data corresponding to the target buffer reaches a preset frequency, if so, releasing the memory corresponding to the target buffer. The invention also provides a computer device and a computer readable storage medium for realizing the method. The invention can effectively determine the condition of memory leakage, can realize the recovery of the memory by an effective method when the memory leakage occurs, and can effectively avoid the problem of releasing the memory by mistake.

Description

Memory recovery method, computer device and computer readable storage medium
Technical Field
The present invention relates to the field of memory processing of computers, and in particular, to a memory recycling method, a computer apparatus implementing the method, and a computer-readable storage medium.
Background
Terminal devices such as smart phones and tablet computers become electronic devices which are most frequently used in daily life of people, people like to install various application programs on the smart electronic devices, and a large number of application programs are simultaneously operated on the terminal devices. In addition, various intelligent box products based on the android operating system are generally configured with high-definition video playing software, and each application program occupies certain memory resources, so that after a large number of application programs are run by the terminal device, a large number of memory resources, especially the application programs such as the high-definition playing software, are used, and a continuous large block of physical memory is often applied through a memory management mechanism.
Before the process uses the memory, the process needs to apply for the system and start to occupy the memory, and the memory is timely recycled after the memory is used. Because the memory of the terminal device is limited, the operating system introduces a recovery mechanism for the memory in order to avoid system abnormality caused by insufficient memory allocation. For example, when the memory is insufficient, the system may close some background processes to reclaim the memory occupied by the background processes.
However, with the increasingly complex design and development of the application program of the terminal device, an error occurs during the application program programming, and if the error occurs during the application program programming, the dynamically allocated memory of the application program may not be released in time after the application program is used, and as a result, the application program always occupies the memory space until the program is finished, which is called memory leak.
Once the large continuous memory leaks due to the abnormal application program, the terminal device with low memory is prone to cause a pause phenomenon due to the use shortage of the memory, and even more, the video cannot be played due to the fact that the large memory cannot be applied. Therefore, it is necessary to identify whether the memory leak occurs in the application program by an effective method, and to timely close the application program once the memory leak occurs in the application program, so as to avoid operating system crash caused by the application program continuously occupying a large amount of memory resources.
For example, chinese patent application No. CN201410857700.2 discloses a memory recovery method, which is to use a memory peak value used by a currently running application program as a judgment reference, compare the currently used memory with a memory peak value used by the application program for a period of time in the past, judge whether a memory leak occurs, and recover the memory of the application program when it is determined that the memory leak occurs.
However, the method uses the memory peak value used by the application program as the basis for judgment, and since the application program may occupy a larger memory due to a large amount of operation data when operating normally, the conventional method is prone to occurrence of a memory leak judgment error, and once the judgment error occurs, the memory occupied by the application program is released by an error, the application program is instantly exited, that is, a "flash back" condition occurs, which is not favorable for the operation of the terminal device.
Disclosure of Invention
The invention mainly aims to provide a memory recovery method which can effectively judge whether memory leakage occurs and recover the memory.
Another objective of the present invention is to provide a computer device capable of implementing the above memory recycling method.
It is still another object of the present invention to provide a computer-readable storage medium capable of implementing the memory reclamation method.
In order to achieve the above main object, the memory recovery method provided by the present invention includes obtaining information of a target buffer corresponding to an abnormal memory segment when confirming that a memory leak occurs; and searching structural body data corresponding to the target buffer in the isolated memory linked list, and judging whether the leakage frequency in the structural body data corresponding to the target buffer reaches a preset frequency, if so, releasing the memory corresponding to the target buffer.
According to the scheme, the method comprises the steps of establishing an isolated memory linked list, recording structural body data corresponding to a target buffer corresponding to an abnormal memory segment in the isolated memory linked list, judging whether the memory segment meets the requirement of memory recovery or not through the leakage frequency in the structural body data, and releasing the memory corresponding to the target buffer if the memory segment meets the requirement of memory recovery, and if the leakage frequency reaches the preset frequency. Therefore, the same target buffer is judged for multiple times, so that the occurrence of memory leakage judgment errors can be greatly reduced, and the influence on normally running application programs is effectively avoided.
And by judging the structure data of the same target buffer for multiple times, the memory section meeting the memory recovery condition can be recovered, namely the memory corresponding to the target buffer is released, so that the application program is effectively prevented from occupying the memory for a long time but not being used, the memory of the terminal equipment is effectively recycled, and the normal operation of the terminal equipment is ensured.
In a preferred embodiment, if it is determined that the number of leaks in the structure data corresponding to the target buffer does not reach the preset number, the number of leaks in the structure data corresponding to the target buffer is increased once, and the memory corresponding to the target buffer is not released.
Therefore, for the memory segment which does not meet the memory recovery requirement, the scheme of the invention temporarily does not release the corresponding memory segment, thereby avoiding the wrong memory release for the normal use of the application program and ensuring the operation of the normally operated application program.
Further, the confirming the memory leak includes: when the available memory of the system is lower than a preset memory threshold value, scanning the buffers corresponding to the used memory segments, and judging whether buffers with zero process use number exist or not, if so, confirming that memory leakage occurs.
It can be seen that, by scanning the buffers corresponding to the memory segment and finding out the buffers with zero number of processes, these buffers are the target buffers corresponding to the abnormal memory segment. Since the number of processes used by the memory segments is zero, that is, no process uses the memory, it is possible to determine that the memory segments are abnormal memory segments and determine that a memory leak occurs.
The further scheme is that before searching the structural body data corresponding to the target buffer in the isolated memory linked list, the following steps are also executed: acquiring structural body data in the isolated memory linked list, and determining whether the process use number of a target buffer corresponding to the currently acquired structural body data is zero, if not, deleting the currently acquired structural body data from the isolated memory linked list without releasing a memory corresponding to the target buffer.
Therefore, for the buffers with the process use number not being zero, if the process use of the memory corresponding to the buffers is indicated, the memory is not an abnormal memory, and therefore the memory needs to be deleted from the isolated memory linked list, but the corresponding memory cannot be released, and the normal operation of the application program is prevented from being influenced.
Further, after the memory corresponding to the target buffer is released, the following steps are executed: and deleting the structural body data corresponding to the target buffer from the linked list.
Therefore, after the memory corresponding to the target buffer is released, the corresponding structure data needs to be deleted from the linked list, so that the memory is prevented from being released mistakenly due to the fact that the structure data is continuously used.
The further scheme is that after searching the structural body data corresponding to the target buffer in the isolated memory linked list, the following steps are also executed: and judging whether the structural body data corresponding to the target buffer exists in the isolated memory linked list or not, if not, creating the structural body data corresponding to the target buffer and adding the structural body data to the isolated memory linked list.
Therefore, when the structural body data of the target buffer corresponding to the abnormal memory segment does not exist in the isolated memory linked list, the structural body data of the target buffer is added in the linked list, so that the structural body data of the buffer corresponding to each abnormal memory segment can be ensured to exist in the isolated memory linked list.
Further, after the memory corresponding to the target buffer is released, the following steps are executed: and judging whether request information requesting to use the memory corresponding to the target buffer is received, if so, acquiring a section of memory with the same capacity and providing a sender of the request information.
Further, the sender for obtaining a segment of memory with the same capacity and providing the request information comprises: after a section of memory with the same capacity is obtained, the memory address is converted into a virtual address, and the information of the virtual address is provided for a sender of the request information.
Therefore, after a certain memory segment is released, when the application program applies to use the segment of memory, the memory is provided to the application program by the operation of recovering the memory, for example, by acquiring a new memory segment with equal capacity and providing the virtual address of the new memory segment to the application program, thereby ensuring the normal operation of the application program.
In order to achieve the above another object, the present invention further provides a computer device including a processor and a memory, wherein the memory stores a computer program, and the computer program implements the steps of the memory reclamation method when executed by the processor.
In order to achieve the above-mentioned another object, the present invention further provides a computer readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the memory reclamation method.
Drawings
Fig. 1 is a flowchart illustrating a method for determining memory leakage according to an embodiment of the memory reclamation method of the present invention.
Fig. 2 is a flowchart of an embodiment of a memory reclamation method according to the present invention.
Fig. 3 is a flowchart illustrating recovering released memory according to an embodiment of the memory reclamation method.
The invention is further explained with reference to the drawings and the embodiments.
Detailed Description
The computer device of the present invention may be the electronic device, and the computer readable storage medium may be various storage media having data storage function, including but not limited to non-volatile memories such as F L ASH, EEPROM, and the like.
The embodiment of the memory recovery method comprises the following steps:
an operating system, such as an android operating system, runs on the terminal device to which the memory recovery method of the embodiment is applied. Because the operating system of the existing terminal device is provided with a memory management mechanism of the existing terminal device and is used for managing the memory used by each application program or process, the embodiment is based on the memory management mechanism of the existing operating system, judges whether the memory of the terminal device leaks, and timely recovers the memory when the memory leaks, thereby avoiding the abnormal operation of the terminal device.
Therefore, the method of this embodiment first needs to determine whether a memory leak occurs in the terminal device, and referring to fig. 1, step S1 is executed first to determine that the system triggers a thread with insufficient memory, for example, to trigger a kswap thread of the system, since the L inux system runs, once a situation that the available memory is low occurs, the L inux system will automatically start the kswap thread and adjust the memory through the kswap thread, for example, forcibly close some processes to release the memory.
After the system is determined to trigger the kswap thread, step S2 is executed to scan the continuous available memory of the terminal device, for example, a memory scanning process is called by the operating system, and the process scans the remaining amount of the continuous memory available to the current system, and then step S3 is executed to determine whether the continuous memory available currently is lower than a preset threshold. Since step S2 determines how much continuous memory the system currently has not been used by scanning the continuously available memory of the system, the amount of the remaining continuous memory currently available to the system is determined.
In step S3, the amount of the continuous memory currently available to the system is compared with a preset threshold, and it is determined whether the amount of the continuous memory currently available to the system is lower than the preset threshold, for example, whether the amount of the continuous memory currently available to the system is lower than 100M, if the amount of the continuous memory currently available to the system is lower than the preset threshold, it indicates that the operation of memory reclamation needs to be performed, and if the determination result in step S3 is no, it indicates that the remaining memory currently available to the system is still sufficient and the operation of memory reclamation does not need to be performed.
Under the L inux operating system, each segment of memory segment has a corresponding buffer, and the buffer is used for storing information such as start and stop addresses, memory size, and the like of the segment of memory segment, so step S4 first obtains the buffer corresponding to one segment of memory segment.
Then, step S5 is executed to determine whether the number of processes using the currently acquired memory segment is zero. For example, after the current buffer ION _ buffer is obtained, the ION CMA heap usage of the currently obtained buffer is obtained, such as obtaining the number of processes currently using the memory segment corresponding to the buffer. If a process applies to use the memory segment corresponding to the buffer, the parameter handle _ count corresponding to the buffer is increased by 1, for example, if the parameter handle _ count corresponding to a buffer is 2, it indicates that two processes currently use the memory segment corresponding to the buffer. If the handle _ count corresponding to a buffer is 0, it indicates that a memory leak occurs in the memory segment corresponding to the current buffer, and a memory recovery operation needs to be performed.
Therefore, step S5 is to determine whether the handle _ count corresponding to the currently acquired buffer is zero, and if so, execute step S6, record the target buffer ion _ buffer corresponding to the memory segment, and determine that the memory leak occurs, and the memory segment corresponding to the target buffer is an abnormal memory segment, that is, the memory segment is considered to be a segment of memory in which the memory leak occurs.
Finally, step S7 is executed to determine whether the currently acquired buffer is the buffer corresponding to the last segment of the scanned memory segment, and if not, the buffer corresponding to the next segment of the scanned memory segment is acquired until the buffer corresponding to the last segment of the scanned memory segment is scanned. In this way, by scanning all the memory segments once, the memory segments with the use number of zero of all the processes can be found out, so that the memory segments with possible memory leakage can be determined.
It is to be understood that if the number of processes using multiple segments of memory is zero, it is determined that the multiple segments of memory are all abnormal memory segments, and therefore, in step S6, the segment in which each segment is abnormal is recorded, and therefore, the number of the target buffers ion _ buffer may be one or multiple, and if there are multiple segments of memory, the information of each target buffer is recorded.
After the memory leak is determined to occur, the memory segment with the memory leak needs to be recycled in this embodiment, that is, the memory segment with the zero number of the released processes is used. Referring to fig. 2, step S11 is first executed to confirm that a memory leak occurs, that is, step S6 is executed in fig. 1, and the target buffer ion _ buffer corresponding to the memory segment with zero used by all processes is recorded.
In order to manage and query the target buffers, the embodiment creates an isolated memory linked list cma _ shock _ ordered _ list, which records all target buffers after step S6 in fig. 1, that is, records information of target buffers corresponding to all abnormal memory segments. Therefore, after confirming that the memory leak occurs, step S12 is executed to determine whether the isolated memory linked list cma _ shock _ ordered _ list is empty, that is, whether there is no data in the linked list, if so, step S13 is executed to create structure data, otherwise, step S14 is executed to scan the isolated memory linked list.
If the determination result in the step S12 is yes, it indicates that the isolated memory linked list does not have any data, and the corresponding data of the target buffer recorded in the step S6 needs to be added to the isolated memory linked list. In this embodiment, the data added to the isolated memory linked list is a structural data, for example, cma _ sharker _ t _ count structural data is created, and parameters of the structural data are defined, for example, the structural data includes a plurality of parameters, such as an identifier random of a corresponding target buffer, an address of a corresponding memory segment, and may further include a plurality of variables, such as a size of a corresponding memory segment, and the like, and also includes a number of times try _ time that the target buffer corresponding to the structural data is found to have a leak.
Therefore, step S13 is to create a structure data of cma _ shrinker _ t _ count, and then step S16 is executed to add the data of the abnormal memory segment recorded in step S6 to the structure data to form a structure data corresponding to the target buffer. It is understood that in this embodiment, an abnormal memory segment will correspond to a target buffer and to a structure data. After the structural body data corresponding to the target buffer is created, the created structural body data is added to the isolated memory linked list to become a member of the isolated memory linked list.
If the result of the determination in the step S12 is negative, which indicates that the isolated memory linked list already contains structural body data, then step S14 is executed to scan the isolated memory linked list, that is, traverse each structural body data in the isolated memory linked list, and step S15 is executed to determine whether the target buffer corresponding to the abnormal memory segment recorded in step S6 exists in the isolated memory linked list, if not, step S16 is executed to form a new structural body data according to the information of the target buffer, and the formed structural body data is added to the isolated memory linked list.
If the determination result in the step S15 is yes, structure data corresponding to a target buffer is obtained, and step S17 is executed to determine whether the number of processes used by the memory segment corresponding to the current target buffer is zero, that is, whether a handle _ count corresponding to the target buffer ion _ buffer is 0, if not, it indicates that a process is currently using the memory segment, which indicates that no memory leak occurs in the memory segment, step S18 needs to be executed to remove the structure data corresponding to the target buffer from the isolated memory linked list, and not release the memory corresponding to the target buffer.
Therefore, for a memory segment in use by a process, the memory segment is not released in the embodiment, so that the process in use of the memory is prevented from crashing due to the mistaken release of the memory, and the situation that the application program cannot run normally is prevented.
If the determination result in the step S17 is yes, it indicates that the memory segment corresponding to the current target buffer is not used by any process, then step S19 is executed to determine whether the number of recorded leakage times try _ time in the currently acquired structure data is greater than or equal to the preset number of times. In this embodiment, a preset number of times, such as 3 times or 5 times, is preset. If the recorded leak times try _ time is not greater than or equal to the preset number, step S20 is performed, and the recorded leak times try _ time is increased by 1 time. For example, when the structure data is created, the initial value of try _ time is zero, and after step S20, the value of try _ time is 1, and so on.
If the determination result in the step S19 is yes, it is determined that the memory segment corresponding to the target buffer meets the memory release condition, and step S21 is executed to remove the structure data corresponding to the target buffer from the isolated memory linked list and release the corresponding memory segment. At this time, the released memory segment becomes a memory segment which can be applied for use by other processes or threads, that is, a memory which can be used by the system.
And finally, executing step S22 to determine whether the currently acquired structure data is the last structure data in the isolated memory linked list, if so, ending the process, otherwise, executing step S23 to acquire the next structure data in the isolated memory linked list, returning to execute step S17, and determining whether the number of the memory segment using processes of the target buffer corresponding to the currently acquired structure data is zero.
As can be seen, in the embodiment, the structural body data corresponding to all the memory segments meeting the memory release condition is found out by traversing each member, i.e., each structural body data, in the isolated memory linked list once, and the memory segments corresponding to the structural body data are released, so that the memory is recovered by the terminal device.
In this embodiment, the memory segments corresponding to all the target buffers are not recycled, but the memory segment is recycled only when the number of times of leakage is found to be greater than a preset number of times, for example, 3 times or 5 times, so that a situation that a certain memory segment is mistakenly released because no process is used in a certain time period can be avoided, and thus, a process crash caused by mistakenly releasing the memory can be avoided.
It should be noted that, in this embodiment, only when the system triggers, for example, the kswap process, the determination process for determining whether the memory leak occurs is started, that is, the process of fig. 1 is executed, and after the memory leak is determined to occur, the process for traversing the isolated memory linked list is executed, that is, the process of fig. 2 is executed, and at this time, the number of times try _ time of the leak is found may be increased by 1. That is, only when the kswap process is triggered 3 or 5 times continuously and the number of processes used in the same memory segment is found to be zero each time the buffer is scanned, the release is performed, so that the released memory segment can be effectively ensured to be in a leakage state, and the occurrence of the situation of releasing the memory by mistake can be avoided to the maximum extent.
Of course, if the memory is released by mistake, the process that originally used the segment of the memory may reapply to use the segment of the memory, so the embodiment provides the operation of memory recovery. Referring to fig. 3, step S31 is executed to determine whether information requesting to use the released memory is received. For example, a memory segment is released, and at this time, the memory segment may have been used by other processes, and if a process that originally used the memory segment requests to use the memory segment at this time, information for using the memory segment is issued.
Because the memory segments released by this embodiment are all physical memory, that is, each segment has its own physical address, and the process receives the virtual address instead of the physical address, that is, the process only issues a request for using a certain segment of the virtual address, but not issues a request for using a certain segment of the physical address.
If the determination result in the step S31 is yes, step S32 is executed to obtain a memory segment with the same memory capacity, where it should be noted that the memory segment obtained in the step S32 is a physical memory segment with its own physical address, but is not mapped to a virtual address. Then, step S33 is executed to map the physical address of the acquired memory segment to a virtual address, for example, acquire a virtual address corresponding to the physical address according to the mapping relationship of the memory address. Finally, step S34 is executed to return the information of the virtual address acquired in step S33 to the process requesting to use the released memory. Thus, the process sending the request information will obtain a segment of memory with the same memory capacity as the released memory capacity, only the physical address of the memory changes, but the process use is not affected.
Preferably, when a process issues a request to use a certain memory, it usually includes information of a virtual address of the used memory, so in step S33, the obtained physical memory may be mapped onto the virtual address, and thus, the virtual address returned in step S34 is the information of the virtual address requested to be used by the process. Through the above operation, the virtual address used by the process is not changed, but the physical memory pointed by the virtual address is different, so that the operation of memory recovery is transparent for the process requesting to use the released memory, that is, the process cannot detect that the physical address of the used memory is changed, and thus, the work of the process is not affected.
It can be seen that, in this embodiment, under the condition that the system trigger memory is insufficient, the abnormal memory segment is obtained by scanning the memory, and the memory segment recorded with the memory leak is recovered by creating the isolated memory linked list, so that the abnormal memory segment is quickly and effectively recovered. In addition, the embodiment also limits the execution of the memory recovery operation by setting the recorded leakage times, avoids releasing the memory by mistake, and ensures the work of the application program or the process.
The embodiment of the computer device comprises:
the computer device of the embodiment includes a processor, a memory, and a computer program stored in the memory and executable on the processor, such as an information processing program for implementing the information processing method. The processor implements the steps of the memory recovery method when executing the computer program.
For example, a computer program may be partitioned into one or more modules that are stored in a memory and executed by a processor to implement the modules of the present invention. One or more of the modules may be a series of computer program instruction segments capable of performing certain functions, which are used to describe the execution of the computer program in the terminal device.
It should be noted that the terminal device may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor, a memory. It will be understood by those skilled in the art that the schematic diagram of the present invention is merely an example of a terminal device, and does not constitute a limitation of the terminal device, and may include more or less components than those shown, or combine some components, or different components, for example, the terminal device may further include an input-output device, a network access device, a bus, etc.
The Processor may be a Central Processing Unit (CPU), or may be other general-purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, a discrete hardware component, or the like. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor being the control center of the terminal device and connecting the various parts of the entire terminal device using various interfaces and lines.
The memory may be used to store computer programs and/or modules, and the processor may implement various functions of the terminal device by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
A computer-readable storage medium:
the module integrated with the terminal device may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, all or part of the flow in the method according to the above embodiments may be implemented by a computer program, which may be stored in a computer readable storage medium and used by a processor to implement the steps of the memory recovery methods.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, in accordance with legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunications signals.
Of course, the above-mentioned solution is only a preferred embodiment of the present invention, and the practical application may also have more changes, for example, the parameters set in the structure data may be changed according to the actual request, or the condition for determining the memory leak may be changed to other conditions, such as the remaining memory available to the system is lower than a certain preset value for a long time, and the changes do not affect the implementation of the present invention, and should also be included in the protection scope of the present invention.

Claims (10)

1. The memory recovery method is characterized by comprising the following steps:
when confirming that the memory leaks, acquiring the information of a target buffer corresponding to the abnormal memory segment;
and searching structural body data corresponding to the target buffer in an isolated memory linked list, and judging whether the leakage frequency in the structural body data corresponding to the target buffer reaches a preset frequency, if so, releasing the memory corresponding to the target buffer.
2. The method according to claim 1, wherein:
and if the leakage frequency in the structural body data corresponding to the target buffer is determined not to reach the preset frequency, increasing the leakage frequency in the structural body data corresponding to the target buffer once, and not releasing the memory corresponding to the target buffer.
3. The memory recovery method according to claim 1 or 2, wherein:
the confirming the memory leak comprises: when the available memory of the system is lower than a preset memory threshold value, scanning the buffers corresponding to the used memory segments, and judging whether buffers with zero process use number exist or not, if so, confirming that memory leakage occurs.
4. The memory reclamation method as recited in claim 3, wherein:
before searching the structural body data corresponding to the target buffer in the isolated memory linked list, executing the following steps:
and acquiring one structural body data in the isolated memory linked list, and confirming whether the process using quantity of a target buffer corresponding to the currently acquired structural body data is zero, if not, deleting the currently acquired structural body data from the isolated memory linked list, and not releasing the memory corresponding to the target buffer.
5. The memory recovery method according to claim 1 or 2, wherein:
after releasing the memory corresponding to the target buffer, executing: and deleting the structural body data corresponding to the target buffer from the isolated memory linked list.
6. The memory recovery method according to claim 1 or 2, wherein:
after searching the structural body data corresponding to the target buffer in the isolated memory linked list, executing the following steps: and judging whether the structural body data corresponding to the target buffer exists in the isolated memory linked list or not, and if not, creating the structural body data corresponding to the target buffer and adding the structural body data to the isolated memory linked list.
7. The memory recovery method according to claim 1 or 2, wherein:
after releasing the memory corresponding to the target buffer, executing:
and judging whether request information requesting to use the memory corresponding to the target buffer is received, if so, acquiring a section of memory with the same capacity and providing a sender of the request information.
8. The method according to claim 7, wherein:
the sender for obtaining a section of memory with the same capacity and providing request information comprises the following steps: after a section of memory with the same capacity is obtained, the memory address is converted into a virtual address, and the information of the virtual address is provided for a sender of the request information.
9. Computer arrangement, characterized in that it comprises a processor and a memory, said memory storing a computer program that, when executed by the processor, performs the steps of the memory reclamation method as recited in any one of claims 1 to 8.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program, when executed by a processor, implements the steps of the memory reclamation method as recited in any one of claims 1 to 8.
CN201810631223.6A 2018-06-19 2018-06-19 Memory recovery method, computer device and computer readable storage medium Active CN108984295B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810631223.6A CN108984295B (en) 2018-06-19 2018-06-19 Memory recovery method, computer device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810631223.6A CN108984295B (en) 2018-06-19 2018-06-19 Memory recovery method, computer device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN108984295A CN108984295A (en) 2018-12-11
CN108984295B true CN108984295B (en) 2020-08-07

Family

ID=64540741

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810631223.6A Active CN108984295B (en) 2018-06-19 2018-06-19 Memory recovery method, computer device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN108984295B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110532198B (en) * 2019-09-09 2023-08-08 成都西山居互动娱乐科技有限公司 Storage space allocation method and device
CN111782560A (en) * 2020-07-10 2020-10-16 Oppo广东移动通信有限公司 Memory recovery method and device, terminal equipment and storage medium
CN112423104A (en) * 2020-09-02 2021-02-26 上海幻电信息科技有限公司 Audio mixing method and system for multi-channel audio in live scene
CN111966603B (en) * 2020-09-04 2024-01-19 网易(杭州)网络有限公司 Memory leakage detection method and device, readable storage medium and electronic equipment
CN113986559B (en) * 2021-12-24 2022-06-24 荣耀终端有限公司 Memory management method and related device

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1994004976A1 (en) * 1992-08-14 1994-03-03 Noblenet, Inc. Client-side memory management process and system for client-server computing
US7398369B2 (en) * 2004-10-28 2008-07-08 International Business Machines Corporation Memory leakage management
CN101908018A (en) * 2010-07-20 2010-12-08 北京海泰方圆科技有限公司 System and method for judging memory leak
CN102053868A (en) * 2009-11-04 2011-05-11 突触计算机系统(上海)有限公司 Memory leak detection method and device
US8881164B2 (en) * 2011-10-18 2014-11-04 Hewlett-Packard Development Company, L.P. Computer process with utilization reduction
CN104182320A (en) * 2013-05-23 2014-12-03 联想(北京)有限公司 Method and device for monitoring leakage of memory
CN106547617A (en) * 2015-09-18 2017-03-29 李鹤 A kind of EMS memory management process and system using analysis-feedback-tuning pattern
CN106610892A (en) * 2015-10-23 2017-05-03 腾讯科技(深圳)有限公司 Memory leak detecting method and device
CN106844159A (en) * 2017-02-03 2017-06-13 广东欧珀移动通信有限公司 A kind of information acquisition method, device and intelligent terminal
CN106844216A (en) * 2017-01-25 2017-06-13 深圳怡化电脑股份有限公司 The localization method and system of a kind of RAM leakage
CN107145447A (en) * 2017-05-09 2017-09-08 网易(杭州)网络有限公司 Detect method, device and the electronic equipment of memory overflow
CN107609199A (en) * 2017-10-24 2018-01-19 网易无尾熊(杭州)科技有限公司 A kind of method, equipment and storage medium for handling and recovering the page
CN107957950A (en) * 2017-12-08 2018-04-24 锐捷网络股份有限公司 A kind of detection method and device of system resource leakage
CN108073439A (en) * 2016-11-11 2018-05-25 深圳业拓讯通信科技有限公司 A kind of JVM RAM leakages automatic testing method and system

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1994004976A1 (en) * 1992-08-14 1994-03-03 Noblenet, Inc. Client-side memory management process and system for client-server computing
US7398369B2 (en) * 2004-10-28 2008-07-08 International Business Machines Corporation Memory leakage management
CN102053868A (en) * 2009-11-04 2011-05-11 突触计算机系统(上海)有限公司 Memory leak detection method and device
CN101908018A (en) * 2010-07-20 2010-12-08 北京海泰方圆科技有限公司 System and method for judging memory leak
US8881164B2 (en) * 2011-10-18 2014-11-04 Hewlett-Packard Development Company, L.P. Computer process with utilization reduction
CN104182320A (en) * 2013-05-23 2014-12-03 联想(北京)有限公司 Method and device for monitoring leakage of memory
CN106547617A (en) * 2015-09-18 2017-03-29 李鹤 A kind of EMS memory management process and system using analysis-feedback-tuning pattern
CN106610892A (en) * 2015-10-23 2017-05-03 腾讯科技(深圳)有限公司 Memory leak detecting method and device
CN108073439A (en) * 2016-11-11 2018-05-25 深圳业拓讯通信科技有限公司 A kind of JVM RAM leakages automatic testing method and system
CN106844216A (en) * 2017-01-25 2017-06-13 深圳怡化电脑股份有限公司 The localization method and system of a kind of RAM leakage
CN106844159A (en) * 2017-02-03 2017-06-13 广东欧珀移动通信有限公司 A kind of information acquisition method, device and intelligent terminal
CN107145447A (en) * 2017-05-09 2017-09-08 网易(杭州)网络有限公司 Detect method, device and the electronic equipment of memory overflow
CN107609199A (en) * 2017-10-24 2018-01-19 网易无尾熊(杭州)科技有限公司 A kind of method, equipment and storage medium for handling and recovering the page
CN107957950A (en) * 2017-12-08 2018-04-24 锐捷网络股份有限公司 A kind of detection method and device of system resource leakage

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Effect of Heat-treatment Time on Performance Recovery of Ti-50.4at%Ni Shape Memory Alloy;H. Cho等;《Effect of Heat-treatment Time on Performance Recovery of Ti-50.4at%Ni Shape Memory Alloy》;20121231;第37卷(第4期);全文 *
面向隐私保护的数据块调整机制;史玉良等;《计算机学报》;20171231;第40卷(第12期);全文 *

Also Published As

Publication number Publication date
CN108984295A (en) 2018-12-11

Similar Documents

Publication Publication Date Title
CN108984295B (en) Memory recovery method, computer device and computer readable storage medium
US11853549B2 (en) Index storage in shingled magnetic recording (SMR) storage system with non-shingled region
US20150317246A1 (en) Memory Reclamation Method and Apparatus
CN107066498B (en) Key value KV storage method and device
US9069477B1 (en) Reuse of dynamically allocated memory
CN111522659B (en) Space use method and device
CN113342507B (en) Distributed lock service realization method and device and computer equipment
CN114168490A (en) Method for determining memory recovery threshold and related equipment
CN115543643A (en) Distributed lock reentry execution method, device, equipment and readable storage medium
US9274946B2 (en) Pre-leak detection scan to identify non-pointer data to be excluded from a leak detection scan
CN110334034B (en) Mapping table dynamic loading method and device, computer equipment and storage medium
CN109032762B (en) Virtual machine backtracking method and related equipment
CN111651443A (en) Data management method and device, electronic equipment and storage medium
CN115729702A (en) Application program memory configuration method, electronic device and computer storage medium
CN109271538A (en) A kind of picture storage method and relevant device
CN116860427A (en) Resource recovery method and device
CN108090128A (en) A kind of merging memory space recovery method, device and electronic equipment
CN109343953B (en) Memory management method and device and electronic equipment
US11003578B2 (en) Method and system for parallel mark processing
CN112035253A (en) Linux system page cache recovery method and related device
CN112015672A (en) Data processing method, device, equipment and storage medium in storage system
CN106959888B (en) Task processing method and device in cloud storage system
CN111679909A (en) Data processing method and device and terminal equipment
CN111143418A (en) Data reading method, device and equipment for database and storage medium
CN115509763B (en) Fingerprint calculation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant