Animation memory caching method, system, device and storage medium
By dynamically determining the maximum capacity of the animation memory cache and releasing memory when memory alarms are not allowed to be cleaned up in real time and the application is unstable, low-latency animation playback and improved background survival rate of the application.
Patent Information
- Application Number
- CN202410889389.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-07-04
AI Technical Summary
The existing technology has problems in the animation memory cache that the memory capacity is difficult to determine, the memory footprint cannot be cleaned immediately, the application is easily killed by the system after the backend, and the memory cannot be adjusted when the system is insufficient, resulting in unstable application operation and low background survival rate.
By obtaining the available memory of the target system and application, determining the appropriate maximum cache memory, and releasing memory according to LRU cache rules when memory alarms are made, ensuring that memory is released in time when memory is insufficient to improve application stability.
Effectively save unnecessary traffic request overhead, reduce the time-consuming decoding and loading animation resources from hard disk, realize low-latency animation playback, and timely release memory when memory is insufficient, improving application operation stability and background survival rate.
Smart Images

Figure CN118900341B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data caching, and in particular to an animation memory caching method, system, device and storage medium. Background Art
[0002] With the rise and development of mobile audio and video live broadcast, the interactive forms of user expression support are no longer limited to text and emoticons, but also include various cool and interesting screen animation interactive effects. In live broadcast, which has extremely high requirements for low latency, high traffic and concurrent requests, it is obviously not advisable to request the same resource through the network every time. The existing animation effect implementation generally saves the created SVGA animation file on the server, and downloads it from the server to the local cache and use it when it needs to be displayed.
[0003] The more sophisticated the animation effect, the larger the SVGA file size is, which is accompanied by high traffic requests and high bandwidth server costs and pressure. The existing technology is generally optimized on cache reuse. Each time the animation is played, it first checks whether there is a target resource in the memory and uses it directly. If not, it checks whether the target resource is already in the local file cache and parses it into the memory for use. Otherwise, it downloads it from the server and caches it for use. Using local cache in this way can save server resource overhead and user traffic overhead, and using memory cache can optimize the time-consuming problem of decoding and loading resources from the hard disk into the memory each time, but there are also the following risks:
[0004] 1) Unable to determine the appropriate memory capacity for SVGA cache;
[0005] 2) Memory usage cannot be cleaned up immediately;
[0006] 3) When the application is returned to the background, the system may kill the process easily;
[0007] 4) When the system memory is insufficient, the memory cannot be adjusted, causing the application to run slower and easily causing memory overflow. Summary of the invention
[0008] The purpose of the present invention is to solve one of the technical problems existing in the prior art to at least a certain extent.
[0009] To this end, an object of an embodiment of the present invention is to provide an animation memory caching method, which can effectively save unnecessary traffic request overhead, reduce the time spent on re-decoding and loading animation resources from the hard disk, thereby responding to animation playback with low latency, and can release memory in time when running memory is insufficient, thereby improving the running stability of the application. When the application exits the user operation interface and retreats to the background, part of the memory can also be released, thereby improving the background survival rate of the application.
[0010] Another object of an embodiment of the present invention is to provide an animation memory caching system.
[0011] In order to achieve the above technical objectives, the technical solutions adopted by the embodiments of the present invention include:
[0012] In a first aspect, an embodiment of the present invention provides an animation memory caching method, comprising the following steps:
[0013] Obtaining the current system available memory of the target system and the current application available memory of the target application, and determining the maximum cache memory according to the system available memory and the application available memory;
[0014] Generate a file saving path according to the uniform resource locator of the target animation file and a preset saving directory, and detect whether the target animation file already exists according to the file saving path;
[0015] When it is determined that the target animation file already exists, determining whether the target SVGA object exists in the memory cache;
[0016] When it is determined that the target SVGA object does not exist in the memory cache, the target animation file is decoded according to the file save path to obtain the target SVGA object, and the target SVGA object is loaded into the memory cache according to the maximum cache memory and LRU cache rules.
[0017] Further, in one embodiment of the present invention, the determining the maximum cache memory according to the system available memory and the application available memory specifically includes:
[0018] Obtaining the total system memory and the memory alarm threshold of the target system, determining the minimum available memory of the target system according to the total system memory and the memory alarm threshold, and further determining the maximum value of the first cache memory allowed by the target system according to the system available memory and the minimum available memory;
[0019] Acquire a memory occupation threshold of the target application, and determine a second cache memory maximum value allowed by the target application according to the application available memory and the memory occupation threshold;
[0020] The maximum cache memory is determined according to a minimum value of the first cache memory maximum value and the second cache memory maximum value.
[0021] Further, in one embodiment of the present invention, the determining whether the target SVGA object exists in the memory cache is specifically as follows:
[0022] The file save path is used as a key value, and a traversal query is performed in the memory cache to determine whether there is the target SVGA object corresponding to the file save path.
[0023] Furthermore, in one embodiment of the present invention, the animation memory caching method further includes the following steps:
[0024] When it is determined that the target animation file does not exist, downloading the target animation file according to the uniform resource locator, and saving the target animation file to the file saving path;
[0025] The target animation file is decoded according to the file saving path to obtain the target SVGA object, and the target SVGA object is loaded into the memory cache according to the maximum cache memory and LRU cache rule.
[0026] Further, in one embodiment of the present invention, the loading of the target SVGA object into the memory cache according to the maximum cache memory and the LRU cache rule specifically includes:
[0027] determining whether the memory cache is full according to the maximum cache memory;
[0028] If the memory cache is full, the memory cache is released according to the LRU cache rule, and the target SVGA object is loaded into the memory cache.
[0029] Furthermore, in one embodiment of the present invention, the animation memory caching method further includes the following steps:
[0030] In response to a memory alarm of the target system, the memory cache is released, and the maximum cache memory is reset according to current memory conditions of the target system and the target application.
[0031] Further, in an embodiment of the present invention, in response to the memory warning information of the target system, releasing the memory cache specifically includes:
[0032] When the alarm level of the memory alarm is a serious level, clearing the memory cache;
[0033] When the alarm level of the memory alarm is a general level, the memory cache is released according to the LRU cache rule, so that the occupied cache of the memory cache is reduced to half of the maximum cache memory.
[0034] In a second aspect, an embodiment of the present invention provides an animation memory cache system, comprising:
[0035] A maximum cache memory determination module, used to obtain the current system available memory of the target system and the current application available memory of the target application, and determine the maximum cache memory according to the system available memory and the application available memory;
[0036] A target animation file detection module, used to generate a file saving path according to the uniform resource locator of the target animation file and a preset saving directory, and to detect whether the target animation file already exists according to the file saving path;
[0037] A target SVGA object determination module is used to determine whether the target SVGA object exists in the memory cache when it is determined that the target animation file already exists;
[0038] The target SVGA object loading module is used to decode the target animation file according to the file save path to obtain the target SVGA object when it is determined that the target SVGA object does not exist in the memory cache, and load the target SVGA object into the memory cache according to the maximum cache memory and LRU cache rules.
[0039] In a third aspect, an embodiment of the present invention provides an animation memory caching device, comprising:
[0040] at least one processor;
[0041] at least one memory for storing at least one program;
[0042] When the at least one program is executed by the at least one processor, the at least one processor implements the above-mentioned animation memory caching method.
[0043] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores a program executable by a processor, and the program executable by the processor is used to execute the above-mentioned animation memory caching method when executed by the processor.
[0044] The advantages and beneficial effects of the present invention will be partly given in the following description, partly become apparent from the following description, or be understood through the practice of the present invention:
[0045] The embodiment of the present invention obtains the current system available memory of the target system and the current application available memory of the target application, determines the maximum cache memory according to the system available memory and the application available memory, generates a file save path according to the uniform resource locator of the target animation file and the preset save directory, and detects whether the target animation file already exists according to the file save path. When it is determined that the target animation file already exists, it is determined whether the target SVGA object exists in the memory cache. When it is determined that the target SVGA object does not exist in the memory cache, the target animation file is decoded according to the file save path to obtain the target SVGA object, and the target SVGA object is loaded into the memory cache according to the maximum cache memory and the LRU cache rule. The embodiment of the present invention can effectively save unnecessary traffic request overhead, reduce the time consumption of re-decoding and loading animation resources from the hard disk, thereby responding to animation playback with low latency, and can release memory in time when the running memory is insufficient, thereby improving the running stability of the application, and can also release part of the memory when the application exits the user operation interface and retreats to the background, thereby improving the background survival rate of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solution in the embodiments of the present invention, the following introduction is made to the drawings required for use in the embodiments of the present invention. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solution of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0047] Figure 1 A flowchart of the steps of an animation memory caching method provided by an embodiment of the present invention;
[0048] Figure 2 A schematic diagram of instructions for an animation memory caching method provided by an embodiment of the present invention;
[0049] Figure 3 A structural block diagram of an animation memory cache system provided by an embodiment of the present invention;
[0050] Figure 4 A structural block diagram of an animation memory caching device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0052] In the description of the present invention, the meaning of "a plurality" is two or more than two. If there is a description of "a first" or "a second", it is only used for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In addition, unless otherwise defined, all technical and scientific terms used in this document have the same meaning as those commonly understood by those skilled in the art.
[0053] In order to solve the existing hidden dangers while using memory cache reuse, the animation memory caching method of the present invention reads the memory usage of the system and application, calculates and sets the appropriate maximum cache memory capacity, and then monitors the memory alarm of the application and promptly chooses to clear the earlier memory cache according to the level of the memory alarm.
[0054] Reference Figure 1 The embodiment of the present invention provides an animation memory caching method, which specifically includes the following steps:
[0055] S101. Obtain the current system available memory of the target system and the current application available memory of the target application, and determine the maximum cache memory according to the system available memory and the application available memory.
[0056] As an optional implementation, the maximum cache memory is determined according to the system available memory and the application available memory, which specifically includes:
[0057] S1011, obtaining the total system memory and memory alarm threshold of the target system, determining the minimum available memory of the target system according to the total system memory and the memory alarm threshold, and further determining the maximum value of the first cache memory allowed by the target system according to the system available memory and the minimum available memory;
[0058] S1012, obtaining a memory occupation threshold of a target application, and determining a maximum value of a second cache memory allowed by the target application according to the application available memory and the memory occupation threshold;
[0059] S1013: Determine the maximum cache memory according to the minimum value of the first cache memory maximum value and the second cache memory maximum value.
[0060] Specifically, the appropriate maximum cache memory is calculated and set by reading the memory usage of the system and applications. The process is as follows:
[0061] Read the current memory usage of the system and applications;
[0062] When the proportion of system available memory to total system memory is less than 20% (i.e., the memory alarm threshold), a memory alarm is likely to be triggered. Therefore, from the system perspective, the maximum cache memory capacity allowed = system available memory - total system memory * 20%;
[0063] The system allocates a fixed memory space to each application. In addition to cache, other functions of the application also need to use and occupy part of the memory, so part of the memory needs to be reserved. In the embodiment of the present invention, the memory to be reserved accounts for 50% (i.e., the memory occupation threshold), so from the perspective of the application, the maximum cache memory capacity allowed = the current available memory of the application * 50%;
[0064] The maximum cache memory capacity finally determined is the minimum value between "the maximum cache memory allowed by the system" and "the maximum cache memory allowed by the application".
[0065] S102: Generate a file saving path according to the uniform resource locator of the target animation file and a preset saving directory, and detect whether the target animation file already exists according to the file saving path.
[0066] Specifically, Figure 2 The figure shows an instruction diagram of the animation memory caching method provided in an embodiment of the present invention. After the user operation triggers the animation playing, it is detected whether the memory cache has been initialized. If not, the corresponding maximum cache memory is set according to the current memory usage of the system and application; after the initialization is completed, the client generates a file save path Path according to the Url (Uniform Resource Locator) of the target SVGA animation to be played and the directory to be saved; according to the Path, it is checked whether the target animation file already exists. If not, the target animation file is downloaded to the local folder.
[0067] S103: When it is determined that the target animation file exists, it is determined whether the target SVGA object exists in the memory cache.
[0068] As an optional implementation, it is further determined whether the target SVGA object exists in the memory cache, which is specifically:
[0069] The file save path is used as the key value, and a traversal query is performed in the memory cache to determine whether there is a target SVGA object corresponding to the file save path.
[0070] Specifically, the Path is used as the key to query whether the target SVGA object already exists in the memory cache. If it exists, the SVGA object is directly used to play the animation; otherwise, the target SVGA object is parsed from the Path, added to the cache device, and used to play the animation.
[0071] S104, when it is determined that the target SVGA object does not exist in the memory cache, the target animation file is decoded according to the file save path to obtain the target SVGA object, and the target SVGA object is loaded into the memory cache according to the maximum cache memory and the LRU cache rule.
[0072] Specifically, before loading the target SVGA object into the memory cache, determine whether the memory cache is full based on the maximum cache memory. If not, add it directly. Otherwise, according to the LRU rule, eliminate and remove the object that has not been used the longest, and then add a new SVGA cache object.
[0073] As an optional implementation, the animation memory caching method further includes the following steps:
[0074] S201, when it is determined that the target animation file does not exist, download the target animation file according to the uniform resource locator, and save the target animation file to a file saving path;
[0075] S202, decoding the target animation file according to the file saving path to obtain a target SVGA object, and loading the target SVGA object into the memory cache according to the maximum cache memory and LRU cache rule.
[0076] Specifically, Figure 2 As shown, when it is detected that the target animation file does not exist according to the file save path, the target animation file is first downloaded according to the uniform resource locator and saved to the file save path, and then the target SVGA object is decoded and loaded into the memory cache to facilitate subsequent animation playback.
[0077] As an optional implementation, the target SVGA object is loaded into the memory cache according to the maximum cache memory and the LRU cache rule, which specifically includes:
[0078] S1041, determining whether the memory cache is full according to the maximum cache memory;
[0079] S1042: If the memory cache is full, release the memory cache according to the LRU cache rule, and load the target SVGA object into the memory cache.
[0080] Specifically, the LRU (Least Recently Used) cache rule is a common cache elimination strategy, and its principle is based on the principle of "least recently used". When the cache space is insufficient, the LRU cache will eliminate the data that has not been used for the longest time to ensure that the cache always stores the latest and most frequently used data. The basic principle of implementing the LRU cache can be achieved by maintaining an ordered access queue. Specifically, a bidirectional linked list can be used to maintain this access queue. The nodes in the linked list are arranged in the order of data access, that is, the nodes closer to the head of the linked list are the most recently accessed, and the nodes closer to the tail of the linked list are the least recently accessed. When a piece of data is accessed, if the data already exists in the cache, it is moved to the head of the linked list. The purpose of this is to move the most recently accessed data to the head of the linked list to reflect its latest and most frequently used situation. When data needs to be eliminated, only the data at the tail of the linked list needs to be eliminated, because they have not been accessed for the longest time and have relatively the least impact on the system. By maintaining such an ordered access queue, the LRU cache can ensure that the data stored in the cache is always the latest and most frequently accessed, thereby improving the cache hit rate and efficiency.
[0081] As an optional implementation, the animation memory caching method further includes the following steps:
[0082] S105 . In response to a memory alarm of the target system, the memory cache is released, and the maximum cache memory is reset according to the current memory conditions of the target system and the target application.
[0083] As an optional implementation, in response to the memory warning information of the target system, the memory cache is released, which specifically includes:
[0084] S1051. When the alarm level of the memory alarm is a serious level, clear the memory cache;
[0085] S1052: When the alarm level of the memory alarm is a general level, the memory cache is released according to the LRU cache rule, so that the occupied cache of the memory cache is reduced to half of the maximum cache memory.
[0086] Specifically, when the system memory alarm is monitored, its alarm level is determined and corresponding cache cleanup is performed: if the alarm level is severe, that is, the system memory is insufficient or there is a risk of the system terminating the process, the memory cache is cleared and the maximum cache memory capacity of the memory cache is readjusted in real time according to the memory usage of the system and the application; if the alarm level is general, that is, the application interface is completely invisible and will not be killed when entering the background queue, part of the cache can be cleaned according to the LRU cache rule, reducing the occupied cache to half of the maximum cache memory, and at the same time readjusting the maximum cache memory capacity of the memory cache according to the real-time memory situation of the system and the application.
[0087] The above is a description of the method steps of the embodiment of the present invention. It can be recognized that the embodiment of the present invention can effectively save unnecessary traffic request overhead, reduce the time consumption of re-decoding and loading animation resources from the hard disk, thereby responding to animation playback with low latency, and can release memory in time when the running memory is insufficient, thereby improving the running stability of the application, and can also release part of the memory when the application exits the user operation interface and retreats to the background, thereby improving the background survival rate of the application.
[0088] Reference Figure 3 , an embodiment of the present invention provides an animation memory cache system, comprising:
[0089] A maximum cache memory determination module is used to obtain the current system available memory of the target system and the current application available memory of the target application, and determine the maximum cache memory according to the system available memory and the application available memory;
[0090] A target animation file detection module is used to generate a file saving path according to the uniform resource locator of the target animation file and a preset saving directory, and detect whether the target animation file already exists according to the file saving path;
[0091] The target SVGA object judgment module is used to judge whether the target SVGA object exists in the memory cache when it is determined that the target animation file already exists;
[0092] The target SVGA object loading module is used to decode the target animation file according to the file save path to obtain the target SVGA object when it is determined that the target SVGA object does not exist in the memory cache, and load the target SVGA object into the memory cache according to the maximum cache memory and LRU cache rules.
[0093] The contents of the above method embodiments are all applicable to the present system embodiments. The functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0094] Reference Figure 4, an embodiment of the present invention provides an animation memory caching device, comprising:
[0095] at least one processor;
[0096] at least one memory for storing at least one program;
[0097] When the at least one program is executed by the at least one processor, the at least one processor implements the animation memory caching method.
[0098] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0099] An embodiment of the present invention further provides a computer-readable storage medium, in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to execute the above-mentioned animation memory caching method.
[0100] A computer-readable storage medium according to an embodiment of the present invention can execute an animation memory caching method provided by an embodiment of the method of the present invention, can execute any combination of implementation steps of the method embodiment, and has the corresponding functions and beneficial effects of the method.
[0101] The embodiment of the present invention also discloses a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes Figure 1 The method shown.
[0102] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the above-mentioned boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.
[0103] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified to the contrary, one or more of the above-mentioned functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0104] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the above methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0105] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0106] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the above-mentioned program is printed, since the above-mentioned program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or processing in other suitable ways as necessary, and then stored in a computer memory.
[0107] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0108] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0109] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0110] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. An animation memory caching method, characterized in that: The following steps are involved: Obtaining the current system available memory of the target system and the current application available memory of the target application, and determining the maximum cache memory according to the system available memory and the application available memory; Generate a file saving path according to the uniform resource locator of the target animation file and a preset saving directory, and detect whether the target animation file already exists according to the file saving path; When it is determined that the target animation file already exists, determining whether the target SVGA object exists in the memory cache; When it is determined that the target SVGA object does not exist in the memory cache, the target animation file is decoded according to the file save path to obtain the target SVGA object, and the target SVGA object is loaded into the memory cache according to the maximum cache memory and the LRU cache rule; The determining of the maximum cache memory according to the system available memory and the application available memory specifically includes: Obtaining the total system memory and the memory alarm threshold of the target system, determining the minimum available memory of the target system according to the total system memory and the memory alarm threshold, and further determining the maximum value of the first cache memory allowed by the target system according to the system available memory and the minimum available memory; Acquire a memory occupancy threshold of the target application, and determine a second cache memory maximum value allowed by the target application according to the application available memory and the memory occupancy threshold; Determine the maximum cache memory according to the minimum value of the first cache memory maximum value and the second cache memory maximum value; The step of loading the target SVGA object into the memory cache according to the maximum cache memory and the LRU cache rule specifically includes: determining whether the memory cache is full according to the maximum cache memory; If the memory cache is full, releasing the memory cache according to the LRU cache rule, and loading the target SVGA object into the memory cache; The maximum cache memory is the maximum cache memory value of the memory cache, and the memory cache is used to cache the target SVGA object corresponding to the target animation file played by the target application.
2. The animation memory caching method according to claim 1, characterized in that: The step of determining whether the target SVGA object exists in the memory cache is as follows: The file save path is used as a key value, and a traversal query is performed in the memory cache to determine whether there is the target SVGA object corresponding to the file save path.
3. The animation memory caching method according to claim 1, characterized in that: The animation memory caching method further comprises the following steps: When it is determined that the target animation file does not exist, downloading the target animation file according to the uniform resource locator, and saving the target animation file to the file saving path; The target animation file is decoded according to the file saving path to obtain the target SVGA object, and the target SVGA object is loaded into the memory cache according to the maximum cache memory and LRU cache rule.
4. An animation memory caching method according to any one of claims 1 to 3, characterized in that: The animation memory caching method further comprises the following steps: In response to a memory alarm of the target system, the memory cache is released, and the maximum cache memory is reset according to current memory conditions of the target system and the target application.
5. The animation memory caching method according to claim 4, characterized in that: The step of releasing the memory cache in response to the memory warning information of the target system specifically includes: When the alarm level of the memory alarm is a serious level, clearing the memory cache; When the alarm level of the memory alarm is a general level, the memory cache is released according to the LRU cache rule, so that the occupied cache of the memory cache is reduced to half of the maximum cache memory.
6. An animation memory cache system, characterized in that: include: A maximum cache memory determination module, used to obtain the current system available memory of the target system and the current application available memory of the target application, and determine the maximum cache memory according to the system available memory and the application available memory; A target animation file detection module, used to generate a file saving path according to the uniform resource locator of the target animation file and a preset saving directory, and to detect whether the target animation file already exists according to the file saving path; A target SVGA object determination module is used to determine whether the target SVGA object exists in the memory cache when it is determined that the target animation file already exists; A target SVGA object loading module is used for, when it is determined that the target SVGA object does not exist in the memory cache, decoding the target animation file according to the file saving path to obtain the target SVGA object, and loading the target SVGA object into the memory cache according to the maximum cache memory and LRU cache rule; The determining of the maximum cache memory according to the system available memory and the application available memory specifically includes: Obtaining the total system memory and the memory alarm threshold of the target system, determining the minimum available memory of the target system according to the total system memory and the memory alarm threshold, and further determining the maximum value of the first cache memory allowed by the target system according to the system available memory and the minimum available memory; Acquire a memory occupancy threshold of the target application, and determine a second cache memory maximum value allowed by the target application according to the application available memory and the memory occupancy threshold; Determine the maximum cache memory according to the minimum value of the first cache memory maximum value and the second cache memory maximum value; The step of loading the target SVGA object into the memory cache according to the maximum cache memory and the LRU cache rule specifically includes: determining whether the memory cache is full according to the maximum cache memory; If the memory cache is full, releasing the memory cache according to the LRU cache rule, and loading the target SVGA object into the memory cache; The maximum cache memory is the maximum cache memory value of the memory cache, and the memory cache is used to cache the target SVGA object corresponding to the target animation file played by the target application.
7. An animation memory cache device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements an animation memory caching method as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium storing a program executable by a processor, characterized in that: The processor-executable program is used to execute an animation memory caching method according to any one of claims 1 to 5 when executed by the processor.
Citation Information
Patent Citations
Animation play method and device
CN106775811A
Application preloading method and apparatus, storage medium and terminal
CN108647055A