CN110737604A - method, device, electronic equipment and storage medium for automatically cleaning memory - Google Patents

method, device, electronic equipment and storage medium for automatically cleaning memory Download PDF

Info

Publication number
CN110737604A
CN110737604A CN201910817805.8A CN201910817805A CN110737604A CN 110737604 A CN110737604 A CN 110737604A CN 201910817805 A CN201910817805 A CN 201910817805A CN 110737604 A CN110737604 A CN 110737604A
Authority
CN
China
Prior art keywords
file
expired
files
deleted
preset
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
CN201910817805.8A
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 QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201910817805.8A priority Critical patent/CN110737604A/en
Publication of CN110737604A publication Critical patent/CN110737604A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1737Details of further file system functions for reducing power consumption or coping with limited storage space, e.g. in mobile devices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Storage Device Security (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to methods, devices, electronic equipment and storage media for automatically cleaning a memory, wherein the method comprises the steps of determining a file meeting a preset expiration condition as an expired file in files of an application program stored in a terminal, screening the expired file meeting the preset cleaning condition from the expired file as a file to be deleted when the remaining space of the terminal is smaller than a preset threshold value, and deleting the file to be deleted.

Description

method, device, electronic equipment and storage medium for automatically cleaning memory
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to methods and devices for automatically cleaning a memory, an electronic device and a storage medium.
Background
With the rapid development of mobile internet technology, various APPs (applications) on terminal devices such as mobile phones and tablet computers are increasing.
A lot of cache data can be generated in the process that a user uses various APPs, and the cache data is generated more and more along with the increase of the use duration and is stored in the memory of the terminal. This results in less and less space being available in the memory, which results in slower and slower operation of the terminal.
According to the prior art, cache data in a memory is cleaned, is that a user downloads memory management software in a terminal device, the software can read all files, pictures or documents in the terminal device, when some files or pictures need to be deleted, the user can manually select the files or pictures needing to be deleted in the software, and then the terminal cleans the selected contents.
The above description of the discovery process of the problems is only for the purpose of assisting understanding of the technical solutions of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
In order to solve the above technical problem or at least partially solve the above technical problem, an embodiment of the present invention provides methods, apparatuses, electronic devices, and storage media for automatically cleaning a memory.
According to , there are provided methods for automatically cleaning memory, including:
determining a file meeting a preset expiration condition as an expired file from files of application programs stored in a terminal;
when the residual space of the terminal is smaller than a preset threshold value, selecting an expired file meeting a preset cleaning condition from the expired files as a file to be deleted;
and deleting the file to be deleted.
Further , the determining, as an expired file, a file in the application program that meets a preset expiration condition, among the files of the application program stored in the terminal, includes:
acquiring the last operation time of a file in an application program;
obtaining the unused time length of the file according to the time interval between the last operation time and the current time;
and if the unused time of the file is greater than a preset time threshold, determining that the file is an expired file.
, when the remaining space of the terminal is less than a preset threshold, selecting an expired file meeting a preset cleaning condition from the expired files as a file to be deleted, including:
determining a file identifier of the expired file;
storing the file identifications of all expired files and the mapping relation between the file identifications and the expired files into an expired folder;
sorting the file identifications from big to small according to the unused duration of the expired files to obtain a file identification sequence;
when the residual space of the terminal is smaller than a preset threshold value, screening a preset number of file identifications from front to back in the file identification sequence;
and taking the expired files corresponding to the preset number of file identifications obtained by screening as files to be deleted.
Further , determining the file identification of the expired file includes:
calculating a path of the expired file stored in the terminal to obtain a path identification code;
and taking the path identification code as the file identification of the expired file.
And , deleting the file to be deleted, which comprises:
creating a file operation thread;
and deleting the file to be deleted through the file operation thread.
According to a second aspect of the embodiments of the present disclosure, there is provided apparatus for automatically cleaning memory, including:
the determining module is used for determining a file meeting a preset expiration condition as an expired file in files for acquiring the application program stored in the terminal;
the screening module is used for screening the expired files meeting the preset cleaning condition from the expired files as files to be deleted when the residual space of the terminal is smaller than a preset threshold;
and the deleting module is used for deleting the file to be deleted.
Further , the determining module includes:
the acquisition submodule is used for acquiring the last operation time of the file in the application program;
, a determining submodule, configured to obtain an unused duration of the file according to a time interval between the last operation time and the current time;
and the judging submodule is used for judging the file to be an expired file if the unused time of the file is greater than a preset time threshold.
Further , the screening module includes:
the second determining submodule is used for determining the file identification of the expired file;
the storage submodule is used for storing the file identifications of all expired files and the mapping relation between the file identifications and the expired files into an expired folder;
the sorting submodule is used for sorting the file identifications from big to small according to the unused duration of the expired files to obtain a file identification sequence;
the screening submodule is used for screening a preset number of file identifications from front to back in the file identification sequence when the residual space of the terminal is smaller than a preset threshold value;
and the third determining submodule is used for taking the expired files corresponding to the preset number of the file identifications obtained by screening as files to be deleted.
, the second determining submodule, configured to,
calculating a path of the expired file stored in the terminal to obtain a path identification code;
and taking the path identification code as the file identification of the expired file.
Further , the delete module includes:
the creating submodule is used for creating a file operation thread;
and the deletion submodule is used for deleting the file to be deleted through the file operation thread.
According to a third aspect of the embodiments of the present application, there are provided electronic devices, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor configured to implement the method steps of any of described above when executing a program stored in the memory.
According to a fourth aspect of the embodiments of the present application, there are storage media having stored thereon a program of a method for automatically clearing memory, the program of the method for automatically clearing memory implementing the steps of the method for automatically clearing memory described in any above when being executed by a processor.
Compared with the closest prior art, the embodiment of the invention firstly determines the files meeting the preset conditions as the expired files in the files of the application program stored in the terminal, then screens the expired files meeting the preset cleaning conditions from the expired files as the files to be deleted when the residual space of the terminal is less than the preset threshold value, and finally deletes the files to be deleted. According to the scheme, the files meeting the conditions are used as the expired files, and then the files to be deleted in the expired files are deleted when the terminal residual space is smaller than the preset threshold value.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a flow diagram illustrating a method for automatically cleaning memories according to an exemplary embodiment of ;
FIG. 2 is a flowchart illustrating a method of determining stale files according to an exemplary embodiment of ;
FIG. 3 is a flowchart illustrating a method for filtering files to be deleted from stale files according to an exemplary embodiment at ;
FIG. 4 is a flowchart illustrating a method of deleting a file to be deleted according to an exemplary embodiment at ;
FIG. 5 is an overall flow diagram illustrating a method for automatically cleaning memory in accordance with an exemplary embodiment at ;
FIG. 6 is a block diagram illustrating the structure of automatically scrubbing memory according to an exemplary embodiment at ;
FIG. 7 is a schematic diagram of the fault warning devices shown in accordance with an exemplary embodiment of ;
fig. 8 is a schematic structural diagram of electronic devices shown according to an exemplary embodiment.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all embodiments of the present invention.
A mobile client implementing various embodiments of the present invention will now be described with reference to the accompanying drawings. In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for facilitating the explanation of the present invention, and have no specific meaning in themselves. Thus, "module" and "component" may be used in a mixture.
The main body of execution of each step of the present application is a terminal. The terminal device may be a mobile terminal such as a mobile phone, a tablet computer, a notebook computer, a palm top computer, a PAD (Personal Digital Assistant), a PMP (portable multimedia Player), a navigation device, etc., and a fixed terminal such as a Digital TV, a desktop computer, etc.
The embodiment of the invention provides methods for automatically cleaning a memory, and as shown in fig. 1, a flow chart of methods for automatically cleaning a memory is shown in the embodiment of the invention.
In step S101, among the files of the application stored in the terminal, a file satisfying a preset expiration condition is determined as an expired file.
For example, if a certain file is not used for more than preset time periods, that is, the file is not added with new content for more than the preset time period, it indicates that the file is not used for a long time, and the file can be used as an expired file.
And determining all files meeting the preset expiration condition as expired files from the files of the application program stored in the terminal according to the determination mode of the preset expiration condition. That is, the determination of the expired file occurs in real time, and any file satisfying the preset expiration condition is regarded as the expired file.
In step S102, when the remaining space of the terminal is smaller than a preset threshold, selecting an expired file meeting a preset cleaning condition from the expired files as a file to be deleted.
In the embodiment of the present invention, the preset cleaning condition may refer to an expired file with an unused time length longer than a preset time length threshold, or may refer to a preset number of expired files with a maximum unused time length. And when the residual space of the terminal is smaller than a preset threshold value, namely the internal memory of the terminal is small and the running speed is low, screening the expired files meeting the preset cleaning condition from all the expired files as files to be deleted.
In the embodiment of the invention, the file meeting the preset expiration condition is taken as the expired file, the terminal can detect the file meeting the preset expiration condition in real time and determine the file as the expired file. And when the residual space of the terminal is smaller than a preset threshold value, screening the expired files meeting the preset cleaning condition from the expired files to serve as files to be deleted. By determining the expired files and screening the files to be deleted from the expired files, the terminal can quickly find and delete the files to be deleted when the remaining space of the terminal is small, the calculation amount is small, and the deleting efficiency is high.
Further , the obsolete files may be filtered among the obsolete files by a page replacement algorithm, which is a rule used to select obsolete files, the page replacement algorithm including a variety of algorithms, such as a best replacement algorithm, a first-in-first-out replacement algorithm, a least recently used algorithm (LRU), and the like.
In step S103, the file to be deleted is deleted.
According to the embodiment of the invention, the files meeting the preset condition are firstly obtained from the files of the application program stored in the terminal and are determined as the expired files, then when the residual space of the terminal is smaller than the preset threshold value, the expired files meeting the preset cleaning condition are screened from the expired files and are used as the files to be deleted, and finally the files to be deleted are deleted. According to the scheme, the files meeting the conditions are used as the expired files, and then the files to be deleted in the expired files are deleted when the terminal residual space is smaller than the preset threshold value.
In possible embodiments of the present invention, as shown in fig. 2, a flowchart of a method for determining an expired file is shown in an embodiment of the present invention.
In step S201, the last operation time of the file in the application is acquired.
In the embodiment of the present invention, the last operation time of the file refers to the last time when the user operates or browses a certain page or file, that is, from this time, the user does not have any operation or browsing on the corresponding page or file.
Specifically, the last operation time may be obtained from the storage path information of the file of the application program stored in the terminal, that is, the time of file generation may be saved at the same time when the file is generated. If the file has the operation of adding content or modifying or deleting content in the subsequent process, the operation time is the last operation time, and if the file has no operation, the generation time of the file is the last operation time.
In step S202, the unused duration of the file is obtained according to the time interval between the last operation time and the current time.
In the embodiment of the invention, the time interval between the time when the user last operates the file and the current time is calculated, and time durations are calculated, wherein the time duration is the unused time duration of the file.
In step S203, if the unused time of the file is greater than the preset time threshold, the file is determined to be an expired file.
In the embodiment of the present invention, the unused time calculated in the above steps is compared with a preset time threshold, and if the unused time is greater than the preset time threshold, the file is an expired file.
The preset time length threshold value can be determined according to the type and number of application programs installed on the user terminal equipment, the use time length of the user on the terminal equipment and the like, and can also be determined according to other conditions.
For example, at the time t0 of creating a folder in an application, the expiration time is set to t2, the time point of expiration is t 1-t 0+ t2, after the time point t1, recursive access is performed on the folder, and a file meeting a preset expiration condition in the search is used as an expired file.
In possible embodiments of the present invention, as shown in fig. 3, there is a flowchart illustrating a method for filtering files to be deleted from expired files according to an embodiment of the present invention.
In step S301, a file identifier of the expired file is determined.
In an embodiment of the present invention, determining the file identifier of the expired file specifically includes: and calculating the path of the expired file determined in the step at the terminal to obtain the path identification code of the expired file, wherein the path identification code is the file identification of the expired file.
, performing times of message digest algorithm or hash transformation on the path of the expired file determined in the above steps stored in the terminal to generate a file identifier (key) corresponding to the expired file, and obtaining a mapping relationship (key-value) between the file identifier and the expired file, thereby facilitating subsequent searching of the expired file to be deleted.
In step S302, the file identifiers of all expired files and the mapping relationship between the file identifiers and the expired files are saved in an expired folder.
In the embodiment of the present invention, the file identifiers of all expired files obtained in the step are stored in expired folders, and the mapping relationship between the file identifiers obtained in the step and the expired files is also stored in the expired folders, so as to facilitate subsequent searching.
In step S303, according to the size of the unused time of the expired file, the file identifiers are sorted from large to small according to the unused time to obtain a file identifier sequence.
In the embodiment of the present invention, the obtained file identifiers of the expired files are sorted from large to small according to the size of the unused time length of the expired files corresponding to the file identifiers, so as to obtain file identifier sequences.
In step S304, when the remaining space of the terminal is smaller than a preset threshold, a preset number of file identifiers are filtered from front to back in the file identifier sequence.
In the embodiment of the present invention, when the terminal detects that the remaining memory space is smaller than the preset threshold, that is, when the memory is insufficient, expired files need to be deleted to increase the memory size of the terminal, at this time, the previous preset number of file identifiers in the obtained file identifier sequence are screened, that is, the file identifiers corresponding to the preset number of expired files with the longest unused time are screened from the expired folder.
Specifically, the file identifier with the longest storage time can be screened from the expired folders obtained in step by a page replacement algorithm.
In step S305, the expired files corresponding to the preset number of file identifiers obtained by screening are used as files to be deleted.
In the embodiment of the present invention, the expired file is found according to the file identifier obtained in the step and the mapping relationship between the file identifier and the expired file, and the expired file is used as the file to be deleted.
In the embodiment of the present invention, in order not to affect the normal use of the user, the file screening operation is performed in an inactive stage of the application program (for example, in a background state, a screen lock state, or a scenario where the generated interaction is simple). Because the writing operation of the file is not involved, the use of the user caused by the thread safety problem can not occur.
By determining the expired files and screening the files to be deleted from the expired files, the terminal can quickly find and delete the files to be deleted when the remaining space of the terminal is small, the calculation amount is small, and the deleting efficiency is high.
In possible embodiments of the present invention, as shown in fig. 4, there is a flowchart illustrating a method for deleting a file to be deleted according to an embodiment of the present invention.
In step S401, a file operation thread is created.
In step S402, the file to be deleted is deleted by the file operation thread.
In the embodiment of the present invention, a file operation thread clearupfilethread, CFT for short, is created first, and since the problem to be solved for deleting a file is to ensure thread security, all modification (e.g., deletion, addition, etc.) operations are performed in the file operation thread. And when the file to be deleted needs to be deleted, deleting the file to be deleted through the file operation thread.
, the modification operation of the file cannot be performed by multiple threads simultaneously, and therefore, a mutual exclusion lock mode is required to be used for protection of the modification operation, that is, the file to be modified is locked, and the reading and writing of the file can only be performed by threads.
Fig. 5 is a flowchart illustrating an overall method for automatically cleaning a memory according to an embodiment of the present invention. Fig. 6 is a block diagram illustrating a structure of automatically cleaning a memory according to an embodiment of the present invention.
In the embodiment of the invention, when the application program has three services, namely service A, service B and service C, folder A, folder B and folder C are generated correspondingly. And starting asynchronous screening operation at the moment, determining the files meeting the preset expiration condition, if the files meeting the expiration condition exist, generating file identifications of the expired files according to Hash transformation, putting the files into a cache pool, filtering according to LRU, searching the file identifications, searching the files to be deleted according to the file identifications, and deleting the files to be deleted through a file operation thread.
Based on the same inventive concept as the method, in another embodiments of the present application, apparatuses for automatically cleaning memory are further disclosed, as shown in fig. 7, the apparatuses for automatically cleaning memory include a determining module 101, a screening module 102, and a deleting module 103.
The determining module 101 is configured to determine, as an expired file, a file satisfying a preset expiration condition among files of applications stored in the terminal.
The screening module 102 is configured to screen expired files meeting a preset cleaning condition from the expired files as files to be deleted when the remaining space of the terminal is smaller than a preset threshold.
The deletion module 103 is configured to delete the file to be deleted.
In possible embodiments of the present invention, the determining module 101 specifically includes an obtaining sub-module, a th determining sub-module, and a determining sub-module.
The obtaining sub-module is configured to obtain a last operation time of a file in the application program.
The th determination submodule is configured to obtain the unused time length of the file according to the time interval between the last operation time and the current time.
The judging submodule is configured to judge the file to be an expired file if the unused time of the file is greater than a preset time threshold.
In possible embodiments of the present invention, the screening module 102 specifically includes a second determining sub-module, a saving sub-module, a sorting sub-module, a screening sub-module, and a third determining sub-module.
The second determining submodule is configured to determine a file identity of the expired file.
The saving submodule is configured to save the file identifications of all expired files and the mapping relation between the file identifications and the expired files into an expired folder.
The sorting submodule is configured to sort the file identifiers according to the unused duration of the expired files from large to small to obtain a file identifier sequence.
The screening submodule is configured to screen a preset number of file identifications from front to back in the file identification sequence when the remaining space of the terminal is smaller than a preset threshold.
The third determining submodule is configured to take the expired files corresponding to the preset number of the screened file identifications as files to be deleted.
In possible embodiments of the invention, the second determination submodule, in particular for,
calculating a path of the expired file stored in the terminal to obtain a path identification code;
and taking the path identification code as the file identification of the expired file.
In possible embodiments of the present invention, the delete module 103 specifically includes a create sub-module and a delete sub-module.
The creating submodule is configured to create a file operation thread;
the deleting submodule is configured to delete the file to be deleted through the file operating thread.
In another embodiment of the present application, kinds of electronic devices are further provided, as shown in fig. 8, including a processor 501, a communication interface 502, a memory 503, and a communication bus 504, where the processor 501, the communication interface 502, and the memory 503 complete communications with each other through the communication bus 504;
a memory 503 for storing a computer program;
the processor 501, when executing the program stored in the memory 503, implements the following steps:
determining a file meeting a preset expiration condition as an expired file from files of application programs stored in a terminal;
when the residual space of the terminal is smaller than a preset threshold value, selecting an expired file meeting a preset cleaning condition from the expired files as a file to be deleted;
and deleting the file to be deleted.
In the embodiment of the invention, firstly, files meeting preset conditions are determined as expired files from the files of the application program stored in the terminal, then when the residual space of the terminal is smaller than a preset threshold value, the expired files meeting preset cleaning conditions are screened from the expired files as files to be deleted, and finally the files to be deleted are deleted. According to the scheme, the files meeting the conditions are used as the expired files, and then the files to be deleted in the expired files are deleted when the terminal residual space is smaller than the preset threshold value.
, determining files meeting preset expiration conditions as expired files from the files of the application stored in the terminal, specifically including:
and acquiring the last operation time of the file in the application program.
In the embodiment of the present invention, the last operation time of the file refers to the last time when the user operates or browses a certain page or file, that is, from this time, the user does not have any operation or browsing on the corresponding page or file.
And obtaining the unused time length of the file according to the time interval between the last operation time and the current time.
In the embodiment of the invention, the time interval between the time when the user last operates the file and the current time is calculated, and time durations are calculated, wherein the time duration is the unused time duration of the file.
And if the unused time of the file is greater than a preset time threshold, determining that the file is an expired file.
In the embodiment of the present invention, the unused time calculated in the above steps is compared with a preset time threshold, and if the unused time is greater than the preset time threshold, the file is an expired file.
The preset time length threshold value can be determined according to the type and number of application programs installed on the user terminal equipment, the use time length of the user on the terminal equipment and the like, and can also be determined according to other conditions.
, when the remaining space of the terminal is smaller than a preset threshold, screening the expired files meeting preset cleaning conditions from the expired files as files to be deleted, specifically comprising:
and determining the file identification of the expired file.
In the embodiment of the invention, the path of the expired file determined in the above steps stored in the terminal is calculated to obtain the path identification code of the expired file, and the path identification code is the file identifier of the expired file.
, performing times of message digest algorithm or hash transformation on the path of the expired file determined in the above steps stored in the terminal to generate a file identifier corresponding to the expired file, and obtaining the mapping relationship between the file identifier and the expired file, thereby facilitating the subsequent search of the expired file to be deleted.
And storing the file identifications of all expired files and the mapping relation between the file identifications and the expired files into an expired folder.
In the embodiment of the present invention, the file identifiers of all expired files obtained in the step are stored in expired folders, and the mapping relationship between the file identifiers obtained in the step and the expired files is also stored in the expired folders, so as to facilitate subsequent searching.
And sequencing the file identifications from large to small according to the unused duration of the expired files to obtain a file identification sequence.
In the embodiment of the present invention, the obtained file identifiers of the expired files are sorted from large to small according to the size of the unused time length of the expired files corresponding to the file identifiers, so as to obtain file identifier sequences.
And when the residual space of the terminal is smaller than a preset threshold value, screening a preset number of file identifications from front to back in the file identification sequence.
In the embodiment of the present invention, when the terminal detects that the remaining memory space is smaller than the preset threshold, that is, when the memory is insufficient, expired files need to be deleted to increase the memory size of the terminal, at this time, the previous preset number of file identifiers in the obtained file identifier sequence are screened, that is, the file identifiers corresponding to the preset number of expired files with the longest unused time are screened from the expired folder.
Specifically, the file identifier with the longest storage time can be screened from the expired folders obtained in step by a page replacement algorithm.
And taking the expired files corresponding to the preset number of file identifications obtained by screening as files to be deleted.
In the embodiment of the present invention, the expired file is found according to the file identifier obtained in the step and the mapping relationship between the file identifier and the expired file, and the expired file is used as the file to be deleted.
Deleting the file to be deleted specifically comprises the following steps:
creating a file operation thread;
and deleting the file to be deleted through the file operation thread.
In the embodiment of the invention, a file operation thread is created first, and since the problem to be solved for deleting the file is to ensure thread safety, all modification (such as deletion, addition and the like) operations are performed in the file operation thread. And when the file to be deleted needs to be deleted, deleting the file to be deleted through the file operation thread.
The communication bus 504 mentioned above for the electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. the communication bus 504 may be divided into an address bus, a data bus, a control bus, etc. for convenience of representation, only bold lines are used in fig. 8, but not only buses or types of buses are represented.
The communication interface 502 is used for communication between the above-described electronic apparatus and other apparatuses.
The Memory 503 may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least disk memories, and optionally, at least storage devices located remotely from the processor.
The Processor 501 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Array (FPGA), other Programmable logic devices, a discrete , a transistor logic device, and discrete hardware components.
In another embodiment of the present application, storage media are further provided, and the storage media store a program of the method for automatically clearing memory, which when executed by a processor implements the steps of the method for automatically clearing memory of any .
When the embodiment of the invention is specifically implemented, reference can be made to the above embodiments, and corresponding technical effects are achieved.
For a hardware implementation, the Processing units may be implemented within or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable arrays (FPGAs), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units configured to perform the functions described herein, or a combination thereof.
For a software implementation, the techniques described herein may be implemented by means of units performing the functions described herein. The software codes may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units into logical functional divisions may be realized in other ways, for example, multiple units or components may be combined or integrated into another systems, or features may be omitted or not executed, and at point , the shown or discussed coupling or direct coupling or communication connection between each other may be through interfaces, and the indirect coupling or communication connection between the apparatuses or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, that is, may be located in places, or may also be distributed on multiple network units.
In addition, functional units in the embodiments of the present invention may be integrated into processing units, or each unit may exist alone physically, or two or more units are integrated into units.
Based on the understanding that the technical solution of the embodiments of the present invention, in essence or a part contributing to the prior art, or a part of the technical solution, can be embodied in the form of a software product stored in storage media, which includes several instructions for making computer devices (which may be personal computers, servers, or network devices, etc.) execute all or part of the steps of the methods described in the embodiments of the present invention.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises an series of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
It is noted that, herein, relational terms such as "," "second," and the like are used solely to distinguish entities or operations from another entities or operations without necessarily requiring or implying any actual such relationship or order between such entities or operations.
Based on the understanding that the technical solutions of the present invention per se or those contributing to the prior art can be embodied in the form of software products stored in storage media (such as ROM/RAM, magnetic disk, optical disk) and including instructions for causing client devices (which may be mobile phones, computers, servers, air conditioners, or network devices) to execute the methods described in the embodiments or the methods described in some parts of the embodiments.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (12)

1, A method for automatically cleaning internal memory, comprising:
determining a file meeting a preset expiration condition as an expired file from files of application programs stored in a terminal;
when the residual space of the terminal is smaller than a preset threshold value, selecting an expired file meeting a preset cleaning condition from the expired files as a file to be deleted;
and deleting the file to be deleted.
2. The method for automatically cleaning internal memory according to claim 1, wherein the determining files meeting preset expiration conditions as expired files in the files of the application stored in the terminal includes:
acquiring the last operation time of a file in an application program;
obtaining the unused time length of the file according to the time interval between the last operation time and the current time;
and if the unused time of the file is greater than a preset time threshold, determining that the file is an expired file.
3. The method for automatically cleaning memory, according to claim 1, wherein when the remaining space of the terminal is less than a preset threshold, selecting the expired files meeting preset cleaning conditions from the expired files as files to be deleted includes:
determining a file identifier of the expired file;
storing the file identifications of all expired files and the mapping relation between the file identifications and the expired files into an expired folder;
sorting the file identifications from big to small according to the unused duration of the expired files to obtain a file identification sequence;
when the residual space of the terminal is smaller than a preset threshold value, screening a preset number of file identifications from front to back in the file identification sequence;
and taking the expired files corresponding to the preset number of file identifications obtained by screening as files to be deleted.
4. The method of automatically cleaning memory according to claim 3, wherein determining the file id of the expired file comprises:
calculating a path of the expired file stored in the terminal to obtain a path identification code;
and taking the path identification code as the file identification of the expired file.
5. The method for automatically cleaning internal memory, according to claim 1, wherein deleting the file to be deleted includes:
creating a file operation thread;
and deleting the file to be deleted through the file operation thread.
An apparatus for automatically cleaning memory of , comprising:
the determining module is used for determining files meeting preset expiration conditions as expired files in the files of the application programs stored in the terminal;
the screening module is used for screening the expired files meeting the preset cleaning condition from the expired files as files to be deleted when the residual space of the terminal is smaller than a preset threshold;
and the deleting module is used for deleting the file to be deleted.
7. The apparatus for automatically clearing memory according to claim 6, wherein the determining module includes:
the acquisition submodule is used for acquiring the last operation time of the file in the application program;
, a determining submodule, configured to obtain an unused duration of the file according to a time interval between the last operation time and the current time;
and the judging submodule is used for judging the file to be an expired file if the unused time of the file is greater than a preset time threshold.
8. The apparatus for automatically cleaning memory according to claim 6, wherein the filter module comprises:
the second determining submodule is used for determining the file identification of the expired file;
the storage submodule is used for storing the file identifications of all expired files and the mapping relation between the file identifications and the expired files into an expired folder;
the sorting submodule is used for sorting the file identifications from big to small according to the unused duration of the expired files to obtain a file identification sequence;
the screening submodule is used for screening a preset number of file identifications from front to back in the file identification sequence when the residual space of the terminal is smaller than a preset threshold value;
and the third determining submodule is used for taking the expired files corresponding to the preset number of the file identifications obtained by screening as files to be deleted.
9. The apparatus for automatically clearing memory according to claim 8, wherein the second determining submodule is configured to,
calculating a path of the expired file stored in the terminal to obtain a path identification code;
and taking the path identification code as the file identification of the expired file.
10. The apparatus for automatically cleaning memory according to claim 6, wherein the delete module includes:
the creating submodule is used for creating a file operation thread;
and the deletion submodule is used for deleting the file to be deleted through the file operation thread.
11, kinds of electronic equipment, which is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the steps of the method for automatically cleaning memory of of any of claims 1-5 when executing the program stored in the memory.
12, storage medium, wherein the storage medium has stored thereon a method program for automatically cleaning memory, which when executed by a processor, implements the steps of the method for automatically cleaning memory of any of claims 1-5- .
CN201910817805.8A 2019-08-30 2019-08-30 method, device, electronic equipment and storage medium for automatically cleaning memory Pending CN110737604A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910817805.8A CN110737604A (en) 2019-08-30 2019-08-30 method, device, electronic equipment and storage medium for automatically cleaning memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910817805.8A CN110737604A (en) 2019-08-30 2019-08-30 method, device, electronic equipment and storage medium for automatically cleaning memory

Publications (1)

Publication Number Publication Date
CN110737604A true CN110737604A (en) 2020-01-31

Family

ID=69267569

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910817805.8A Pending CN110737604A (en) 2019-08-30 2019-08-30 method, device, electronic equipment and storage medium for automatically cleaning memory

Country Status (1)

Country Link
CN (1) CN110737604A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858515A (en) * 2020-08-03 2020-10-30 中消云(北京)物联网科技研究院有限公司 File management method and device
CN112035119A (en) * 2020-08-28 2020-12-04 北京奇艺世纪科技有限公司 Data deleting method and device
CN112817923A (en) * 2021-02-20 2021-05-18 北京奇艺世纪科技有限公司 Application program data processing method and device
CN114143574A (en) * 2020-09-04 2022-03-04 深圳市雷鸟网络传媒有限公司 Method for cleaning storage space, storage medium and terminal equipment
CN114968941A (en) * 2022-05-31 2022-08-30 重庆长安汽车股份有限公司 Vehicle-end file deleting method and system, electronic equipment and readable storage medium
CN115017111A (en) * 2022-05-07 2022-09-06 北京城市网邻信息技术有限公司 Resource file processing method and device, electronic equipment and readable medium
CN115237826A (en) * 2022-09-23 2022-10-25 深圳乐娱游网络科技有限公司 Automatic application cache cleaning method and related equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103562857A (en) * 2011-06-10 2014-02-05 国际商业机器公司 Releasing blocks of storage class memory
CN105912671A (en) * 2016-04-12 2016-08-31 努比亚技术有限公司 Method and device for cleaning up useless files
CN106951550A (en) * 2017-03-27 2017-07-14 广东欧珀移动通信有限公司 Data processing method, device and mobile terminal
CN109408469A (en) * 2018-09-05 2019-03-01 中国平安人寿保险股份有限公司 Stale data document handling method, device, electronic device and storage medium
CN109828795A (en) * 2018-12-28 2019-05-31 努比亚技术有限公司 A kind of apparatus control method, terminal and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103562857A (en) * 2011-06-10 2014-02-05 国际商业机器公司 Releasing blocks of storage class memory
CN105912671A (en) * 2016-04-12 2016-08-31 努比亚技术有限公司 Method and device for cleaning up useless files
CN106951550A (en) * 2017-03-27 2017-07-14 广东欧珀移动通信有限公司 Data processing method, device and mobile terminal
CN109408469A (en) * 2018-09-05 2019-03-01 中国平安人寿保险股份有限公司 Stale data document handling method, device, electronic device and storage medium
CN109828795A (en) * 2018-12-28 2019-05-31 努比亚技术有限公司 A kind of apparatus control method, terminal and computer readable storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
张晓勇等: "《嵌入式通信系统》", 31 March 2017 *
石先明等: "《信号、通信及信息系统工程》", 31 December 2015 *
陈宏涛: "《QBASIC语言程序设计》", 31 January 2003 *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858515A (en) * 2020-08-03 2020-10-30 中消云(北京)物联网科技研究院有限公司 File management method and device
CN112035119A (en) * 2020-08-28 2020-12-04 北京奇艺世纪科技有限公司 Data deleting method and device
CN112035119B (en) * 2020-08-28 2024-03-08 北京奇艺世纪科技有限公司 Data deleting method and device
CN114143574A (en) * 2020-09-04 2022-03-04 深圳市雷鸟网络传媒有限公司 Method for cleaning storage space, storage medium and terminal equipment
CN114143574B (en) * 2020-09-04 2023-12-05 深圳市雷鸟网络传媒有限公司 Method for cleaning storage space, storage medium and terminal equipment
CN112817923A (en) * 2021-02-20 2021-05-18 北京奇艺世纪科技有限公司 Application program data processing method and device
CN112817923B (en) * 2021-02-20 2024-03-26 北京奇艺世纪科技有限公司 Application program data processing method and device
CN115017111A (en) * 2022-05-07 2022-09-06 北京城市网邻信息技术有限公司 Resource file processing method and device, electronic equipment and readable medium
CN114968941A (en) * 2022-05-31 2022-08-30 重庆长安汽车股份有限公司 Vehicle-end file deleting method and system, electronic equipment and readable storage medium
CN115237826A (en) * 2022-09-23 2022-10-25 深圳乐娱游网络科技有限公司 Automatic application cache cleaning method and related equipment

Similar Documents

Publication Publication Date Title
CN110737604A (en) method, device, electronic equipment and storage medium for automatically cleaning memory
CN108874289B (en) Application history record viewing method and device and electronic equipment
CN102880713B (en) File clean-up method and device
US20210311927A1 (en) Systems and methods for locating application specific data
CN114416667B (en) Method and device for rapidly sharing network disk file, network disk and storage medium
CN106294206B (en) Cache data processing method and device
CN109614559A (en) Data processing method and device
CN109496292A (en) A kind of disk management method, disk management device and electronic equipment
CN105574163A (en) File processing method and device and electronic equipment
CN108133048B (en) File sorting method and device and mobile terminal
CN114374392A (en) Data compression storage method and device, terminal equipment and readable storage medium
CN111831691A (en) Data reading and writing method and device, electronic equipment and storage medium
CN105430115A (en) Method and apparatus for optimizing IP (Internet Protocol) library and computing device
CN110399451B (en) Full-text search engine caching method, system and device based on nonvolatile memory and readable storage medium
CN116796085A (en) File processing method and device, electronic equipment and storage medium
WO2014079305A1 (en) Method and computing device for processing data
CN108090128B (en) Recovery method and device for merged storage space and electronic equipment
CN110888840A (en) File query method, device, equipment and medium in distributed file system
CN110471793B (en) Data backup method, data recovery method, first terminal and second terminal
CN104572943A (en) Installation-free program cleaning method and device
CN114461762A (en) Archive change identification method, device, equipment and storage medium
CN111198900B (en) Data caching method and device for industrial control network, terminal equipment and medium
CN112667682A (en) Data processing method, data processing device, computer equipment and storage medium
CN108073712B (en) Method and device for deleting main data in information system and computer equipment
CN108632366B (en) File downloading method and device and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200131

RJ01 Rejection of invention patent application after publication