WO2020006860A1 - 一种图片缓存清理方法、装置、终端设备及介质 - Google Patents
一种图片缓存清理方法、装置、终端设备及介质 Download PDFInfo
- Publication number
- WO2020006860A1 WO2020006860A1 PCT/CN2018/104969 CN2018104969W WO2020006860A1 WO 2020006860 A1 WO2020006860 A1 WO 2020006860A1 CN 2018104969 W CN2018104969 W CN 2018104969W WO 2020006860 A1 WO2020006860 A1 WO 2020006860A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- picture
- cache
- cached
- priority
- pictures
- 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.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0891—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches using clearing, invalidating or resetting means
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0893—Caches characterised by their organisation or structure
Definitions
- the present application belongs to the technical field of data processing, and in particular, relates to a method, a device, a terminal device, and a medium for cleaning a picture cache.
- the picture cache is emptied directly after receiving a memory warning.
- the picture cache can be cleaned up, the picture cache that some users need to operate will be cleaned up together, so that the user can When operating, it is easy for the operation to be abnormal.
- embodiments of the present application provide a picture cache cleaning method and a terminal device, so as to solve the problem that an abnormal operation situation of a user is easily caused when the picture cache is cleaned in the prior art.
- a first aspect of the embodiments of the present application provides a method for cleaning a picture cache, including:
- the compressed cached image is prioritized.
- Level sorting the favorite flag value is used to indicate whether the cached picture exists in the favorite list, and the total loading time is the sum of the lengths of time when the cached picture is historically loaded and displayed by the display module;
- the compressed cache pictures are sequentially cleaned until the occupied memory of the compressed cache pictures is less than or equal to the first memory threshold.
- a second aspect of the embodiments of the present application provides a picture cache cleaning device, including:
- a picture compression module configured to compress a cached picture based on a maximum resolution of a display module of a terminal device when a total picture cache is larger than a preset first memory threshold
- the picture sorting module is configured to, if the compressed occupied memory of the cached picture is greater than the first memory threshold, based on the favorite tag value, cached duration and total load duration of each cached picture, Prioritize the cached pictures, the favorite flag value is used to indicate whether the cached picture exists in the favorite list, and the total load time is the sum of the lengths of the cached pictures displayed by the display module history load;
- the picture cache module is configured to clean up the compressed cached pictures in order from low to high priority until the compressed occupied memory of the cached picture is less than or equal to the first memory threshold.
- a third aspect of the embodiments of the present application provides a terminal device including a memory and a processor.
- the memory stores computer-readable instructions executable on the processor, and the processor executes the computer-readable instructions. The following steps are implemented when reading instructions:
- the compressed cached image is prioritized.
- Level sorting the favorite flag value is used to indicate whether the cached picture exists in the favorite list, and the total loading time is the sum of the lengths of time when the cached picture is historically loaded and displayed by the display module;
- the compressed cache pictures are sequentially cleaned until the occupied memory of the compressed cache pictures is less than or equal to the first memory threshold.
- a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, and is characterized in that the computer-readable instructions are implemented when executed by at least one processor. The following steps:
- the compressed cached image is prioritized.
- Level sorting the favorite flag value is used to indicate whether the cached picture exists in the favorite list, and the total loading time is the sum of the lengths of time when the cached picture is historically loaded and displayed by the display module;
- the compressed cache pictures are sequentially cleaned until the occupied memory of the compressed cache pictures is less than or equal to the first memory threshold.
- a multi-level cleaning method is used to clean up cached pictures step by step when the picture cache occupies too much memory, which greatly reduces The possibility of mistaken cleaning is reduced to ensure the normal operation of the user.
- the cached picture takes up too much memory, considering that when the picture resolution is greater than the maximum resolution supported by the display module of the terminal device, even if the picture resolution is high, the user's browsing effect will not be effective. There will be differences, but the higher the resolution of the picture, the larger the memory it occupies. Therefore, high-resolution pictures are extremely wasted on memory.
- the embodiment of the present application first compresses the cached pictures at the maximum resolution to reduce The memory occupied by cached pictures. Because compression of cached pictures does not clean up any cached pictures, the possibility of mistakenly cleaning up cached pictures is avoided, and normal operations of the user are guaranteed. After the cached picture is compressed, if the cached picture still takes up too much memory, the embodiment of the present application will identify the cache based on the compressed data, based on attribute data such as the cached duration of the cached picture, the total loading time, and whether it is favorited by the user. The importance of the picture to the user and prioritize them accordingly, and prioritize the low-priority cache pictures that are not important to the user. At the same time, after cleaning the cache pictures of each priority, the current cache is detected in time.
- the occupied memory of the picture is still too large. If it is too large, continue to clean up the next higher-priority cached picture. If the occupied memory is not greater than the set memory threshold, stop the cleaning of the cached picture directly to complete Cleanup of cached images. Because the cached images that are relatively less important to the user are prioritized each time, the possibility of the impact on the normal operation of the user is minimized. At the same time, multiple priority levels are cleaned up and judged in time after cleaning.
- the embodiment of the present application does not perform indiscriminate over-cleaning of cached pictures like in the prior art, which greatly improves the accuracy of clearing cached pictures, so that the embodiments of the present application can achieve accurate and effective
- the cached pictures are cleaned, so as not to affect the normal operation of the user, and avoid the abnormal operation of the user.
- FIG. 1 is a schematic flowchart of an image cache cleaning method provided in Embodiment 1 of the present application;
- FIG. 2 is a schematic flowchart of an image cache cleaning method provided in Embodiment 2 of the present application.
- FIG. 3 is a schematic flowchart of an image cache cleaning method provided in Embodiment 3 of the present application.
- FIG. 4 is a schematic structural diagram of a picture cache cleaning device provided in Embodiment 4 of the present application.
- FIG. 5 is a schematic diagram of a terminal device provided in Embodiment 5 of the present application.
- FIG. 1 shows an implementation flowchart of a method for cleaning a picture cache provided in Embodiment 1 of the present application, which is detailed as follows:
- the cache picture is compressed based on the maximum resolution of the display module of the terminal device.
- the embodiments of the present application first compress the cached pictures to reduce the memory occupied by the cached pictures.
- the embodiment of this application will The maximum resolution supported in the display module is used to compress the cached picture to achieve the normal operation of the user while saving the cached picture and occupying memory.
- the display module is directly used.
- the maximum supported resolution is used to compress the cached picture, and when the terminal device has multiple display modules, the cached picture is compressed with the largest resolution among the resolutions supported by these display modules. Among them, if the original resolution of the cache picture is less than or equal to the maximum resolution, no compression is needed.
- the specific value of the first memory threshold can be set by a technician based on the actual memory of the terminal device or the actual usable memory allocated by the terminal device for the application, but the first memory threshold should be less than or equal to the corresponding memory warning. Memory threshold to ensure effective cleaning of cached images.
- the compressed cached picture has a larger memory than the first memory threshold, prioritize the compressed cached pictures based on the favorite tag value, cached time, and total load time corresponding to each cached picture, and add favorite tag values. It is used to indicate whether the cached picture exists in the favorites list.
- the total load time is the total length of the cached picture displayed by the display module history load.
- step S103 the compressed cache pictures are cleaned up in order from the lowest to the highest priority, until the occupied memory of the compressed cache pictures is less than or equal to the first memory threshold.
- the memory occupied by the cached image is still too high after compression, it indicates that the effect of the first situation has not met the requirements, and the cleaning needs to be continued. Because the importance of different cached pictures to users may vary greatly, some may be very important to users, and some may not have much effect on users. Therefore, if all cached pictures are directly made according to the existing technology, there is no difference. Cleaning up will cause the user's important pictures to be mistakenly cleaned up together, thus making the normal operation of the user vulnerable. Therefore, in order to achieve accurate cleaning of cached images to avoid the impact of the cleaning of cached images on the normal operation of the user, in the embodiment of the present application, the importance of each cached image to the user is identified and prioritized.
- the cached pictures with lower priority are cleaned first. If the cached pictures of a single priority are cleaned up, the cached pictures still occupy too high memory after compression, then the next priority is high. The first-level cached pictures are cleaned up, until the compressed cached pictures occupy less than or equal to the first memory threshold, and the cached pictures are cleaned up.
- the three factors of the bookmark value corresponding to the cached picture, the cached time and the total load time are combined to determine the importance of each cached picture to the user. Degree of identification and prioritization and cleanup.
- the specific method of prioritizing according to the bookmark value, the cached duration and the total loading duration is not limited here, and can be set by a technician according to requirements, including but not limited to the method as in the second embodiment of the present application. .
- the cache picture is cleared.
- the embodiment of the present application will Stop clearing cached images. Since S101 does not clean up any cached pictures, no accidental cleanup will occur at this time, and normal operations of the user will not be affected in any way.
- a multi-level cleaning method is used to clean up cached pictures step by step when the picture cache occupies too much memory, which greatly reduces The possibility of mistaken cleaning is reduced to ensure the normal operation of the user.
- the cached picture takes up too much memory, considering that when the picture resolution is greater than the maximum resolution supported by the display module of the terminal device, even if the picture resolution is high, the user's browsing effect will not be effective. There will be differences, but the higher the resolution of the picture, the larger the memory it occupies. Therefore, high-resolution pictures are extremely wasted on memory.
- the embodiment of the present application first compresses the cached pictures at the maximum resolution to reduce The memory occupied by cached pictures. Because compression of cached pictures does not clean up any cached pictures, the possibility of mistakenly cleaning up cached pictures is avoided, and normal operations of the user are guaranteed. After the cached picture is compressed, if the cached picture still takes up too much memory, the embodiment of the present application will identify the cache based on the compressed data, based on attribute data such as the cached duration of the cached picture, the total loading time, and whether it is favorited by the user The importance of the picture to the user and prioritize them accordingly, and prioritize the low-priority cache pictures that are not important to the user. At the same time, after cleaning the cache pictures of each priority, the current cache is detected in time.
- the occupied memory of the picture is still too large. If it is too large, continue to clean up the next higher-priority cached picture. If the occupied memory is not greater than the set memory threshold, stop the cleaning of the cached picture directly to complete Cleanup of cached images. Because the cached images that are relatively less important to the user are prioritized each time, the possibility of the impact on the normal operation of the user is minimized. At the same time, multiple priority levels are cleaned up and judged in time after cleaning.
- the embodiment of the present application does not perform indiscriminate over-cleaning of cached pictures like in the prior art, which greatly improves the accuracy of cleaning the cached pictures, so that the embodiments of the present application can achieve the maximum Accurate and effective cleaning of cached images, without affecting the normal operation of the user, and avoiding the occurrence of abnormal operation of the user.
- Embodiment 2 of the present application includes:
- the error clearing is set in the embodiment of the present application as the cache image with the highest priority in the final processing.
- the cached pictures are divided according to the length of the cached pictures, and the cached pictures with the shorter cached time and the pictures with the longer cached time are respectively set with priority.
- the display time and frequency of the cached picture in the terminal device are relatively large, so in theory, the total loading time of the cached picture can show this to a certain extent.
- the importance of cached pictures to users in real life, people's demand for pictures will change with time. It may sometimes be impossible to accurately determine the importance of a cached picture to users based on the total load time. For example, suppose that the user needs to operate the A picture for a long period of time due to mood or work needs. Therefore, the A picture is extremely important to the user during this period and may take a long time to load, but the latter period is shorter. Due to changes in mood or work content, the B picture becomes extremely important during this period of time.
- the B picture may be frequently loaded and displayed.
- the time period corresponding to the A picture is longer.
- the corresponding total load time is greater than the total load time of the B picture.
- the processing is based only on the total loading time, it will be concluded that the importance of the A picture is higher than that of the B picture, but in reality, if the demand time of the B picture is very close to the current time, and the The demand time is far away from the current time.
- the B picture is more important to the user than the A picture. It can be seen that the accuracy of the cached picture cannot be guaranteed by judging the importance of the cached picture based on only a single factor of the total loading time.
- the effective cache ratio total load time / cached time is used to indicate the importance of a cached picture to users. It is the history of the user ’s demand for cached pictures, and the cached time represents the total cache time of the cached pictures. Therefore, by quoting the quotient of the two, you can quantify how important the cached picture is to the user within the cached time.
- the cached time When the cached time is short, the cached pictures have not been cached for a long time. The user may also need to operate these cached pictures. When prioritizing and cleaning these cached pictures, it is necessary to quantify the importance of each cached picture to the user Level to ensure that the less important cached images are prioritized when cleaning, and to ensure that the cleaning is accurate and effective.
- this embodiment of the present application sets it as the third priority with a lower priority, and
- the effective cache is high, it means that it is more important to the user and needs to be cleaned up later. Therefore, in order to prevent the wrong cleaning of these more important cached pictures, its priority needs to be set to a higher second priority.
- the priority levels of the first priority, the second priority, the third priority, and the fourth priority are decreased in order.
- the embodiment of this application Set it to the fourth priority with the lowest priority.
- the duration threshold and the cache ratio threshold in the embodiments of the present application can be set by a technician according to actual conditions.
- the third embodiment of the present application includes:
- the N + 1 cache picture sets are cleaned up in order from the order of the number of times of the threshold, until the occupied memory of the compressed cache picture is less than or equal to the first memory threshold.
- the total load times of cached images of the same priority will also be sorted and cleaned. .
- the cached picture set corresponding to the smaller number of times will be prioritized (Ie cached picture sets with a small total number of load times) to clean up, and after each cleanup of a single cached picture set is completed, check whether the memory occupied by the cached picture is less than the memory threshold.
- the cached picture set is cleaned up. If it is less than that, the next cache image set with a larger total load will be cleaned up.
- the thresholds of the N times are different in size, and specific values can be set by a technician according to actual conditions.
- the embodiment of this application includes:
- the second memory threshold is larger than the first memory threshold.
- the embodiments of this application will directly clean up all invisible cached images directly to release more memory for the application program. Load and display the cached picture for cleaning, so that when the application can be used normally, the user can operate the currently used cached picture normally.
- the specific value of the second memory threshold can be set by a technician.
- Embodiments 1 to 4 of the present application may fail to respond in time.
- the user cannot use the application normally and cannot operate the cached picture. Therefore, in order to ensure the normal use of the application by the user and the normal operation of the cached picture by subsequent users, the embodiments of this application include:
- the embodiment of the present application will directly clean up all cached pictures to make as much memory as possible for the application program. The normal operation of subsequent applications and the user's guarantee of the normal operation of subsequent cached pictures.
- FIG. 4 shows a structural block diagram of a picture cache cleaning device provided by an embodiment of the present application.
- the image cache cleaning device illustrated in FIG. 4 may be an execution subject of the image cache cleaning method provided by the foregoing first embodiment.
- the picture cache cleaning device includes:
- the picture compression module 41 is configured to compress the cached picture based on the maximum resolution of the display module of the terminal device when the total amount of the picture cache is greater than a preset first memory threshold.
- the picture sorting module 42 is configured to: if the compressed occupied memory of the cached picture is greater than the first memory threshold, based on the favorite tag value, the cached duration, and the total load duration corresponding to each of the cached pictures, Prioritize the cached pictures, the favorite flag value is used to indicate whether the cached picture exists in the favorite list, and the total load time is the sum of the lengths of the cached pictures displayed by the display module history load.
- the picture cache module 43 is configured to sequentially clean up the compressed cached pictures in order from low to high priority until the compressed occupied memory of the cached picture is less than or equal to the first memory threshold.
- the picture sorting module 42 includes:
- the effective cache ratio is determined by the total load duration and the cached The quotient of duration is calculated.
- the priority levels of the first priority, the second priority, the third priority, and the fourth priority are sequentially decreased.
- the picture cache module 43 includes:
- N times thresholds Obtain preset N times thresholds, and divide the compressed cache pictures at the current priority into the N times threshold based on the total loading times corresponding to the compressed pictures at the current priority respectively Corresponding N + 1 cache picture sets, where N is a positive integer.
- the N + 1 cache picture sets are sequentially cleaned according to an order of the number of times from small to large, until the compressed occupied memory of the cached pictures is less than or equal to the first memory threshold.
- the picture cache cleaning device further includes:
- the second memory threshold is greater than the first memory threshold
- the picture cache cleaning device further includes:
- first, second, etc. are used in the text to describe various elements in some embodiments of the present application, these elements should not be limited by these terms. These terms are only used to distinguish one element from another.
- a first contact may be named a second contact, and similarly, a second contact may be named a first contact without departing from the scope of the various described embodiments. Both the first contact and the second contact are contacts, but they are not the same contact.
- FIG. 5 is a schematic diagram of a terminal device according to an embodiment of the present application.
- the terminal device 5 of this embodiment includes a processor 50 and a memory 51.
- the memory 51 stores computer-readable instructions 52 that can be run on the processor 50.
- the steps in the foregoing embodiments of the method for clearing picture caches are implemented, for example, steps 101 to 103 shown in FIG.
- the processor 50 executes the computer-readable instructions 52
- the functions of each module / unit in the foregoing device embodiments are implemented, for example, the functions of modules 41 to 43 shown in FIG. 4.
- the terminal device 5 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
- the terminal device may include, but is not limited to, a processor 50 and a memory 51.
- FIG. 5 is only an example of the terminal device 5 and does not constitute a limitation on the terminal device 5. It may include more or less components than shown in the figure, or combine some components or different components.
- the terminal device may further include an input sending device, a network access device, a bus, and the like.
- the processor 50 may be a central processing unit (Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), and application-specific integrated circuits (Applications) Specific Integrated Circuit (ASIC), off-the-shelf Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
- CPU Central Processing Unit
- DSP Digital Signal Processor
- ASIC Applications
- FPGA off-the-shelf Programmable Gate Array
- a general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
- the memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or a memory of the terminal device 5.
- the memory 51 may also be an external storage device of the terminal device 5, such as a plug-in hard disk, a smart media card (SMC), and a secure digital (SD) provided on the terminal device 5. Card, flash card, etc. Further, the memory 51 may further include both an internal storage unit of the terminal device 5 and an external storage device.
- the memory 51 is configured to store the computer-readable instructions and other programs and data required by the terminal device.
- the memory 51 may also be used to temporarily store data that has been transmitted or is to be transmitted.
- each functional unit in each embodiment of the present application may be integrated into one processing unit, or each of the units may exist separately physically, or two or more units may be integrated into one unit.
- the above integrated unit may be implemented in the form of hardware or in the form of software functional unit.
- the integrated module / unit When the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the methods of the above embodiments, and can also be completed by computer-readable instructions instructing related hardware.
- the computer-readable instructions can be stored in a computer-readable storage medium In the computer-readable instructions, when executed by a processor, the steps of the foregoing method embodiments can be implemented.
- the computer-readable instructions include computer-readable instruction codes, and the computer-readable instruction codes may be in a source code form, an object code form, an executable file, or some intermediate form.
- the computer-readable medium may include: any entity or device capable of carrying the computer-readable instruction code, a recording medium, a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory, ROM), Random Access Memory Memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media.
- a recording medium a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory, ROM), Random Access Memory Memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media.
- a recording medium a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory, ROM), Random Access Memory Memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media.
- the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdictions.
- the computer-readable medium Excludes electric carrier signals and t
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
本申请提供了一种图片缓存清理方法、装置、终端设备及介质,适用于数据处理技术领域,该方法包括:当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;若压缩后的缓存图片的占用内存大于第一内存阈值,基于各缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的缓存图片进行优先级排序;按照优先级从低到高的顺序,依次对压缩后的缓存图片进行清理,直至压缩后的缓存图片的占用内存小于或等于第一内存阈值。本申请实施例能够实现精准有效地对缓存图片进行清理,从而不会造成对用户正常操作的影响,避免了用户操作异常情况的发生。
Description
本申请要求于2018年07月06日提交中国专利局、申请号为、发明名称为“一种图片缓存清理方法及终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请属于数据处理技术领域,尤其涉及一种图片缓存清理方法、装置、终端设备及介质。
应用程序在进行图片处理的时候,通常会专门为图片开辟图片缓存以提高对图片的存取的效率。但由于终端设备的缓存空间有限,为了保证用户对图片的正常浏览等操作以及应用程序的正常运行,需要及时对图片缓存进行清理。
现有技术都是在接收到内存警告后直接将图片缓存清空,这样虽然能实现对图片缓存的清理,但对于一些用户所需操作的图片缓存也会一并清理,使得用户在对缓存的图片进行操作时,容易出现操作异常的情况。
有鉴于此,本申请实施例提供了一种图片缓存清理方法及终端设备,以解决现有技术中对图片缓存进行清理时,容易造成用户操作异常情况的问题。
本申请实施例的第一方面提供了一种图片缓存清理方法,包括:
当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;
若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;
按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
本申请实施例的第二方面提供了一种图片缓存清理装置,包括:
图片压缩模块,用于当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;
图片排序模块,用于若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;
图片缓存模块,用于按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
本申请实施例的第三方面提供了一种终端设备,包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:
当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;
若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;
按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
本申请实施例的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被至少一个处理器执行时实现如下步骤:
当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;
若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;
按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
本申请实施例中,为了防止对缓存图片的误清理,在图片缓存占用内存过大时采用了多级清理的方式逐级对缓存图片进行清理,相对现有技术一次清空而言,极大地减小了误清理的可能性,保证了用户的正常操作。具体而言,在缓存图片占用内存过大时,考虑到当图片分辨率大于终端设备的显示模块支持的最大分辨率时,即使图片分辨率再高,对用户而言其操作浏览的效果也不会有差异,但图片分辨率越高其所占用的内存越大,因此高分辨率的图片对内存的浪费情况极为严重,因此本申请实施例首先会对缓存图片进行最大分辨率压缩,以减少缓存图片对内存的占用,由于对缓存图片的压缩并不会清理任何缓存图片,因此,避免了对缓存图片误清理的可能性,保证了用户的正常操作。在对缓存图片压缩后,若缓存图片占用内存仍过大,本申请实施例会在压缩的基础上,再根据缓存图片的已缓存时长、总加载时长以及是否被用户收藏等属性数据,来识别缓存图片对用户的重要程度并进行相应的优先级排序,并优先对对用户不重要的优先级低的缓存图片进行清理,同时在对每个优先级的缓存图片进行清理完成后,及时检测当前缓存图片的占用内存是否仍过大,若过大则继续对下一个优先级较高的缓存图片继续进行清理,若占用内存不大于设定的内存阈值,则直接停止对缓存图片的清理,以完成对缓存图片的清理。由于每次都是优先清理对用户相对而言重要程度较低的缓存图片,从而使得清理对用户正常操作的影响可能性减到了最小,同时多个优先级层层清理,并在清理后及时判断是否达到清理目标,从而使得本申请实施例不会像现有技术一样对缓存图片进行无差别的过度清理,极大地提升了对缓存图片清理的精准度,使得本申请实施例能够实现精准有效地对缓存图片进行清理,从而不会造成对用户正常操作的影响,避免了用户操作异常情况的发生。
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例一提供的图片缓存清理方法的实现流程示意图;
图2是本申请实施例二提供的图片缓存清理方法的实现流程示意图;
图3是本申请实施例三提供的图片缓存清理方法的实现流程示意图;
图4是本申请实施例四提供的图片缓存清理装置的结构示意图;
图5是本申请实施例五提供的终端设备的示意图。
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。
图1示出了本申请实施例一提供的图片缓存清理方法的实现流程图,详述如下:
S101,当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩。
考虑到实际情况中缓存图片的分辨率越大其占用的内存也就越大,而当缓存图片的分辨率过大时,对于可支持的分辨率有限的终端设备而言,其就会造成不必要的内存浪费。因此当缓存图片过多导致图片缓存总量过大时,为了保证应用程序的正常使用保证用户的正常操作,本申请实施例中首先会对缓存图片进行压缩处理,以减少缓存图片的占用内存。其中,考虑到直接对图片的压缩会导致缓存图片在屏幕的显示效果受影响,可能对用户正常的浏览等操作造成一定的影响,但实际情况中,当图片分辨率大于或等于终端设备的显示模块支持的最大分辨率时,即使图片分辨率再高对用户而言其操作浏览的效果也不会有差异,因此为了避免压缩对用户正常操作造成影响,本申请实施例中会根据终端设备的显示模块中支持的最大分辨率来对对缓存图片进行压缩,以实现在节省缓存图片占用内存的同时,保证用户的正常操作,其中,在终端设备仅有一个显示模块时,直接以该显示模块可支持的最大分辨率来对缓存图片进行压缩,而当终端设备具有多个显示模块时,则以这些显示模块支持的分辨率中最大的分辨率来对缓存图片进行压缩。其中,若缓存图片原分辨率本来就小于或等于最大分辨率,则无需进行压缩。
其中,第一内存阈值的具体值可由技术人员根据终端设备的实际内存情况,或者终端设备为应用程序分配的实际可使用内存情况来进行设置,但第一内存阈值应当小于或等于内存警告对应的内存阈值,以保证对缓存图片的有效清理。
S102,若压缩后的缓存图片的占用内存大于第一内存阈值,基于各缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的缓存图片进行优先级排序,收藏标记值用于标示缓存图片是否存在于收藏列表,总加载时长为缓存图片被显示模块历史加载显示的时长总和。
S103,按照优先级从低到高的顺序,依次对压缩后的缓存图片进行清理,直至压缩后的缓存图片的占用内存小于或等于第一内存阈值。
若压缩后缓存图片占用内存仍过高,说明第一次情况的效果没有达到要求,需要继续进行清理。由于不同的缓存图片对用户的重要程度差异可能较大,如有些可能对用户非常重要,有些则可能对用户而言并没有什么作用,因此,若直接按照现有技术对所有缓存图片进行无差别清理,会导致对用户重要图片的一并误清理,从而使得用户正常操作容易受到影响。因此,为了实现对缓存图片的精准清理,以避免缓存图片清理对用户正常操作的影响,本申请实施例中会对每张缓存图片对用户的重要程度进行识别和优先级排序,并在得到每种缓存图片对应的优先级之后,再优先对优先级低的缓存图片进行清理,若对单个优先级的缓存图片清理完成后,压缩后缓存图片占用内存仍过高则继续对下一个优先级高一级的缓存图片进行清理,直至压缩后的缓存图片的占用内存小于或等于第一内存阈值为止,完成对缓存图片的清理工作。
其中,考虑到实际情况中当缓存图片对人们较为重要时,人们往往会在浏览缓存图片时进行收藏标记,同时人们对较为的喜欢缓存图片的浏览显示的时长以及次数等,也均明显高于其他缓存图片。因此,为了实现对缓存图片对用户重要程度的评估,本申请实施例中会综合缓存图片对应的收藏标记值、已缓存时长以及总加载时长三方面因素,来对每张缓存图片对用户的重要程度进行识别和优先级排序及清理。其中具体的根据收藏标记值、已缓存时长和总加载时长来进行优先度排序的具体方法此处不予限定,可由技术人员根据需求自行设定,包括但不限于如本申请实施例二的方法。
作为本申请的一个实施例,在S101之后,若压缩后的缓存图片的占用内存不大于第一内存阈值,完成对缓存图片的清理。
当压缩后的缓存图片的占用内存不大于第一内存阈值时,说明缓存图片的占用内存已经满足用户正常使用的要求,此时为了防止过度清理对缓存图片造成误清理,本申请实施例中会停止对缓存图片的清理工作。由于S101对缓存图片不会对任何缓存图片进行清理,因此此时不会出现任何误清理的情况,不会对用户的正常操作造成任何影响。
本申请实施例中,为了防止对缓存图片的误清理,在图片缓存占用内存过大时采用了多级清理的方式逐级对缓存图片进行清理,相对现有技术一次清空而言,极大地减小了误清理的可能性,保证了用户的正常操作。具体而言,在缓存图片占用内存过大时,考虑到当图片分辨率大于终端设备的显示模块支持的最大分辨率时,即使图片分辨率再高,对用户而言其操作浏览的效果也不会有差异,但图片分辨率越高其所占用的内存越大,因此高分辨率的图片对内存的浪费情况极为严重,因此本申请实施例首先会对缓存图片进行最大分辨率压缩,以减少缓存图片对内存的占用,由于对缓存图片的压缩并不会清理任何缓存图片,因此,避免了对缓存图片误清理的可能性,保证了用户的正常操作。在对缓存图片压缩后,若缓存图片占用内存仍过大,本申请实施例会在压缩的基础上,再根据缓存图片的已缓存时长、总加载时长以及是否被用户收藏等属性数据,来识别缓存图片对用户的重要程度并进行相应的优先级排序,并优先对对用户不重要的优先级低的缓存图片进行清理,同时在对每个优先级的缓存图片进行清理完成后,及时检测当前缓存图片的占用内存是否仍过大,若过大则继续对下一个优先级较高的缓存图片继续进行清理,若占用内存不大于设定的内存阈值,则直接停止对缓存图片的清理,以完成对缓存图片的清理。由于每次都是优先清理对用户相对而言重要程度较低的缓存图片,从而使得清理对用户正常操作的影响可能性减到了最小,同时多个优先级层层清理,并在清理后及时判断是否达到清理目标,从而使得本申请实施例不会像现有技术一样对缓存图片进行无差别的过度清理,极大地提升了对缓存图片清理的精准度,使得本申请实施例能够最大限度地实现对缓存图片精准有效的清理,且不会造成对用户正常操作的影响,避免了用户操作异常情况的发生。
作为对缓存图片优先级排序的一种具体实现方式,如图2所示,本申请实施例二包括:
S201,将存在于收藏列表的缓存图片对应的压缩后的缓存图片设置为第一优先级。
实际情况中,当用户对某张缓存图片收藏了时,说明该缓存图片对用户而言非常重要,因此,为了防止一开始就将这些非常重要的已收藏缓存图片清理掉,造成对重要缓存图片的误清理,本申请实施例中将其设定为最后处理的优先级最高的缓存图片。
S202,计算不存在于收藏列表,且对应的已缓存时长不大于预设的时长阈值的缓存图片的有效缓存比,有效缓存比由总加载时长与已缓存时长之商计算得到。
对于用户没有收藏的缓存图片,本申请实施例中会根据已经缓存的时长进行划分,对已缓存时长较短的缓存图片和已缓存时长较长的图片分别进行优先级设置。
由于实际情况中,用户较为需要的缓存图片相对其他缓存图片而言,其在终端设备中显示的时长频率等均较大,因此,理论上缓存图片的总加载时长可以在一定程度上显示出该缓存图片对用户的重要程度,然而在实际生活中,人们对图片需求的情况会随着时间的变化而变化,仅根据总加载时长有时可能会无法准确判断一张缓存图片对用户的重要程度。例如,假设用户较长的一段时间内,由于心情或者工作需要等原因对需要对A图片进行操作,因此这段时间内A图片对用户极为重要可能会加载较长的时间,但后面一段较短的时间内用户由于心情变化或者工作内容产生了变化,使得B图片的变得极为重要,因此这段时间内可能会对B图片经常性的加载显示,同时假设由于A图片对应的时间段较长,其对应的总加载时长大于B图片的总加载时长。此时,若仅根据总加载时长来进行处理,必然会得出A图片的重要程度高于B图片的结论,但实际情况中,若B图片的需求时间与当前时间非常接近,而A图片的需求时间与当前时间相隔较远,此时B图片对用户的重要程度明显高于A图片。由此可知,仅仅根据总加载时长单条因素来判断缓存图片对用户的重要程度,其准确性必然无法得到保证。
在本申请实施例中,为了实现对缓存图片对用户重要程度的准确量化,采用了有效缓存比=总加载时长/已缓存时长来表示一张缓存图片对用户的重要程度,由于总加载时长代表着用户对缓存图片的需求历史情况,而已缓存时长又代表着缓存图片总的缓存时间情况,因此通过求两者的商可以量化缓存图片在已缓存的时间内对用户的重要程度的情况如何。
S203,将不存在于收藏列表,且对应的有效缓存比大于预设的缓存比阈值的缓存图片对应的压缩后的缓存图片设置为第二优先级,并将对应的有效缓存比不大于缓存比阈值的缓存图片对应的压缩后的缓存图片设置为第三优先级。
当已缓存时长较短时说明缓存图片并没有缓存很久,用户还有可能需要对这些缓存图片进行操作,在对这些缓存图片进行优先级排序清理时,需要量化每张缓存图片的对用户的重要程度,以保证清理时能优先清理重要程度较低的缓存图片,保证清理的准确有效。
当有效缓存比较低时,说明缓存图片对用户的重要程度较低,可以优先进行清理以保证缓存情况的准确有效,因此本申请实施例将其设置为优先级较低的第三优先级,而有效缓存比较高时,则说明其对用户较为重要需要置后进行清理,因此为了防止对这些较为重要的缓存图片的误清理,需要将其优先级设置为较高的第二优先级。
S204,将不存在于收藏列表,且对应的已缓存时长大于时长阈值的缓存图片对应的压缩后的缓存图片设置为第四优先级。
其中,第一优先级、第二优先级、第三优先级以及第四优先级的优先级等级依次降低。
考虑到实际情况中,若缓存图片已经缓存了很久的时间且又没有被用户收藏,说明该缓存图片对用户而言重要程度极低,因此在进行清理时可以优先进行清理,因此本申请实施例中将其设置为优先级最低的第四优先级。其中,本申请实施例中的时长阈值以及缓存比阈值,均可由技术人员根据实际情况进行设置。
作为对每个优先级的缓存图片进行清理的一种具体实现,如图3所示,本申请实施例三,包括:
S301,获取预设的N个次数阈值,并基于当前优先级的压缩后的缓存图片分别对应的总加载次数,将当前优先级的压缩后的缓存图片划分为与N个次数阈值对应的N+1个缓存图片集,其中,N为正整数。
S302,根据次数阈值从小到大的顺序依次对N+1个缓存图片集进行清理,直至压缩后的缓存图片的占用内存小于或等于第一内存阈值。
为了进一步地提升对缓存图片清理的精准度,防止缓存图片的误清理,本申请实施例在对单个优先级的缓存图片进行清理时,也会进行同一优先级的缓存图片的总加载次数排序清理。由于总加载次数越少,说明用户对缓存图片操作的次数越少,即缓存图片对用户的重要程度越低,因此在本申请实施例中会优先对较小的次数阈值对应的缓存图片集(即总加载次数较小的缓存图片集)进行清理,并在每次对单个缓存图片集清理完成后,检测缓存图片占用内存是否小于内存阈值,若小于则完成了对缓存图片的清理,若不小于则继续对下一个总加载次数较大的缓存图片集进行清理。其中,N个次数阈值大小各不相同,具体值可由技术人员根据实际情况设置。
作为本申请的一个实施例,考虑到实际情况中当缓存图片占用内存严重过高时,不仅仅会引起内存警告,更可能会使得应用程序出现卡顿甚至无法正常运行,此时若仍使用本申请实施例一至三中的方法进行清理,可能无法及时保障应用程序的正常使用,使得用户操作异常,因此,为了保证缓存图片占用内存验证过高时应用程序的正常使用,本申请实施例包括:
若图片缓存总量大于预设的第二内存阈值,对缓存图片中当前未加载的图片进行清理,第二内存阈值大于第一内存阈值。
在缓存图片占用内存过大时,为了保证应用程序的正常使用,本申请实施例会直接将所有不可见的缓存图片直接进行清理,以释放出更多的内存供应用程序使用,由于没有对当前正在加载显示的缓存图片进行清理,从而保证了应用程序可正常使用时,用户可以正常对当前正在使用的缓存图片进行操作。其中,第二内存阈值的具体值大小,可由技术人员自行设定。
作为本申请的一个实施例,考虑到实际情况中,内存警告的诱发原因不仅仅只是缓存图片过多,而当其他原因导致了内存警告时,本申请实施例一至4可能无法及时地作出反应,从而使得用户无法正常使用应用程序,更无法对缓存图片进行操作,因此为了保证用户对应用程序的正常使用,以保证后续用户对缓存图片的正常操作,本申请实施例包括:
当接收到内存警告时,若图片缓存总量小于或等于第一内存阈值,将缓存图片全部清空。
当接收到内存警告但缓存图片占用内存又较小时,说明不是诱发原因不是缓存图片,因此本申请实施例会直接将所有缓存图片进行清理,以尽可能地腾出更多内存给应用程序使用,以为后续应用程序的正常运行以及用户对后续缓存图片的正常操作提供保障。
对应于上文实施例的方法,图4示出了本申请实施例提供的图片缓存清理装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。图4示例的图片缓存清理装置可以是前述实施例一提供的图片缓存清理方法的执行主体。
参照图4,该图片缓存清理装置包括:
图片压缩模块41,用于当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩。
图片排序模块42,用于若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和。
图片缓存模块43,用于按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
进一步地,图片排序模块42,包括:
将存在于所述收藏列表的所述缓存图片对应的压缩后的所述缓存图片的优先级设置为第一优先级。
计算不存在于所述收藏列表,且对应的所述已缓存时长不大于预设的时长阈值的所述缓存图片的有效缓存比,所述有效缓存比由所述总加载时长与所述已缓存时长之商计算得到。
将不存在于所述收藏列表,且对应的所述有效缓存比大于预设的缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第二优先级,并将对应的所述有效缓存比不大于所述缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第三优先级。
将不存在于所述收藏列表,且对应的所述已缓存时长大于所述时长阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第四优先级。
其中,所述第一优先级、所述第二优先级、所述第三优先级以及所述第四优先级的优先级等级依次降低。
进一步地,图片缓存模块43,包括:
获取预设的N个次数阈值,并基于当前优先级的压缩后的所述缓存图片分别对应的总加载次数,将当前优先级的压缩后的所述缓存图片划分为与所述N个次数阈值对应的N+1个缓存图片集,其中,N为正整数。
根据次数阈值从小到大的顺序依次对所述N+1个缓存图片集进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
进一步地,该图片缓存清理装置,还包括:
若所述图片缓存总量大于预设的第二内存阈值,对所述缓存图片中当前未加载的图片进行清理,所述第二内存阈值大于所述第一内存阈值。
进一步地,该图片缓存清理装置,还包括:
当接收到内存警告时,若所述图片缓存总量小于或等于所述第一内存阈值,将所述缓存图片全部清空。
本申请实施例提供的图片缓存清理装置中各模块实现各自功能的过程,具体可参考前述图1所示实施例一的描述,此处不再赘述。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
还应理解的是,虽然术语“第一”、“第二”等在文本中在一些本申请实施例中用来描述各种元素,但是这些元素不应该受到这些术语的限制。这些术语只是用来将一个元素与另一元素区分开。例如,第一接触可以被命名为第二接触,并且类似地,第二接触可以被命名为第一接触,而不背离各种所描述的实施例的范围。第一接触和第二接触都是接触,但是它们不是同一接触。
图5是本申请一实施例提供的终端设备的示意图。如图5所示,该实施例的终端设备5包括:处理器50、存储器51,所述存储器51中存储有可在所述处理器50上运行的计算机可读指令52。所述处理器50执行所述计算机可读指令52时实现上述各个图片缓存清理方法实施例中的步骤,例如图1所示的步骤101至103。或者,所述处理器50执行所述计算机可读指令52时实现上述各装置实施例中各模块/单元的功能,例如图4所示模块41至43的功能。
所述终端设备5可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述终端设备可包括,但不仅限于,处理器50、存储器51。本领域技术人员可以理解,图5仅仅是终端设备5的示例,并不构成对终端设备5的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备还可以包括输入发送设备、网络接入设备、总线等。
所称处理器50可以是中央处理单元(Central
Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application
Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器51可以是所述终端设备5的内部存储单元,例如终端设备5的硬盘或内存。所述存储器51也可以是所述终端设备5的外部存储设备,例如所述终端设备5上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器51还可以既包括所述终端设备5的内部存储单元也包括外部存储设备。所述存储器51用于存储所述计算机可读指令以及所述终端设备所需的其他程序和数据。所述存储器51还可以用于暂时地存储已经发送或者将要发送的数据。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一计算机可读存储介质中,该计算机可读指令在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机可读指令包括计算机可读指令代码,所述计算机可读指令代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机可读指令代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access
Memory,RAM)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使对应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。
Claims (20)
- 一种图片缓存清理方法,其特征在于,包括:当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 如权利要求1所述的图片缓存清理方法,其特征在于,所述基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,包括:将存在于所述收藏列表的所述缓存图片对应的压缩后的所述缓存图片设置为第一优先级;计算不存在于所述收藏列表,且对应的所述已缓存时长不大于预设的时长阈值的所述缓存图片的有效缓存比,所述有效缓存比由所述总加载时长与所述已缓存时长之商计算得到;将不存在于所述收藏列表,且对应的所述有效缓存比大于预设的缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第二优先级,并将对应的所述有效缓存比不大于所述缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第三优先级;将不存在于所述收藏列表,且对应的所述已缓存时长大于所述时长阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第四优先级;其中,所述第一优先级、所述第二优先级、所述第三优先级以及所述第四优先级的优先级等级依次降低。
- 如权利要求1或2所述的图片缓存清理方法,其特征在于,所述按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,包括:获取预设的N个次数阈值,并基于当前优先级的压缩后的所述缓存图片分别对应的总加载次数,将当前优先级的压缩后的所述缓存图片划分为与所述N个次数阈值对应的N+1个缓存图片集,其中,N为正整数;根据次数阈值从小到大的顺序依次对所述N+1个缓存图片集进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 如权利要求1所述的图片缓存清理方法,其特征在于,还包括:若所述图片缓存总量大于预设的第二内存阈值,对所述缓存图片中当前未加载的图片进行清理,所述第二内存阈值大于所述第一内存阈值。
- 如权利要求1所述的图片缓存清理方法,其特征在于,还包括:当接收到内存警告时,若所述图片缓存总量小于或等于所述第一内存阈值,将所述缓存图片全部清空。
- 一种图片缓存清理装置,其特征在于,包括:图片压缩模块,用于当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;图片排序模块,用于若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;图片缓存模块,用于按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 如权利要求6所述的图片缓存清理装置,其特征在于,所述图片排序模块,包括:将存在于所述收藏列表的所述缓存图片对应的压缩后的所述缓存图片的优先级设置为第一优先级;计算不存在于所述收藏列表,且对应的所述已缓存时长不大于预设的时长阈值的所述缓存图片的有效缓存比,所述有效缓存比由所述总加载时长与所述已缓存时长之商计算得到;将不存在于所述收藏列表,且对应的所述有效缓存比大于预设的缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第二优先级,并将对应的所述有效缓存比不大于所述缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第三优先级;将不存在于所述收藏列表,且对应的所述已缓存时长大于所述时长阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第四优先级;其中,所述第一优先级、所述第二优先级、所述第三优先级以及所述第四优先级的优先级等级依次降低。
- 如权利要求6或7所述的图片缓存清理装置,其特征在于,所述图片缓存模块,还包括:获取预设的N个次数阈值,并基于当前优先级的压缩后的所述缓存图片分别对应的总加载次数,将当前优先级的压缩后的所述缓存图片划分为与所述N个次数阈值对应的N+1个缓存图片集,其中,N为正整数;根据次数阈值从小到大的顺序依次对所述N+1个缓存图片集进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 如权利要求6所述的图片缓存清理装置,其特征在于,还包括:若所述图片缓存总量大于预设的第二内存阈值,对所述缓存图片中当前未加载的图片进行清理,所述第二内存阈值大于所述第一内存阈值。
- 如权利要求6所述的图片缓存清理装置,其特征在于,还包括:当接收到内存警告时,若所述图片缓存总量小于或等于所述第一内存阈值,将所述缓存图片全部清空。
- 一种终端设备,其特征在于,所述图片缓存清理处理终端设备包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 如权利要求11所述的终端设备,其特征在于,所述基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,包括:将存在于所述收藏列表的所述缓存图片对应的压缩后的所述缓存图片设置为第一优先级;计算不存在于所述收藏列表,且对应的所述已缓存时长不大于预设的时长阈值的所述缓存图片的有效缓存比,所述有效缓存比由所述总加载时长与所述已缓存时长之商计算得到;将不存在于所述收藏列表,且对应的所述有效缓存比大于预设的缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第二优先级,并将对应的所述有效缓存比不大于所述缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第三优先级;将不存在于所述收藏列表,且对应的所述已缓存时长大于所述时长阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第四优先级;其中,所述第一优先级、所述第二优先级、所述第三优先级以及所述第四优先级的优先级等级依次降低。
- 如权利要求11或12所述的终端设备,其特征在于,所述按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,包括:获取预设的N个次数阈值,并基于当前优先级的压缩后的所述缓存图片分别对应的总加载次数,将当前优先级的压缩后的所述缓存图片划分为与所述N个次数阈值对应的N+1个缓存图片集,其中,N为正整数;根据次数阈值从小到大的顺序依次对所述N+1个缓存图片集进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 如权利要求11所述的终端设备,其特征在于,所述处理器执行所述计算机可读指令时还实现如下步骤:若所述图片缓存总量大于预设的第二内存阈值,对所述缓存图片中当前未加载的图片进行清理,所述第二内存阈值大于所述第一内存阈值。
- 如权利要求11所述的终端设备,其特征在于,所述处理器执行所述计算机可读指令时还实现如下步骤:当接收到内存警告时,若所述图片缓存总量小于或等于所述第一内存阈值,将所述缓存图片全部清空。
- 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被至少一个处理器执行时实现如下步骤:当图片缓存总量大于预设的第一内存阈值时,基于终端设备的显示模块的最大分辨率对缓存图片进行压缩;若压缩后的所述缓存图片的占用内存大于所述第一内存阈值,基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,所述收藏标记值用于标示所述缓存图片是否存在于收藏列表,所述总加载时长为所述缓存图片被所述显示模块历史加载显示的时长总和;按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 根据权利要求16所述的计算机可读存储介质,其特征在于,所述基于各所述缓存图片分别对应的收藏标记值、已缓存时长和总加载时长,对压缩后的所述缓存图片进行优先级排序,包括:将存在于所述收藏列表的所述缓存图片对应的压缩后的所述缓存图片设置为第一优先级;计算不存在于所述收藏列表,且对应的所述已缓存时长不大于预设的时长阈值的所述缓存图片的有效缓存比,所述有效缓存比由所述总加载时长与所述已缓存时长之商计算得到;将不存在于所述收藏列表,且对应的所述有效缓存比大于预设的缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第二优先级,并将对应的所述有效缓存比不大于所述缓存比阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第三优先级;将不存在于所述收藏列表,且对应的所述已缓存时长大于所述时长阈值的所述缓存图片对应的压缩后的所述缓存图片设置为第四优先级;其中,所述第一优先级、所述第二优先级、所述第三优先级以及所述第四优先级的优先级等级依次降低。
- 根据权利要求16或17所述的计算机可读存储介质,其特征在于,所述按照优先级从低到高的顺序,依次对压缩后的所述缓存图片进行清理,包括:获取预设的N个次数阈值,并基于当前优先级的压缩后的所述缓存图片分别对应的总加载次数,将当前优先级的压缩后的所述缓存图片划分为与所述N个次数阈值对应的N+1个缓存图片集,其中,N为正整数;根据次数阈值从小到大的顺序依次对所述N+1个缓存图片集进行清理,直至压缩后的所述缓存图片的占用内存小于或等于所述第一内存阈值。
- 根据权利要求16所述的计算机可读存储介质,其特征在于,还包括:若所述图片缓存总量大于预设的第二内存阈值,对所述缓存图片中当前未加载的图片进行清理,所述第二内存阈值大于所述第一内存阈值。
- 根据权利要求16所述的计算机可读存储介质,其特征在于,还包括:当接收到内存警告时,若所述图片缓存总量小于或等于所述第一内存阈值,将所述缓存图片全部清空。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810736162.XA CN109299297A (zh) | 2018-07-06 | 2018-07-06 | 一种图片缓存清理方法及终端设备 |
| CN201810736162.X | 2018-07-06 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020006860A1 true WO2020006860A1 (zh) | 2020-01-09 |
Family
ID=65170255
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/104969 Ceased WO2020006860A1 (zh) | 2018-07-06 | 2018-09-11 | 一种图片缓存清理方法、装置、终端设备及介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109299297A (zh) |
| WO (1) | WO2020006860A1 (zh) |
Families Citing this family (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110119385A (zh) * | 2019-05-06 | 2019-08-13 | 无锡睿勤科技有限公司 | 一种图片处理方法及电子设备 |
| CN110134652A (zh) * | 2019-05-10 | 2019-08-16 | Oppo广东移动通信有限公司 | 缓存文件的回收方法、装置、电子设备及存储介质 |
| CN115398406A (zh) * | 2020-06-02 | 2022-11-25 | 深圳市欢太科技有限公司 | 数据压缩方法、装置、电子设备及存储介质 |
| CN111726654A (zh) * | 2020-06-30 | 2020-09-29 | 京东方科技集团股份有限公司 | 视频推送、播放方法、装置、系统及存储介质 |
| CN111966646B (zh) * | 2020-08-17 | 2024-05-14 | Vidaa(荷兰)国际控股有限公司 | 文件缓存方法和显示设备 |
| CN112000908A (zh) * | 2020-10-28 | 2020-11-27 | 湖南新云网科技有限公司 | 图片加载方法、装置、系统、电子设备及可读存储介质 |
| CN114995914B (zh) * | 2022-06-23 | 2025-10-28 | 中国平安财产保险股份有限公司 | 图片数据的处理方法、装置、计算机设备及存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090138533A1 (en) * | 2007-09-11 | 2009-05-28 | Nikon Corporation | Electronic album providing system and file providing system |
| CN103631616A (zh) * | 2013-08-28 | 2014-03-12 | 广州品唯软件有限公司 | 图片快速加载及缓存方法与系统 |
| CN105389152A (zh) * | 2015-11-17 | 2016-03-09 | 小米科技有限责任公司 | 投射图片的方法、装置及终端设备 |
| CN105868353A (zh) * | 2016-03-29 | 2016-08-17 | 努比亚技术有限公司 | 一种照片清理方法及终端 |
| CN106681745A (zh) * | 2015-11-09 | 2017-05-17 | 五八同城信息技术有限公司 | 图片加载方法及终端 |
| CN107577711A (zh) * | 2017-08-01 | 2018-01-12 | 北京奇艺世纪科技有限公司 | 一种图片缓存的方法和装置 |
-
2018
- 2018-07-06 CN CN201810736162.XA patent/CN109299297A/zh not_active Withdrawn
- 2018-09-11 WO PCT/CN2018/104969 patent/WO2020006860A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090138533A1 (en) * | 2007-09-11 | 2009-05-28 | Nikon Corporation | Electronic album providing system and file providing system |
| CN103631616A (zh) * | 2013-08-28 | 2014-03-12 | 广州品唯软件有限公司 | 图片快速加载及缓存方法与系统 |
| CN106681745A (zh) * | 2015-11-09 | 2017-05-17 | 五八同城信息技术有限公司 | 图片加载方法及终端 |
| CN105389152A (zh) * | 2015-11-17 | 2016-03-09 | 小米科技有限责任公司 | 投射图片的方法、装置及终端设备 |
| CN105868353A (zh) * | 2016-03-29 | 2016-08-17 | 努比亚技术有限公司 | 一种照片清理方法及终端 |
| CN107577711A (zh) * | 2017-08-01 | 2018-01-12 | 北京奇艺世纪科技有限公司 | 一种图片缓存的方法和装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109299297A (zh) | 2019-02-01 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020006860A1 (zh) | 一种图片缓存清理方法、装置、终端设备及介质 | |
| US9176804B2 (en) | Memory dump optimization in a system | |
| CN110765031B (zh) | 数据存储方法、装置、移动终端及存储介质 | |
| US20220035655A1 (en) | Method and Device for Anonymous Page Management, Terminal Device, and Readable Storage Medium | |
| US11044209B2 (en) | Asymmetric co-operative queue management for messages | |
| US20130179410A1 (en) | Real-time selection of compression operations | |
| WO2020006859A1 (zh) | 一种图片缓存清理方法、装置、终端设备及介质 | |
| CN108984103B (zh) | 用于去重的方法和设备 | |
| WO2021057623A1 (zh) | 内存回收方法、装置、电子设备及存储介质 | |
| CN110727607A (zh) | 内存回收方法、装置以及电子设备 | |
| CN113779368A (zh) | 信息推送方法、装置及设备 | |
| US10762207B2 (en) | Method and device for scanning virus | |
| WO2025020508A1 (zh) | 内存泄漏的检测方法、装置、电子设备及可读存储介质 | |
| CN107168643B (zh) | 一种数据存储方法及装置 | |
| CN117492648A (zh) | 数据处理方法、装置、设备及存储介质 | |
| US10402370B2 (en) | Information processing method and electronic apparatus | |
| CN110651253A (zh) | 内存管理系统、信息处理装置及内存管理方法 | |
| CN110069386A (zh) | 一种运算终端数据处理方法、运算终端、系统及介质 | |
| CN115842752A (zh) | 一种弱网处理方法、装置、设备及存储介质 | |
| CN111625500A (zh) | 文件快照方法及装置、电子设备和存储介质 | |
| CN108664322A (zh) | 数据处理方法及系统 | |
| CN118573950A (zh) | 视频帧存储方法、视频播放器、终端及可读存储介质 | |
| CN111833232A (zh) | 一种图像处理装置 | |
| CN112306371A (zh) | 存储管理的方法、设备和计算机程序产品 | |
| CN110069493B (zh) | 数据处理方法、装置、计算机设备及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18925338 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18925338 Country of ref document: EP Kind code of ref document: A1 |