WO2018223677A1 - 一种基于图片资源的内存自动释放方法及系统 - Google Patents
一种基于图片资源的内存自动释放方法及系统 Download PDFInfo
- Publication number
- WO2018223677A1 WO2018223677A1 PCT/CN2017/120148 CN2017120148W WO2018223677A1 WO 2018223677 A1 WO2018223677 A1 WO 2018223677A1 CN 2017120148 W CN2017120148 W CN 2017120148W WO 2018223677 A1 WO2018223677 A1 WO 2018223677A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- memory
- image
- loaded
- picture
- bitmap object
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5022—Mechanisms to release resources
Definitions
- the present invention relates to the field of memory release technologies, and in particular, to a memory resource-based automatic memory release method and system.
- the picture is a frequently used component.
- the Bitmap object can usually be used to carry an image.
- the overhead of images in memory is very large.
- developers usually manually instantiate and release bitmap objects. In this way, if we no longer use the image but forget to release the bitmap, it may cause a memory leak, and in serious cases will cause OOM (memory out of bounds) exception.
- the present invention provides a picture resource based automatic memory release method and system that overcomes the above problems or at least partially solves the above problems.
- a method for automatically releasing memory based on a picture resource including:
- the in-memory recycling mechanism is triggered to recover the bitmap object, thereby realizing the release of the memory.
- the invention has the beneficial effects that: selecting a thread pool with a cache function to asynchronously load a picture, effectively solving the problem that the picture is too large, causing ANR (Application Not Responding), and periodically cleaning the bitmap object in the memory.
- ANR Application Not Responding
- the present invention can also be improved as follows.
- the cacheable thread pool includes a plurality of cacheable sub-threads, and the step S1 specifically includes:
- the cacheable thread pool When the cacheable thread pool receives the image resource loading request, according to the number of image resources to be loaded, a corresponding number of cacheable sub-threads are enabled, and the corresponding image resource is loaded in the cacheable sub-thread.
- the loading of the corresponding picture resource in the cacheable sub-thread includes:
- the task class is defined in the cacheable sub-thread, and the image resource loading method in the bitmap factory class is called in the task class to implement loading of the image resource.
- step S1 further includes:
- Multiple cacheable sub-threads can load multiple identical images at the same time
- the map object in the step S2 further includes the number of times of loading the same picture at the same time.
- the same picture loading address is the same, and the storage address in the memory is different after each loading of the same picture.
- step S2 further includes:
- the garbage collection mechanism When the memory resources are tight, the garbage collection mechanism is triggered to collect garbage in the memory. If the memory resources are still tight after garbage collection, the bitmap object of the weak reference relationship is actively reclaimed to release the memory.
- step S3 specifically includes:
- bitmap object If the bitmap object satisfies the collection condition, the bitmap object is reclaimed to release the memory; otherwise, the bitmap object is not reclaimed.
- step S33 specifically includes:
- bitmap object If the bitmap object is invisible, the recovery condition is satisfied, and if the bitmap object is visible, the recovery condition is not satisfied;
- bitmap object if the bitmap object is currently displayed on the page, the bitmap object is marked as visible, otherwise, the bitmap object is marked as invisible.
- a memory automatic release system based on a picture resource including:
- An asynchronous loading module for asynchronously loading an image resource by using a cacheable thread pool
- the relation table maintenance module is configured to construct a map object corresponding to the loaded image every time a picture is loaded, wherein the map object stores the image loading address and the storage address in the memory after the image is loaded, and stores all the map objects.
- the list relationship table
- the obtaining module is configured to traverse the entire list relation table according to a preset time interval, and obtain a bitmap object according to the storage address in the memory after the picture in the list relation table is loaded;
- the recovery release module is configured to trigger a recovery mechanism in the memory to recover the bitmap object if the bitmap object satisfies the recovery condition, thereby realizing release of the memory.
- declaration module is further included;
- the declaration module is configured to declare the bitmap object of the loaded image resource as a weak reference relationship
- the recycling release module is further configured to:
- the garbage collection mechanism When the memory resources are tight, the garbage collection mechanism is triggered to collect garbage in the memory. If the memory resources are still tight after garbage collection, the bitmap object of the weak reference relationship is actively reclaimed to release the memory.
- a processor, a memory, and a bus are included;
- the processor and the memory complete communication with each other through the bus;
- the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the following methods:
- the image resource is asynchronously loaded in the image loader by using a cacheable thread pool
- map object Each time an image is loaded, a map object corresponding to the loaded image is constructed, wherein the map object stores the image loading address and the storage address in the memory after the image is loaded, and all the map objects are stored in the list relation table;
- the in-memory recycling mechanism is triggered to recover the bitmap object, thereby realizing the release of the memory.
- FIG. 1 is a flowchart of a method for automatically releasing a memory based on a picture resource according to an embodiment of the present invention
- FIG. 2 is a block diagram showing a connection of an automatic memory release system based on a picture resource according to another embodiment of the present invention
- FIG. 3 is a block diagram showing an overall connection of a memory automatic release system based on a picture resource according to still another embodiment of the present invention
- FIG. 4 is a block diagram showing the connection of an electronic device according to an embodiment of the present invention.
- a method for automatically releasing a memory based on a picture resource includes: S1, using a cacheable thread pool to load an image resource asynchronously in a picture loader; S2, each time a picture is loaded Build a map object corresponding to the loaded image, wherein the map object stores the image loading address and the storage address in the memory after the image is loaded, and stores all the map objects in the list relation table; S3, according to the preset time interval Traversing the entire list relation table, obtaining a bitmap object according to the storage address in the memory after the picture in the list relation table is loaded; S4, if the bitmap object satisfies the recycling condition, triggering the in-memory recycling mechanism to recover the bitmap object, realizing The release of memory.
- the cacheable thread pool is used to load the image asynchronously in the image loader, so as to avoid the existing main thread from performing the image resource.
- the phenomenon of jamming caused by synchronous loading In the process of loading the image resource by the cacheable thread pool, each time an image resource is loaded, a map object corresponding to the loaded image is constructed, wherein the map object stores the image loading address, that is, the source of the image, and the image loading. After the storage address in memory.
- create a list relation table and store each map object in the list relation table.
- the entire list relation table is traversed, and according to the picture in each map object in the list relation table, after loading
- the memory address in memory is used to obtain a bitmap object in memory.
- a memory address in memory corresponds to a bitmap object.
- the acquired bitmap object is judged whether the bitmap object satisfies the collection condition. If it is satisfied, the bitmap object is collected. If the condition is not satisfied, the bitmap object is not collected.
- a thread pool with a cache function is selected to asynchronously load a picture, which effectively solves the problem that the picture is too large, causing ANR, and can periodically clean up the bitmap object in the memory, thereby automatically releasing the memory, and ensuring system resources.
- ANR ANR
- the cacheable thread pool includes a plurality of cacheable sub-threads
- the step S1 specifically includes: when the cacheable thread pool receives the image resource loading request, according to the image resource to be loaded The number, the corresponding number of cacheable sub-threads are opened, and the corresponding image resource is loaded in the cacheable sub-thread.
- the embodiment selects the cacheable thread pool to asynchronously load the picture resource.
- each cacheable child thread is responsible for implementing a picture. load.
- the asynchronous loading of the picture resource is implemented in the sub-thread, instead of being implemented in the main thread, so that even if the picture resource is large, the main thread does not cause an abnormal phenomenon such as a stuck and an ANR.
- the loading of the corresponding picture resource in the cacheable sub-thread specifically includes: defining a task class in the cacheable sub-thread, and calling an image in the bitmap factory class in the task class
- the resource loading method is used to implement loading of the image resource.
- the normal loading of the bitmap object is to load the bitmap object by calling the bitmapFactory, the factory class of the bitmap. Normally, the image resource can be loaded directly in the main thread through the bitmap factory class.
- the loading method is to load the image into a bitmap object by calling the image resource loading method decodeFile in the bitmap factory class.
- the specific process of implementing asynchronous loading of picture resources by each cacheable sub-thread in this embodiment is similar to the above, defining a task class in each cacheable sub-thread, and calling a picture resource loading method in the bitmap factory class in the task class. decodeFile to achieve the loading of image resources.
- the step S1 further includes: a plurality of cacheable sub-threads can simultaneously load a plurality of identical pictures; and the map object in the step S2 further includes the same picture at the same time.
- the number of loads, in which, in the map object, the same image loading address is the same, the same image is stored in the memory address after each load.
- multiple sub-threads in the cacheable thread pool can simultaneously load image resources in parallel, and each sub-thread is responsible for loading an image.
- each sub-thread is responsible for loading an image.
- the cacheable thread pool receives an external image resource loading request, for example, 7 images need to be loaded at the same time, 4 images in the 7 images to be loaded are the same image, and the other 3 images belong to different images.
- the cacheable thread pool needs to create 2 new sub-threads, so that there are 7 cacheable thread pools. Child thread.
- a sub-thread is responsible for loading an image resource, and 7 sub-threads in the cacheable thread pool can load 7 images at the same time.
- the map object stores the reference relationship of the loaded images in the form of key-value pairs.
- the key value in the map needs to ensure uniqueness, but for each A different picture, the image loading address is different. Therefore, this embodiment utilizes the picture load address as the key value of the map object.
- a map object corresponds to an image, the key value is the image loading address, and the value is the number of times the image is loaded during a loading process. For example, 4 of the 7 images loaded at the same time belong to the same image, therefore, the map
- the key value in the object is the loading address of this image, and the value is the loading number of 4. For these 7 pictures, there are 7 storage addresses in the memory after loading, and each storage address can only store one picture.
- the image loading address is used as the key value in the map object, and the number of times the same image is loaded in one loading process and the storage address in the memory after each image is loaded are used as the value of the map object. Value, describe the loaded image.
- a list relation table is constructed, and multiple map objects are stored in the list relation table to maintain a list chain of reference relationships of all loaded pictures, so as to facilitate positioning of the pictures through the list chain later. And management.
- the step S2 further includes: declaring the bitmap object of the loaded picture resource as a weak reference relationship; when the memory resource is tight, triggering the garbage collection mechanism to collect garbage in the memory, if the garbage After the memory resources are still tight after the recovery, the bitmap object of the weak reference relationship is actively recovered to release the memory.
- this embodiment declares the bitmap object of the loaded image resource as a weak reference relationship, specifically, using the WeakReference weak reference method on the loaded bitmap object.
- a layer is set so that the bitmap object has a weak reference relationship in the system.
- An object with a weak reference relationship has an advantage.
- the system resources are tight, for example, when the system resource is below a threshold, the system will trigger the garbage collection mechanism to recycle the garbage in the memory. If the garbage is recycled, the memory resources are still tight. At this time, the system will actively reclaim the object of the weak reference relationship to ensure that the system does not have a memory exception. Therefore, by setting a weak reference relationship on the bitmap object, the system memory collector can effectively recycle the memory.
- the step S3 specifically includes: S31, designing a timer in the image loader, traversing the entire list relationship table when the timer reaches the timeout threshold; S32, according to the list relationship table Each bitmap object records the memory address in the memory after loading, and acquires the bitmap object in the memory one by one; S33, if the bitmap object satisfies the recycling condition, the bitmap object is reclaimed to release the memory; otherwise, The bitmap object is not recycled.
- the timer In the process of automatically destroying and retrieving the bitmap object in the memory, the timer is designed in the image loader, and then a timeout threshold is set for the timer. When the timer reaches the timeout threshold, for example, the timer reaches 1 minute, traverse the entire list relation table, and according to the memory address stored in the memory of each map object in the list relation table, find the corresponding bitmap object, and determine whether the bitmap object meets the recycling condition. If the bitmap object satisfies the collection condition, the bitmap object is reclaimed to release the memory; if the bitmap object does not satisfy the recycling condition, the collection is not performed.
- the timeout threshold for example, the timer reaches 1 minute
- the bitmap object in the memory is automatically reclaimed by designing a timer in the image loader. Even if the developer does not actively reclaim the bitmap object when using the bitmap object, the bitmap object is automatically reclaimed next time. Effectively avoids memory out of bounds exceptions.
- the step S33 specifically includes: if the bitmap object is in an invisible state, the recovery condition is satisfied, and if the bitmap object is in a visible state, the recovery condition is not satisfied; wherein, if the bitmap object is currently in the Displayed on the page marks the bitmap object as visible, otherwise it marks the bitmap object as invisible.
- bitmap object when the bitmap object is determined to satisfy the recovery condition, if the bitmap object is currently invisible, the bitmap object satisfies the recovery condition, and then the bitmap object is collected. If the bitmap object is in the visible state, the collection condition is not satisfied, and the bitmap object is not recycled.
- bitmap object if the bitmap object is currently displayed on the foreground page, the bitmap object is marked as visible, otherwise, the bitmap object is marked as invisible. That is to say, when the bitmap object is currently displayed on the foreground page, the bitmap object is not reclaimed. If the bitmap object is not currently displayed on the page, the bitmap object is reclaimed.
- a picture resource-based memory automatic release system which includes an asynchronous load module 21, a relation table maintenance module 22, an acquisition module 23, and a recycle release module 24.
- the asynchronous loading module 21 is configured to asynchronously load the image resource by using the cacheable thread pool.
- the relationship table maintenance module 22 is configured to construct a map object corresponding to the loaded image each time a picture is loaded, wherein the map object stores the image loading address and the storage address in the memory after the image is loaded, and all the map objects are Stored in the list relationship table.
- the obtaining module 23 is configured to traverse the entire list relation table according to a preset time interval, and obtain a bitmap object according to the storage address in the memory after the picture in the list relation table is loaded.
- the recovery release module 24 is configured to trigger a recovery mechanism in the memory to recover the bitmap object if the bitmap object satisfies the recovery condition, so as to release the memory.
- the cacheable thread pool includes a plurality of cacheable sub-threads, and the asynchronous load module 21 is specifically configured to: when receiving the image resource loading request, start the cacheable thread pool according to the number of image resources to be loaded. The corresponding number of cacheable sub-threads, in the cacheable sub-thread to achieve the loading of the corresponding image resource.
- the asynchronous loading module 21 is configured to implement loading of the corresponding picture resource in the cacheable sub-thread, and specifically includes: defining a task class in the cacheable sub-thread, and calling the image resource loading method in the bitmap factory class in the task class to implement Loading of image assets.
- the plurality of cacheable sub-threads can load multiple identical pictures at the same time; the map object also includes the number of times of loading the same picture at the same time, wherein in the map object, the same picture loads the same address, the same picture The memory address in memory is different after each load.
- the picture resource-based memory automatic release system further includes a declaration module 25 and a traversal module 26, and the declaration module 25 is configured to declare the bitmap object of the loaded picture resource as a weak reference relationship.
- the recovery release module 24 is specifically configured to trigger a garbage collection mechanism to collect garbage in the memory when the memory resource is tight. If the memory resource is still tight after the garbage collection, the bitmap object of the weak reference relationship is actively recovered to release the memory.
- the traversing module 26 is configured to traverse the entire list relationship table when the timer in the image loader reaches the timeout threshold.
- the obtaining module 23 is specifically configured to: acquire the bitmap object in the memory one by one according to the storage address in the memory after the image recorded in each map object in the list relation table is loaded.
- the recovery release module 24 is specifically configured to: if the bitmap object satisfies the recovery condition, the bitmap object is recovered to release the memory; otherwise, the bitmap object is not collected.
- bitmap object is invisible, the recovery condition is satisfied. If the bitmap object is visible, the collection condition is not satisfied; wherein if the bitmap object is currently displayed on the page, the bitmap object is marked as visible; otherwise, Mark the bitmap object as invisible.
- an electronic device includes a processor 401, a memory 402, and a bus 403.
- the processor 401 and the memory 402 complete communication with each other through the bus 403. .
- the processor 401 is configured to invoke the program instructions in the memory 402 to perform the method provided by the foregoing method embodiments, for example, including: asynchronously loading a picture resource by using a cacheable thread pool in a picture loader; When loading an image, the map object corresponding to the loaded image is constructed, wherein the map object stores the image loading address and the storage address in the memory after the image is loaded, and all the map objects are stored in the list relation table; Set the time interval, traverse the entire list relation table, obtain the bitmap bitmap object according to the storage address in the memory after the picture in the list relation table is loaded; if the bitmap object satisfies the recycling condition, trigger the in-memory recycling mechanism to recover the bitmap object To achieve the release of memory.
- the invention discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, the computer being capable of executing the corresponding implementation when the program instructions are executed by the computer
- the intelligent filtering control layout method provided by the example includes, for example, asynchronously loading the image resource by using a cacheable thread pool in the image loader; and each time a picture is loaded, the map object corresponding to the loaded image is built, wherein, The object stores the image loading address and the storage address in the memory after the image is loaded, and stores all the map objects in the list relation table; traverses the entire list relationship table according to the preset time interval, and loads the image according to the list relationship table.
- the bitmap address object is obtained in the memory address in the memory; if the bitmap object satisfies the recycling condition, the in-memory recycling mechanism is triggered to recover the bitmap object, thereby realizing the release of the memory.
- the present invention also provides a non-transitory computer readable storage medium storing computer instructions for causing a computer to execute the smart layout control method provided by the corresponding embodiment, for example, including
- the cacheable thread pool is used to asynchronously load the image resource; each time a picture is loaded, the map object corresponding to the loaded image is built, wherein the map object stores the image loading address and the image is loaded in the memory.
- all the map objects are stored in the list relation table; according to the preset time interval, the entire list relation table is traversed, and the bitmap bitmap object is obtained according to the storage address in the memory after the picture in the list relation table is loaded; When the bitmap object satisfies the collection condition, it triggers the in-memory recycling mechanism to recycle the bitmap object to release the memory.
- the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
- the foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
- the invention provides a memory automatic release method and system based on picture resources, and selects a thread pool with a cache function to asynchronously load a picture, effectively solving the problem that the picture is too large and causing ANR, and defining a polling timer to
- the image is effectively cleaned up to achieve the purpose of automatic cleaning of the bitmap object, and a weak reference relationship is wrapped for the bitmap object, which ensures that when the system resources are tight, the problem of system memory abnormality does not occur, and the developer is improved. Development efficiency and the possibility of reducing abnormalities in the program.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
Abstract
一种基于图片资源的内存自动释放方法及系统,所述的方法包括:在图片加载器中利用可缓存线程池对图片资源进行异步加载(S1);每加载一张图片时,构建与加载图片对应的map对象,map对象中存放有图片的加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中(S2);按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位图bitmap对象(S3);若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放(S4)。选择具有缓存功能的线程池来异步加载图片,有效地解决了图片过大导致ANR的问题发生,提高了开发者的开发效率和降低程序出现异常的可能性。
Description
交叉引用
本申请引用于2017年3月22日提交的专利名称为“一种基于图片资源的内存自动释放方法及系统”的第201710175351.X号中国专利申请,其通过引用被全部并入本申请。
本发明涉及内存释放技术领域,更具体地,涉及一种基于图片资源的内存自动释放方法及系统。
在Android开发过程中图片是一个经常使用到的组件,Android中通常可以使用Bitmap对象来承载一张图片。图片在内存中的开销是非常大的,目前在开发过程中,通常是开发人员手动实例化和释放bitmap对象。采用这种方式,如果当我们已经不再使用该图片但是却忘记释放该bitmap的时候就有可能会引起内存泄漏,严重的时候会引起OOM(内存越界)异常。
发明内容
本发明提供一种克服上述问题或者至少部分地解决上述问题的一种基于图片资源的内存自动释放方法及系统。
根据本发明的第一方面,提供了一种基于图片资源的内存自动释放方法,包括:
S1,在图片加载器中利用可缓存线程池对图片资源进行异步加载;
S2,每加载一张图片时,构建于加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的 map对象存放于list关系表中;
S3,按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位图bitmap对象;
S4,若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
本发明的有益效果为:选择具有缓存功能的线程池来异步加载图片,有效地解决了图片过大导致ANR(Application Not Responding,应用没有响应)的问题发生,以及能够定期清理内存中的bitmap对象,达到自动释放内存的目的,能够确保在系统资源紧张的时候,也不会引起系统内存异常的问题发生,提高了开发者的开发效率和降低程序出现异常的可能性。
在上述技术方案的基础上,本发明还可以作如下改进。
进一步的,所述可缓存线程池包括多个可缓存子线程,所述步骤S1具体包括:
当可缓存线程池接收到图片资源加载请求时,根据需要加载的图片资源的个数,开启相应个数的可缓存子线程,在可缓存子线程中实现相应图片资源的加载。
进一步的,所述在可缓存子线程中实现相应图片资源的加载具体包括:
在可缓存子线程中定义任务类,在所述任务类中调用bitmap工厂类中的图片资源加载方法来实现图片资源的加载。
进一步的,所述步骤S1还包括:
多个可缓存子线程可同时对多张相同的图片进行加载;
所述步骤S2中的map对象中还包括同一时刻同一张图片的加载次数,其中,在map对象中,同一张图片加载地址相同,同一张图片每一次加载后在内存中的存储地址不同。
进一步的,所述步骤S2还包括:
将加载后的图片资源的bitmap对象申明为弱引用关系;
当内存资源紧张时,触发垃圾回收机制对内存中的垃圾回收,若垃圾回收后内存资源依然紧张,则主动回收弱引用关系的bitmap对象,以释放内 存。
进一步的,所述步骤S3具体包括:
S31,在图片加载器中设计定时器,当定时器达到超时阈值时,遍历整个list关系表;
S32,根据list关系表中的每一个map对象中记录的图片加载后在内存中的存储地址,逐一获取在内存中的bitmap对象;
S33,若bitmap对象满足回收条件,则对该bitmap对象回收,以对内存进行释放,否则,对该bitmap对象不进行回收。
进一步的,所述步骤S33具体包括:
若bitmap对象为不可见状态,则满足回收条件,若bitmap对象为可见状态,则不满足回收条件;
其中,若bitmap对象当前在页面上显示,则将bitmap对象标记为可见状态,否则,将bitmap对象标记为不可见状态。
根据本发明的第二方面,提供了一种基于图片资源的内存自动释放系统,包括:
异步加载模块,用于利用可缓存线程池对图片资源进行异步加载;
关系表维护模块,用于每加载一张图片时,构建与加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;
获取模块,用于按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得bitmap对象;
回收释放模块,用于若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
进一步的,还包括申明模块;
申明模块,用于将加载后的图片资源的bitmap对象申明为弱引用关系;
所述回收释放模块还用于:
当内存资源紧张时,触发垃圾回收机制对内存中的垃圾回收,若垃圾回收后内存资源依然紧张,则主动回收弱引用关系的bitmap对象,以释放内 存。
根据本发明的第三方面,包括处理器(processor)、存储器(memory)和总线;
所述处理器和存储器通过所述总线完成相互间的通信;
所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如下方法:
在图片加载器中利用可缓存线程池对图片资源进行异步加载;
每加载一张图片时,构建与加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;
按照固定的时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得bitmap对象;
若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
图1为本发明一个实施例的基于图片资源的内存自动释放方法流程图;
图2为本发明另一个实施例的基于图片资源的内存自动释放系统连接框图;
图3为本发明又一个实施例的基于图片资源的内存自动释放系统的整体连接框图;
图4为本发明一个实施例的电子设备连接框图。
下面结合附图和实施例,对本发明的具体实施方式作进一步详细描述。以下实施例用于说明本发明,但不用来限制本发明的范围。
参见图1,提供了本发明一个实施例的基于图片资源的内存自动释放方法,包括:S1,在图片加载器中利用可缓存线程池对图片资源进行异步加载; S2,每加载一张图片时,构建与加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;S3,按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得bitmap对象;S4,若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
图片在内存中的开销是非常大的,在图片加载的过程中,开发人员手动实例化和释放承载图片的位图bitmap对象,若开发人员忘记释放bitmap对象时,就可能会引起内存泄漏,严重时甚至会引起内存越界异常。因此,本实施例提供一套内存自动释放的机制。
为了不引起加载图片的主线程发现卡顿的现象和出现ANR异常,本实施例中在图片加载器中利用可缓存线程池来对图片进行异步加载,避免现有的采用主线程对图片资源进行同步加载所引起的卡顿现象。利用可缓存线程池对图片资源加载的过程中,每加载一张图片资源,就构建一个与加载图片对应的map对象,其中,map对象中存放有图片加载地址,即图片的来源,和图片加载后在内存中的存储地址。为了便于对所有的加载图片的定位和管理,创建一个list关系表,将每一个map对象均存放于list关系表中。
为了能够定期对内存中的图片进行清理,按照预设时间间隔,比如,每隔一分钟,就会对整个list关系表进行遍历,并根据list关系表中每一个map对象中的图片加载后在内存中的存储地址,来获取对内存中的bitmap对象,内存中一个存储地址对应有一个bitmap对象。然后对获取的bitmap对象进行判断,该bitmap对象是否满足回收条件,若满足,则对该bitmap对象进行回收,若不满足条件,则对bitmap对象不进行回收。
本实施例选择具有缓存功能的线程池来异步加载图片,有效地解决了图片过大导致ANR的问题发生,以及能够定期清理内存中的bitmap对象,达到自动释放内存的目的,能够确保在系统资源紧张的时候,也不会引起系统内存异常的问题发生,提高了开发者的开发效率和降低程序出现异常的可能性。
在本发明的一个实施例中,所述可缓存线程池包括多个可缓存子线程,所述步骤S1具体包括:当可缓存线程池接收到图片资源加载请求时,根据需要加载的图片资源的个数,开启相应个数的可缓存子线程,在可缓存子线程中实现相应图片资源的加载。
在利用线程池对图片资源进行异步加载的过程中,通常有多种线程池,可缓存线程池、定长线程池、周期性定长线程池和单一线程池。由于本方案需要实现的是图片资源的异步加载任务,且同时为了后续能够复用线程池的线程,本实施例选择可缓存的线程池来异步加载图片资源。
当可缓存线程池接收到外部的图片资源加载请求时,根据需要加载的图片资源的个数,开启线程池中相应个数的可缓存子线程,每一个可缓存子线程负责实现一张图片的加载。
本实施例通过在子线程中实现图片资源的异步加载,而不是在主线程中实现,这样即使是图片资源再大也不会引起主线程的卡顿和出现ANR等异常现象。
在本发明的另一个实施例中,所述在可缓存子线程中实现相应图片资源的加载具体包括:在可缓存子线程中定义任务类,在所述任务类中调用bitmap工厂类中的图片资源加载方法来实现图片资源的加载。
bitmap对象常规的加载是通过调用bitmapFactory,即bitmap的工厂类来对bitmap对象进行加载的。通常情况下是可以直接在主线程中通过bitmap工厂类来对图片资源进行加载的,加载方式是通过调用bitmap工厂类中的图片资源加载方法decodeFile来加载图片为bitmap对象。
但是在特殊情况下,比如,图片很大的时候,此时如果直接在主线程中调用decodeFile方法来加载超大图片,则会由于加载时间过长导致主线程卡死出现ANR异常。
本实施例中每一个可缓存子线程实现图片资源的异步加载的具体过程与上述相类似,在每一个可缓存子线程中定义任务类,在任务类中调用bitmap工厂类中的图片资源加载方法decodeFile来实现图片资源的加载。
在本发明的一个实施例中,所述步骤S1还包括:多个可缓存子线程可 同时对多张相同的图片进行加载;所述步骤S2中的map对象中还包括同一时刻同一张图片的加载次数,其中,在map对象中,同一张图片加载地址相同,同一张图片每一次加载后在内存中的存储地址不同。
需要说明的是,可缓存线程池中的多个子线程是可以同时并行对图片资源进行加载的,每一个子线程负责加载一张图片。当可缓存线程池接收到外部的图片资源加载请求时,比如,需要同时加载7张图片,需要加载的7张图片中有4张图片时同一张图片,其它3张图片均属于不同的图片,若可缓存线程池中当前只有5个可缓存子线程,而可缓存线程池此时需要开启7个子线程,因此,这个时候可缓存线程池需要新建2个子线程,使得可缓存线程池中存在7个子线程。其中,一个子线程负责加载一张图片资源,可缓存线程池中的7个子线程可同时对7张图片进行加载。
当7张图片资源均加载完成后,需要构建4个map对象,map对象以键值对的方式来存储加载图片的引用关系,其中,map中的key值是需要确保唯一性的,而针对每个不同的图片,图片加载地址不同。因此,本实施例利用图片加载地址作为map对象的key值。一个map对象中对应一个图片,key值是图片加载地址,value值是图片的一次加载过程中加载的次数,比如,上述同时加载的7张图片中有4张图片属于同一张图片,因此,map对象中的key值为这张图片加载地址,而value值为加载次数4。而对于这7张图片,加载后在内存中的存储地址有7个,每一个存储地址只能存放一张图片。
本实施例通过巧妙的设计,使用图片加载地址作为map对象中的key值,并将在一次加载过程同一张图片加载的次数以及每一张图片加载后在内存中的存储地址作为map对象的value值,对加载的图片进行描述。为了存储多个图片的引用关系,构建了一个list关系表,在list关系表中存放多个map对象以达到维护所有加载图片的引用关系的列表链,以方便后期通过这个列表链对图片进行定位和管理。
在本发明的一个实施例中,所述步骤S2还包括:将加载后的图片资源的bitmap对象申明为弱引用关系;当内存资源紧张时,触发垃圾回收机制对内存中的垃圾回收,若垃圾回收后内存资源依然紧张,则主动回收弱引用 关系的bitmap对象,以释放内存。
为了确保bitmap对象在系统资源紧张的时候能够及时有效地被系统回收,本实施例将加载后的图片资源的bitmap对象申明为弱引用关系,具体是使用WeakReference弱引用方法在加载后的bitmap对象上套一层,这样bitmap对象在系统中就具备弱引用关系。具备弱引用关系的对象有一个优点,当系统资源紧张的时候,比如,系统资源低于一个阈值时,系统会触发垃圾回收机制对内存中的垃圾进行回收,如果垃圾回收后,内存资源依然紧张,则此时系统会主动回收弱引用关系的对象,确保系统不会出现内存的异常。因此,通过在bitmap对象上套一层弱引用关系来确保系统内存回收器能够有效地对内存进行回收处理。
在本发明的另一个实施例中,所述步骤S3具体包括:S31,在图片加载器中设计定时器,当定时器达到超时阈值时,遍历整个list关系表;S32,根据list关系表中的每一个map对象中记录的图片加载后在内存中的存储地址,逐一获取在内存中的bitmap对象;S33,若bitmap对象满足回收条件,则对该bitmap对象回收,以对内存进行释放,否则,对该bitmap对象不进行回收。
在对内存中的bitmap对象自动销毁回收的过程中,在图片加载器中设计定时器Timer,然后给该定时器Timer设置一个超时阈值,当定时器Timer达到超时阈值时,比如,定时器Timer达到1分钟时,遍历整个list关系表,并根据list关系表中的每一个map对象中记录的图片加载后在内存的存储地址,找到对应的bitmap对象,并判断bitmap对象是否满足回收条件。若bitmap对象满足回收条件,则对bitmap对象进行回收,以释放内存;若bitmap对象不满足回收条件,则不进行回收。
本实施例通过在图片加载器中设计定时器来定期对内存中的bitmap对象自动进行回收,即使开发者在使用bitmap对象时没有主动回收bitmap对象,也会在下一次对bitmap对象进行自动回收,从而有效地避免了内存越界的异常。
在本发明的另一个实施例中,所述步骤S33具体包括:若bitmap对象 为不可见状态,则满足回收条件,若bitmap对象为可见状态,则不满足回收条件;其中,若bitmap对象当前在页面上显示,则将bitmap对象标记为可见状态,否则,将bitmap对象标记为不可见状态。
上述实施例中判断bitmap对象时候满足回收条件具体为,若bitmap对象当前为不可见状态,则该bitmap对象满足回收条件,那么对该bitmap对象进行回收。若bitmap对象为可见状态,则不满足回收条件,则不对给bitmap对象进行回收。其中,若bitmap对象当前在前台的页面上显示,则将该bitmap对象标记为可见状态,否则,将bitmap对象标记为不可见状态。也就是说当bitmap对象当前在前台的页面上正在显示时,则不对该bitmap对象回收,若bitmap对象当前没有的页面上显示,则对该bitmap对象进行回收。
参见图2,提供了本发明另一个实施例的基于图片资源的内存自动释放系统,包括异步加载模块21、关系表维护模块22、获取模块23和回收释放模块24。
异步加载模块21,用于利用可缓存线程池对图片资源进行异步加载。
关系表维护模块22,用于每加载一张图片时,构建与加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中。
获取模块23,用于按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得bitmap对象。
回收释放模块24,用于若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
其中,所述可缓存线程池包括多个可缓存子线程,所述异步加载模块21具体用于:当接收到图片资源加载请求时,根据需要加载的图片资源的个数,开启可缓存线程池中相应个数的可缓存子线程,在可缓存子线程中实现相应图片资源的加载。
异步加载模块21,用于在可缓存子线程中实现相应图片资源的加载具体包括:在可缓存子线程中定义任务类,在所述任务类中调用bitmap工厂类 中的图片资源加载方法来实现图片资源的加载。
其中,多个可缓存子线程可同时对多张相同的图片进行加载;map对象中还包括同一时刻同一张图片的加载次数,其中,在map对象中,同一张图片加载地址相同,同一张图片每一次加载后在内存中的存储地址不同。
参见图3,基于图片资源的内存自动释放系统还包括申明模块25和遍历模块26,申明模块25用于将加载后的图片资源的bitmap对象申明为弱引用关系。
所述回收释放模块24,具体用于当内存资源紧张时,触发垃圾回收机制对内存中的垃圾回收,若垃圾回收后内存资源依然紧张,则主动回收弱引用关系的bitmap对象,以释放内存。
遍历模块26,用于当图片加载器中的定时器达到超时阈值时,遍历整个list关系表。
所述获取模块23具体用于:根据list关系表中的每一个map对象中记录的图片加载后在内存中的存储地址,逐一获取在内存中的bitmap对象。
所述回收释放模块24,具体用于若bitmap对象满足回收条件,则对该bitmap对象回收,以对内存进行释放,否则,对该bitmap对象不进行回收。
其中,若bitmap对象为不可见状态,则满足回收条件,若bitmap对象为可见状态,则不满足回收条件;其中,若bitmap对象当前在页面上显示,则将bitmap对象标记为可见状态,否则,将bitmap对象标记为不可见状态。
参见图4,为本发明一种电子设备,包括:处理器(processor)401、存储器(memory)402和总线403;其中,所述处理器401和存储器402通过所述总线403完成相互间的通信。
所述处理器401用于调用所述存储器402中的程序指令,以执行上述各方法实施例所提供的方法,例如包括:在图片加载器中利用可缓存线程池对图片资源进行异步加载;每加载一张图片时,构建于加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位 图bitmap对象;若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。本发明公开一种计算机程序产品,该计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,该计算机程序包括程序指令,当程序指令被计算机执行时,计算机能够执行上述对应实施例所提供的智能过滤的控件布局方法,例如包括:在图片加载器中利用可缓存线程池对图片资源进行异步加载;每加载一张图片时,构建于加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位图bitmap对象;若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
本发明还提供一种非暂态计算机可读存储介质,该非暂态计算机可读存储介质存储计算机指令,该计算机指令使计算机执行上述对应实施例所提供的智能过滤的控件布局方法,例如包括:在图片加载器中利用可缓存线程池对图片资源进行异步加载;每加载一张图片时,构建于加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位图bitmap对象;若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所描述的实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。 可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分方法。
本发明提供一种基于图片资源的内存自动释放方法及系统,选择具有缓存功能的线程池来异步加载图片,有效地解决了图片过大导致ANR的问题发生,以及定义一个轮询定时器来对图片进行有效的清理从而达到了bitmap对象自动清理的目的,同时为bitmap对象包裹一层弱引用关系,能够确保在系统资源紧张的时候,也不会引起系统内存异常的问题发生,提高了开发者的开发效率和降低程序出现异常的可能性。
最后,本申请的方法仅为较佳的实施方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。
Claims (12)
- 一种基于图片资源的内存自动释放方法,其特征在于,包括:S1,在图片加载器中利用可缓存线程池对图片资源进行异步加载;S2,每加载一张图片时,构建与加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;S3,按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位图bitmap对象;S4,若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
- 如权利要求1所述的基于图片资源的内存自动释放方法,其特征在于,所述可缓存线程池包括多个可缓存子线程,所述步骤S1具体包括:当可缓存线程池接收到图片资源加载请求时,根据需要加载的图片资源的个数,开启相应个数的可缓存子线程,在可缓存子线程中实现相应图片资源的加载。
- 如权利要求2所述的基于图片资源的内存自动释放方法,其特征在于,所述在可缓存子线程中实现相应图片资源的加载具体包括:在可缓存子线程中定义任务类,在所述任务类中调用bitmap工厂类中的图片资源加载方法来实现图片资源的加载。
- 如权利要求3所述的基于图片资源的内存自动释放方法,其特征在于,所述步骤S1还包括:多个可缓存子线程可同时对多张相同的图片进行加载;所述步骤S2中的map对象中还包括同一时刻同一张图片的加载次数,其中,在map对象中,同一张图片加载地址相同,同一张图片每一次加载后在内存中的存储地址不同。
- 如权利要求4所述的基于图片资源的内存自动释放方法,其特征在于,所述步骤S2还包括:将加载后的图片资源的bitmap对象申明为弱引用关系;当内存资源紧张时,触发垃圾回收机制对内存中的垃圾回收,若垃圾回收后内存资源依然紧张,则主动回收弱引用关系的bitmap对象,以释放内存。
- 如权利要求5所述的基于图片资源的内存自动释放方法,其特征在于,所述步骤S3具体包括:S31,在图片加载器中设计定时器,当定时器达到超时阈值时,遍历整个list关系表;S32,根据list关系表中的每一个map对象中记录的图片加载后在内存中的存储地址,逐一获取在内存中的bitmap对象;S33,若bitmap对象满足回收条件,则对该bitmap对象回收,以对内存进行释放,否则,对该bitmap对象不进行回收。
- 如权利要求6所述的基于图片资源的内存自动释放方法,其特征在于,所述步骤S33具体包括:若bitmap对象为不可见状态,则满足回收条件,若bitmap对象为可见状态,则不满足回收条件;其中,若bitmap对象当前在页面上显示,则将bitmap对象标记为可见状态,否则,将bitmap对象标记为不可见状态。
- 一种基于图片资源的内存自动释放系统,其特征在于,包括:异步加载模块,用于利用可缓存线程池对图片资源进行异步加载;关系表维护模块,用于每加载一张图片时,构建与加载图片对应的map对象,其中,map对象中存放有图片加载地址和图片加载后在内存中的存储地址,将所有的map对象存放于list关系表中;获取模块,用于按照预设时间间隔,遍历整个list关系表,根据list关系表中图片加载后在内存中的存储地址获得位图bitmap对象;回收释放模块,用于若bitmap对象满足回收条件,则触发内存中的回收机制对该bitmap对象进行回收,实现对内存的释放。
- 如权利要求8所述的基于图片资源的内存自动释放系统,其特征在 于,还包括申明模块;申明模块,用于将加载后的图片资源的bitmap对象申明为弱引用关系;所述回收释放模块还用于:当内存资源紧张时,触发垃圾回收机制对内存中的垃圾回收,若垃圾回收后内存资源依然紧张,则主动回收弱引用关系的bitmap对象,以释放内存。
- 一种电子设备,其特征在于,包括:至少一个处理器、至少一个存储器、通信接口和总线;其中,所述处理器、存储器、通信接口通过所述总线完成相互间的通信;所述通信接口用于该设备与玩具控制系统的通信设备之间的信息传输;所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如权利要求1-7任一项所述的方法。
- 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,所述计算机指令使所述计算机执行如权利要求1-7任一项所述的方法。
- 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如权利要求1-7任一项所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710419328.0A CN107357650B (zh) | 2017-06-06 | 2017-06-06 | 一种基于图片资源的内存自动释放方法及系统 |
CN201710419328.0 | 2017-06-06 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2018223677A1 true WO2018223677A1 (zh) | 2018-12-13 |
Family
ID=60271796
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2017/120148 WO2018223677A1 (zh) | 2017-06-06 | 2017-12-29 | 一种基于图片资源的内存自动释放方法及系统 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN107357650B (zh) |
WO (1) | WO2018223677A1 (zh) |
Families Citing this family (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107357650B (zh) * | 2017-06-06 | 2020-12-15 | 武汉斗鱼网络科技有限公司 | 一种基于图片资源的内存自动释放方法及系统 |
CN108345505B (zh) * | 2018-02-02 | 2022-08-30 | 珠海金山网络游戏科技有限公司 | 一种多线程资源管理方法和系统 |
CN108595262B (zh) * | 2018-03-29 | 2021-06-22 | 北京奇艺世纪科技有限公司 | 数据处理方法及装置 |
CN108897532B (zh) * | 2018-04-12 | 2022-01-04 | 武汉斗鱼网络科技有限公司 | 一种类工厂注册的方法、装置及电子设备 |
CN108845792B (zh) * | 2018-04-12 | 2022-01-04 | 武汉斗鱼网络科技有限公司 | 一种类工厂注册的方法、装置及电子设备 |
CN108762916B (zh) * | 2018-05-03 | 2022-12-13 | 北京五八信息技术有限公司 | 一种内存管理方法、装置、设备及计算机可读存储介质 |
CN109194986A (zh) * | 2018-08-24 | 2019-01-11 | 深圳市酷开网络科技有限公司 | 一种资源控制方法、智能电视及存储介质 |
CN109388459A (zh) * | 2018-09-26 | 2019-02-26 | 平安普惠企业管理有限公司 | 图片加载方法、装置、计算机设备及存储介质 |
CN109739853A (zh) * | 2018-12-21 | 2019-05-10 | 北京金山安全软件有限公司 | 数组处理方法、装置、电子设备及存储介质 |
CN110064198A (zh) * | 2019-04-11 | 2019-07-30 | 网易(杭州)网络有限公司 | 资源的处理方法及装置、存储介质和电子装置 |
CN110175306B (zh) * | 2019-05-23 | 2022-03-29 | 珠海天燕科技有限公司 | 一种广告信息的处理方法及装置 |
CN112506641B (zh) * | 2019-09-16 | 2022-11-11 | 武汉斗鱼网络科技有限公司 | 一种对象智能释放方法、装置和终端设备 |
CN113779451A (zh) * | 2020-09-16 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | 一种页面加载方法和装置 |
CN113986438B (zh) * | 2021-10-30 | 2024-01-30 | 深圳市快易典教育科技有限公司 | 动画的加载方法、系统、装置及计算机可读存储介质 |
CN118193227B (zh) * | 2024-05-17 | 2024-08-23 | 杭州摩西科技发展有限公司 | 内存管理优化方法、装置、电子设备和存储介质 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102541605A (zh) * | 2011-12-30 | 2012-07-04 | Tcl集团股份有限公司 | 基于Android系统的图片加载方法和装置 |
CN103888602A (zh) * | 2014-03-03 | 2014-06-25 | 广州金山网络科技有限公司 | 移动终端中展示列表的控制方法和装置 |
CN104252367A (zh) * | 2013-06-27 | 2014-12-31 | 北京新媒传信科技有限公司 | 一种智能终端中异步加载图片的方法和系统 |
CN104267996A (zh) * | 2014-09-29 | 2015-01-07 | 广州金山网络科技有限公司 | 一种图片资源处理方法、装置及终端 |
CN104657380A (zh) * | 2013-11-20 | 2015-05-27 | 青岛海信移动通信技术股份有限公司 | 一种图片加载方法和装置 |
CN107357650A (zh) * | 2017-06-06 | 2017-11-17 | 武汉斗鱼网络科技有限公司 | 一种基于图片资源的内存自动释放方法及系统 |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103488373A (zh) * | 2012-06-12 | 2014-01-01 | 腾讯科技(深圳)有限公司 | 一种图片展示的方法、装置及移动终端 |
CN103544207B (zh) * | 2013-08-19 | 2019-01-29 | Tcl集团股份有限公司 | 一种图片加载显示的方法与系统 |
CN105893061A (zh) * | 2016-06-12 | 2016-08-24 | 杭州勒芒科技有限公司 | 应用程序开发方法及系统 |
CN106201358A (zh) * | 2016-07-15 | 2016-12-07 | 珠海市魅族科技有限公司 | 一种内存垃圾回收的方法及装置 |
CN106547624B (zh) * | 2016-11-04 | 2021-01-01 | 武汉斗鱼网络科技有限公司 | 基于Android的图片加载方法及装置 |
-
2017
- 2017-06-06 CN CN201710419328.0A patent/CN107357650B/zh active Active
- 2017-12-29 WO PCT/CN2017/120148 patent/WO2018223677A1/zh active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102541605A (zh) * | 2011-12-30 | 2012-07-04 | Tcl集团股份有限公司 | 基于Android系统的图片加载方法和装置 |
CN104252367A (zh) * | 2013-06-27 | 2014-12-31 | 北京新媒传信科技有限公司 | 一种智能终端中异步加载图片的方法和系统 |
CN104657380A (zh) * | 2013-11-20 | 2015-05-27 | 青岛海信移动通信技术股份有限公司 | 一种图片加载方法和装置 |
CN103888602A (zh) * | 2014-03-03 | 2014-06-25 | 广州金山网络科技有限公司 | 移动终端中展示列表的控制方法和装置 |
CN104267996A (zh) * | 2014-09-29 | 2015-01-07 | 广州金山网络科技有限公司 | 一种图片资源处理方法、装置及终端 |
CN107357650A (zh) * | 2017-06-06 | 2017-11-17 | 武汉斗鱼网络科技有限公司 | 一种基于图片资源的内存自动释放方法及系统 |
Also Published As
Publication number | Publication date |
---|---|
CN107357650A (zh) | 2017-11-17 |
CN107357650B (zh) | 2020-12-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2018223677A1 (zh) | 一种基于图片资源的内存自动释放方法及系统 | |
US7908521B2 (en) | Process reflection | |
CN104205109B (zh) | 持续性和弹性的工作者进程 | |
US8495638B2 (en) | Component-specific disclaimable locks | |
US11132294B2 (en) | Real-time replicating garbage collection | |
CN105700939A (zh) | 一种分布式系统中多线程同步的方法和系统 | |
US11675622B2 (en) | Leader election with lifetime term | |
CN111414256B (zh) | 基于麒麟移动操作系统的应用程序进程派生方法、系统及介质 | |
CN104216767A (zh) | 多线程之间访问共享数据的方法及装置 | |
EP3485375B1 (en) | Workflow-based object destruction | |
US8893137B2 (en) | Transaction-based shared memory protection for high availability environments | |
CN107423090B (zh) | 一种Flash播放器异常日志管理方法及系统 | |
CN113515317A (zh) | 数据恢复的方法、装置 | |
US9063777B2 (en) | Consistent undeployment support as part of lifecycle management for business processes in a cluster-enabled BPM runtime | |
CN117076416A (zh) | 一种优化目录容量嵌套配额的方法、系统、设备和介质 | |
CN102937934B (zh) | 通过动态的语言引擎捕捉遥测数据 | |
US11068375B2 (en) | System and method for providing machine learning based memory resiliency | |
CN116680055A (zh) | 一种异步任务处理方法、装置、计算机设备及存储介质 | |
CN108345505B (zh) | 一种多线程资源管理方法和系统 | |
CN112988277B (zh) | 规则文件加载方法、装置、服务器及介质 | |
CN114996955A (zh) | 一种云原生混沌工程实验的靶场环境构建方法及装置 | |
US10698724B2 (en) | Managing shared resources in a distributed computing system | |
CN115878336A (zh) | 锁操作中的信息处理方法、装置及计算设备 | |
Patel et al. | Using {Trātṛ} to tame Adversarial Synchronization | |
CA2693938A1 (en) | Software object lock management using observations |
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: 17912918 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: 17912918 Country of ref document: EP Kind code of ref document: A1 |