Method and device for determining memory usage when loading images

By adding a load listener to Lottie's animation view function, analyzing the object information of the target animation and calculating the memory required for rendering, the problem of the risk of memory exhaustion when Lottie loads AE effects is solved, and the accurate determination of memory usage information is achieved. Reasonable avoidance.

CN114968572BActive Publication Date: 2024-12-27BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210562654.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-23
Publication Date
2024-12-27
Estimated Expiration
2042-05-23

Smart Images

  • Figure CN114968572B_ABST
    Figure CN114968572B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and device for determining the memory occupied when loading an image, wherein the method comprises: in response to an animation loading trigger operation, loading a target animation for a target application based on an animation view function in a target animation adding tool; obtaining component object information for the target animation returned by a loading listener pre-added in the animation view function; obtaining basic attribute information corresponding to each frame target image of the target animation from the component object information; and determining the memory resources required for rendering the target image based on the basic attribute information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for determining memory usage when loading an image. Background Art

[0002] Lottie is an open source tool that can add animation effects to native applications. It can render After Effects animations (hereinafter referred to as AE effects) in real time in applications. When executing AE effects, Lottie will load the images required for the effects. For complex animation scenes, multiple frames of images will need to be loaded. Image loading will take up a certain amount of memory. Loading a large number of images will cause huge memory consumption, which may lead to the risk of memory exhaustion in the application.

[0003] In order to reasonably avoid the risk of memory exhaustion in a timely manner, there is a demand for determining the memory occupied by Lottie when loading images. However, in the related technology, there is no relevant solution for determining the memory occupied by Lottie when loading images, resulting in the risk of memory exhaustion when Lottie loads AE special effects. Summary of the invention

[0004] The embodiments of the present disclosure at least provide a method, apparatus, computer device and storage medium for determining the memory occupied when loading an image.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for determining the memory occupied when loading an image, including:

[0006] In response to the animation loading trigger operation, loading the target animation for the target application based on the animation view function in the target animation adding tool;

[0007] Obtaining component object information for the target animation returned by the loading listener pre-added in the animation view function;

[0008] From the component object information, obtain basic attribute information corresponding to each frame target image of the target animation;

[0009] The memory resources required for rendering the target image are determined according to the basic attribute information.

[0010] In a possible implementation manner, after determining the memory resources required for rendering the target image according to the basic attribute information, the method further includes:

[0011] For each frame of the target image, based on the target image, basic attribute information of the target image, and memory resources required for rendering the target image, generate visualization information of the target image;

[0012] According to the visualization information of the target image of each frame of the target animation, a visualization page of the target animation is generated, and the visualization page displays the visualization information of each frame of the target image.

[0013] In a possible implementation manner, after determining the memory resources required for rendering the target image according to the basic attribute information, the method further includes:

[0014] For each frame of the target image, when the memory resources required for rendering the target image are greater than a preset resource threshold, an alarm prompt information for the target image is generated.

[0015] In a possible implementation, the acquiring the component object information for the target animation returned by the loading listener pre-added in the animation view function includes:

[0016] In response to the animation view function successfully loading the target animation, the loading listener pre-added in the animation view function is started, and the component object information for the target animation returned by the loading listener is obtained.

[0017] In a possible implementation, the method further includes the step of adding the loading listener:

[0018] For each application location in the target application that uses the target animation adding tool, the plug-in is determined by using the memory occupied information of the target application, and the target code corresponding to the loading listener is deployed in the constructor of the animation view function to add the loading listener to the animation view function at the application location.

[0019] In a possible implementation, the acquiring, from the component object information, basic attribute information corresponding to each frame target image of the target animation includes:

[0020] Determining the picture object information of each frame of the target picture required for loading the target animation from the component object information;

[0021] According to the picture object information, basic attribute information of each frame of the target picture is obtained.

[0022] In a possible implementation manner, the basic attribute information includes at least one of picture size information, picture name, picture path information of the target picture, and a bitmap of the target picture.

[0023] In a second aspect, an embodiment of the present disclosure further provides a device for determining the memory occupied when loading an image, including:

[0024] A loading module, for responding to an animation loading trigger operation, and loading a target animation for a target application based on an animation view function in a target animation adding tool;

[0025] A first acquisition module is used to acquire component object information for the target animation returned by a loading listener pre-added in the animation view function;

[0026] A second acquisition module is used to acquire basic attribute information corresponding to each frame target image of the target animation from the component object information;

[0027] A determination module is used to determine the memory resources required for rendering the target image according to the basic attribute information.

[0028] In a possible implementation, the device further includes:

[0029] A display module, for generating visualization information of the target image for each frame of the target image based on the target image, the basic attribute information of the target image and the memory resources required for rendering the target image, after determining the memory resources required for rendering the target image according to the basic attribute information;

[0030] According to the visualization information of the target image of each frame of the target animation, a visualization page of the target animation is generated, and the visualization page displays the visualization information of each frame of the target image.

[0031] In a possible implementation, the device further includes:

[0032] A prompt module is used to generate an alarm prompt message for the target image for each frame of the target image after determining the memory resources required for rendering the target image based on the basic attribute information, if the memory resources required for rendering the target image are greater than a preset resource threshold.

[0033] In a possible implementation, the first acquisition module, when acquiring the component object information for the target animation returned by the loading listener pre-added in the animation view function, is used to start the loading listener pre-added in the animation view function in response to the animation view function successfully loading the target animation, and acquire the component object information for the target animation returned by the loading listener.

[0034] In a possible implementation, the device further includes:

[0035] Add a module for adding the loading listener by following these steps:

[0036] For each application location in the target application that uses the target animation adding tool, the plug-in is determined by using the memory occupied information of the target application, and the target code corresponding to the loading listener is deployed in the constructor of the animation view function to add the loading listener to the animation view function at the application location.

[0037] In a possible implementation manner, the second acquisition module, when acquiring the basic attribute information respectively corresponding to each frame target image of the target animation from the component object information, is used to determine the image object information of each frame target image required to load the target animation from the component object information;

[0038] According to the picture object information, basic attribute information of each frame of the target picture is obtained.

[0039] In a possible implementation manner, the basic attribute information includes at least one of picture size information, picture name, picture path information of the target picture, and a bitmap of the target picture.

[0040] In a third aspect, an optional implementation of the present disclosure further provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the machine-readable instructions perform the steps of the above-mentioned first aspect, or any possible implementation of the first aspect.

[0041] In a fourth aspect, an optional implementation of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are executed.

[0042] For a description of the effects of the apparatus for determining the occupied memory when loading an image, the computer device, and the computer-readable storage medium, please refer to the description of the method for determining the occupied memory when loading an image, which will not be repeated here.

[0043] The method, device, computer equipment and storage medium for determining the memory occupied when loading an image provided by the embodiments of the present disclosure can accurately obtain the component object information of the target animation by using the loading listener added in the animation view function to obtain the component object information of the currently loaded target animation when the animation view function in the target animation adding tool loads the target animation for the target application. Since the component object information includes the basic attribute information of each frame of the target image required for loading the target animation, the basic attribute information of each frame of the target image included in the target animation can be accurately obtained by parsing the component object information. The basic attribute information can be used to accurately calculate the memory resources required to render the target image, thereby determining the memory occupied when loading the target image. Based on the determination of the memory occupied when the target animation adding tool loads the target image, the risk of memory exhaustion can be further reasonably avoided.

[0044] Furthermore, the method, apparatus, computer device and storage medium for determining the memory occupied when loading an image provided by the embodiments of the present disclosure can also generate visualization information of the target image after determining the memory resources required to render the target image, and generate a visualization page using the visualization information corresponding to the target image of each frame. By displaying the visualization page, the attribute information of the target image can be obtained more intuitively and clearly.

[0045] Furthermore, the method, apparatus, computer equipment and storage medium for determining the memory occupied during image loading provided by the embodiments of the present disclosure can also generate an alarm by generating an alarm prompt message after determining the memory resources required to render the target image, when it is determined that the memory resources required to render the target image are greater than a preset resource threshold, thereby facilitating timely and reasonable avoidance of the risk of memory exhaustion and improving the rationality of target animation loading.

[0046] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0048] Figure 1A flowchart of a method for determining the memory usage when loading an image provided by an embodiment of the present disclosure is shown;

[0049] Figure 2 A schematic diagram of a visualization page provided by an embodiment of the present disclosure is shown;

[0050] Figure 3 A specific implementation flow chart of a method for determining occupied memory provided by an embodiment of the present disclosure is shown;

[0051] Figure 4 A schematic diagram of a device for determining memory usage when loading an image provided by an embodiment of the present disclosure is shown;

[0052] Figure 5 A schematic diagram of the structure of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure claimed for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0054] In addition, the terms "first", "second", etc. in the description and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein.

[0055] The "multiple or several" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0056] After research, it was found that when Lottie loads the target image of the target animation, it is completely completed by Lottie's own loading framework, without the need to use the image loader (ImageLoader). Therefore, the existing solution for determining the memory occupied by ImageLoader cannot be applied to determining the memory occupied when Lottie loads the target image, resulting in the demand for determining the memory occupied when Lottie loads the image cannot be met, and further, it will not be possible to reasonably avoid the risk of memory exhaustion when Lottie loads AE special effects.

[0057] Based on the above research, the present disclosure provides a solution for determining the memory occupied when loading an image. When the animation view function in the target animation adding tool loads the target animation for the target application, the loading listener added in the animation view function is used to obtain the component object information of the currently loaded target animation, so that the component object information of the target animation can be accurately obtained. Since the component object information includes the basic attribute information of each frame of the target image required for loading the target animation, the basic attribute information of each frame of the target image included in the target animation can be accurately obtained by parsing the component object information. The basic attribute information can be used to accurately calculate the memory resources required to render the target image, thereby determining the memory occupied when loading the target image. Based on the determination of the memory occupied when the target animation adding tool loads the target image, the risk of memory exhaustion can be further reasonably avoided.

[0058] The defects existing in the above solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.

[0059] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0060] To facilitate understanding of this embodiment, a method for determining the occupied memory when loading an image disclosed in an embodiment of the present disclosure is first introduced in detail. The executor of the method for determining the occupied memory when loading an image provided in an embodiment of the present disclosure is generally a terminal device or other processing device with certain computing capabilities, wherein the terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a personal digital assistant (PDA), a handheld device, a computer device, etc.; in some possible implementations, the method for determining the occupied memory when loading an image may be implemented by a processor calling computer-readable instructions stored in a memory.

[0061] The following describes the method for determining the memory usage when loading an image provided by an embodiment of the present disclosure by taking a computer device as an example.

[0062] like Figure 1 As shown, it is a flowchart of a method for determining the memory occupied when loading an image provided by an embodiment of the present disclosure, which may include the following steps:

[0063] S101: In response to an animation loading trigger operation, a target animation is loaded for a target application based on an animation view function in a target animation adding tool.

[0064] Here, the target animation adding tool is Lottie. When Lottie loads the target animation, it is carried by the animation view function in Lottie. The animation view function is a function for loading the target animation, which can be specifically the Lottie animation view (LottieAnimationView) function in Lottie. The LottieAnimationView described below is the animation view function.

[0065] The target animation is the After Effects animation effect loaded by Lottie. The target animation may include multiple frames of target images. Based on the display of the multiple frames of target images, animation features may be formed.

[0066] The target application may be any application that has the ability to display AE special effects. The above animation loading trigger operation may be, for example, an operation in which a user enters any animation page in the target application.

[0067] In specific implementation, when the user clicks on the animation page in the target application, the animation loading trigger operation is completed. Then, in response to the animation loading trigger operation, the target animation to be displayed for the animation loading trigger operation can be determined. The target animation is loaded in the target application using LottieAnimationView in Lottie. Specifically, each frame of the target image included in the target animation can be rendered and displayed in sequence according to the order of appearance of each frame of the target image, so as to form and display the target animation in the animation page in the target application.

[0068] S102: Obtain component object information for the target animation returned by a loading listener pre-added in the animation view function.

[0069] Here, the loading listener is used to listen to LottieAnimationView loading the target animation and is triggered after LottieAnimationView loads the target animation. The loading listener can be represented by LottieOnCompositionLoadedListener, the listener when Lottie loads the composition.

[0070] After being triggered, LottieOnCompositionLoadedListener can use the internal resource callback method to obtain the composition object information of the target animation loaded by LottieAnimationView. Here, the composition object information is used to characterize the basic attribute information related to each frame of the target image included in the target animation, as well as the animation attribute information of the target animation. For example, the basic attribute information may include the image size of the target image, the storage location of the target image, the bitmap of the image, and other information. The animation attribute information may include, for example, the duration of the target animation, the creator, the creation time, the animation type, and the occupied resource information. The composition object information can be represented by a Lottie composition object (LottieComposition object).

[0071] In specific implementation, after the animation view function successfully loads the target animation, the loading listener added in the animation view function will be triggered. After that, the loading listener will be able to obtain the component object information for the target animation and feedback. In this way, the component object information returned by the loading listener can be obtained.

[0072] In one embodiment, you can add a loading listener in the animation view function as follows:

[0073] For each application location in the target application that uses the target animation adding tool, the plug-in is determined using the memory occupied information of the target application, and the target code corresponding to the loading listener is deployed in the constructor of the animation view function to add the loading listener to the animation view function at the application location.

[0074] Here, there may be multiple application locations for loading AE special effects in a target application, and the target animation adding tool can be used at each application location. Therefore, for each application location, in the target animation adding tool that can be used at the application location, the constructor is used at the application location to build the animation view function corresponding to the application location. The above constructor is a component for building the animation view function.

[0075] The method for determining the occupied memory when loading an image provided by the embodiment of the present disclosure can utilize the method of constructing a plug-in (Gradle) to construct a plug-in for determining the occupied memory information including the above-mentioned target code, that is, the method for determining the occupied memory when loading an image provided by the embodiment of the present disclosure can be assembled into a plug-in for determining the occupied memory information. Then, using the plug-in for determining the occupied memory information and the constructor, an animation view function is constructed at each application location where the target animation adding tool is used. Exemplarily, for the Android system, the Android plug-in (i.e., Android Gradle) in the Android (Android) system can be utilized to construct a plug-in for determining the occupied memory information that carries the above-mentioned method for determining the occupied memory, and the constructed plug-in for determining the occupied memory information can be represented by a Lottie monitor plug-in (prek_lottie_monitor_plugin).

[0076] The above-mentioned target code includes the code corresponding to the loading listener and the code corresponding to the method for determining the memory occupied when loading an image provided in the embodiment of the present disclosure. By deploying the target code in the constructor, the memory occupied information when the animation view function loads the target image can be determined.

[0077] In specific implementation, for each application location in the target application that uses the target animation adding tool, the pre-built memory usage information can be accessed to determine the plug-in and the code library of the target code, and the accessed memory usage information can be used to determine the plug-in and the code library. When the constructor is used to construct the animation view function at each application location, the target code corresponding to the loading listener is deployed in the constructor, thereby realizing the addition of the loading listener in the animation view function.

[0078] In this way, by determining the plug-in through the memory occupation information, it is possible to automatically add a loading listener to the animation view function used in various application locations without manual addition, thereby improving the deployment efficiency and convenience of the loading listener.

[0079] In addition, the animation view function corresponding to each application location can hold a unique draggable object (LottieDrawable object), where the LottieDrawable object is a drawable object used to add the target image included in the target animation. The LottieDrawable object held by each animation view function can have a unique identifier, which can be used as the identifier of the animation view function. In specific applications, the image object information of the target image loaded by each animation view function can be determined based on the LottieDrawable object held by each animation view function.

[0080] In one embodiment, S102 may be implemented according to the following steps:

[0081] In response to the animation view function successfully loading the target animation, a loading listener pre-added in the animation view function is started, and component object information for the target animation returned by the loading listener is obtained.

[0082] For example, in response to LottieAnimationView successfully loading the target animation, the LottieOnCompositionLoadedListener corresponding to the LottieAnimationView may be triggered. After LottieOnCompositionLoadedListener is successfully triggered, LottieOnCompositionLoadedListener will return the LottieComposition object for the target animation, and then the LottieComposition object corresponding to the target animation may be obtained.

[0083] S103: Obtain basic attribute information corresponding to each frame target image of the target animation from the component object information.

[0084] The basic attribute information is used for all basic attributes of the target image. For example, the basic attribute information may include image size information, image type, image content, the type and size of the font in the image, image layer information, etc. In one embodiment, the basic attribute information may specifically include at least one of the image size information, image name, image path information, and the bitmap of the target image. The target images of each frame of the target animation are the frames of images required to load the target animation.

[0085] The picture size information is the length and width information of the target picture, and the picture path is the storage path information of the target picture. For example, A / B / C / Picture A means that the storage path of Picture A is A / B / C.

[0086] In specific implementation, after obtaining the component object information, basic attribute information of each frame of the target image can be extracted from the component object information. The basic attribute information can be represented by Lottie image resources (LottieImageAsset).

[0087] In one embodiment, for S103, basic attribute information corresponding to each frame target picture may be obtained according to the following steps:

[0088] S103 - 1 : Determine the picture object information of each frame of the target picture required for loading the target animation from the component object information.

[0089] Here, one frame of target image corresponds to one picture object information, which can be represented by a map object. The picture object information includes all basic attribute information of the corresponding target picture.

[0090] In specific implementation, after obtaining the component object information, the image object information of each frame target image can be filtered out from the component object information based on the LottieDrawable object held by the animation view function. That is, the map object of each frame target image is filtered out from the component object information.

[0091] S103-2: Obtain basic attribute information of each frame of the target picture according to the picture object information.

[0092] In specific implementation, each filtered picture object information can be traversed to obtain the basic attribute information included in each picture object information, that is, the basic attribute information of each frame target picture is obtained. That is, according to the map object of each frame target picture, the LottieImageAsset of each frame target picture is determined respectively.

[0093] S104: Determine the memory resources required for rendering the target image according to the basic attribute information.

[0094] During specific implementation, for each frame of the target image, the size of the memory resources required for rendering the target image may be calculated according to the bitmap in the basic attribute information of the target image.

[0095] In this way, when the target animation is loaded for the target application by the animation view function in the target animation adding tool, the component object information of the currently loaded target animation is obtained by using the loading listener added in the animation view function, so that the component object information of the target animation can be accurately obtained. Since the component object information includes the basic attribute information of each frame target image required for the target animation loading, the basic attribute information of each frame target image included in the target animation can be accurately obtained by parsing the component object information. The basic attribute information can be used to accurately calculate the memory resources required to render the target image, thereby determining the memory occupied when loading the target image. Based on the determination of the memory occupied when the target animation adding tool loads the target image, the risk of memory exhaustion can be further reasonably avoided.

[0096] In one embodiment, in order to more intuitively and clearly reflect the relevant information of each frame of the target image, after determining the memory resources required for rendering the target image according to the basic attribute information, a visualization page for the target animation can also be generated. In specific implementation, the following steps can be followed:

[0097] Step 1: for each frame of the target image, based on the target image, basic attribute information of the target image and memory resources required for rendering the target image, generate visualization information of the target image.

[0098] Here, the visualization information is information obtained after the basic attributes of the target image are visualized. In specific implementation, for each frame of the target image in the target animation, after determining the memory resources required to render the target image, the frame of the target image, the basic attribute information of the frame of the target image (for example, image size information, image name, image path information), and the memory resources occupied by the frame of the target image can be visualized to obtain the visualization information of the frame of the target image.

[0099] Based on this, corresponding visualization information can be obtained for each frame of the target image.

[0100] Step 2: Generate a visualization page of the target animation based on the visualization information of each frame of the target image of the target animation, and display the visualization information of each frame of the target image on the visualization page.

[0101] Here, the visualization page displays visualization information of various target images.

[0102] In specific implementation, after obtaining the visualization information of each frame of the target image, a visualization page can be generated, and the visualization information of each frame of the target image can be displayed together in the generated visualization page. Figure 2 FIG. 1 is a schematic diagram of a visualization page provided by an embodiment of the present disclosure. Figure 2 In the example, the target animation includes three target images corresponding to the target animation and the visualization information of each target image, that is, target image 1 and its corresponding visualization information, target image 2 and its corresponding visualization information, and visualization information corresponding to target image 3. The visualization information includes the target image, image size information of the target image, image name and type, memory resources occupied by the image, and the identifier of the animation view function for loading the target image.

[0103] Alternatively, for each frame of target image, the visualization information of the frame of target image can be used to generate a visualization page of the frame of target image, and the visualization page corresponding to each frame of target image can be displayed in sequence according to the position of each frame of target image in the target animation and / or the order of appearance.

[0104] Alternatively, the size of the visualization page that can be displayed on the screen can be determined based on the screen size of the terminal on which the target application is installed, and the number of target images that can be displayed in a visualization page and the number of visualization pages that need to be generated can be determined based on the size of the visualization page and the size of each frame of the target image, and the corresponding visualization information can be displayed in each generated visualization page.

[0105] Optionally, after obtaining the visualization information of each frame of the target image, a visualization page can be generated, and the visualization page can carry the visualization information of all the target images. After the visualization page is displayed, the visualization information displayed in the visualization page can be updated in response to the user's sliding operation on the visualization page, so as to ensure that each visualization information can be displayed in the visualization page through the sliding operation.

[0106] In this way, by displaying the visualization page, the attribute information of the target image can be obtained more intuitively and clearly.

[0107] In another embodiment, in order to avoid the risk of memory exhaustion in a timely manner, after determining the memory resources required to render the target image based on the basic attribute information, an alarm can be implemented for each frame of the target image. Specifically, for each frame of the target image, after determining the memory resources required to render the target image, the memory resources can be compared with the preset resource threshold to determine whether it is greater than the preset resource value. Among them, the preset resource value is the maximum memory resource occupancy value for each frame of the target image set based on experience. If the memory resources required for a target image are greater than the memory resource occupancy value, there is a risk of memory exhaustion.

[0108] When it is determined that the memory resources required for rendering the target image are greater than the preset resource threshold, an alarm prompt information for the target image can be generated. Specifically, the alarm prompt information for the target image can be generated and fed back according to the image name of the target image, the memory resources required, and other information. In this way, upon receiving the alarm prompt information, the target image can be processed in time to prevent memory from running out (Out Of Memory).

[0109] Alternatively, in another embodiment, after determining that each frame of the target image included in the target animation corresponds to the memory resources required to be used, the sum of the memory resources required to be used by the target animation can be determined, and then the remaining available memory resources can be determined. When the sum of the memory resources is greater than the remaining available memory resources, an alarm prompt message for the target animation is generated and fed back. The alarm prompt message includes the memory resource information required to be used corresponding to each frame of the target image. In this way, upon receiving the alarm prompt message, the target animation can be processed in a timely manner to prevent memory exhaustion (Out Of Memory).

[0110] Alternatively, after determining the sum of memory resources, the ratio of the currently used memory resources and the sum of memory resources to the total memory resources can be determined. When the ratio exceeds a preset ratio, an alarm prompt message for the target animation is generated and fed back. In this way, upon receiving the alarm prompt message, the target animation can be processed in time to prevent memory from running out (Out Of Memory).

[0111] like Figure 3 As shown, a specific implementation flow chart of a method for determining occupied memory provided by an embodiment of the present disclosure may include the following steps:

[0112] S301: Determine a plug-in by accessing the memory usage information of the target application according to the application location of the target animation adding tool in the target application.

[0113] S302: Determine the plug-in using the memory usage information of the access target application, and deploy the target code corresponding to the loading listener in the constructor of the animation view function to add the loading listener to the animation view function at the application location.

[0114] S303: In response to the animation loading triggering operation, a target animation is loaded for a target application based on an animation view function in a target animation adding tool.

[0115] In this step, after responding to the animation loading trigger operation, the memory occupied information determination logic corresponding to the target code is also correspondingly turned on.

[0116] S304: Obtain component object information for the target animation returned by the loading listener pre-added in the animation view function.

[0117] Here, when the animation view function successfully loads the target image included in the target animation, the loading listener can be triggered, and then the component object information for the target animation returned by the loading listener can be obtained.

[0118] S305: Obtain basic attribute information corresponding to each frame target image of the target animation from the component object information.

[0119] S306: Determine the memory resources required for rendering the target image according to the basic attribute information.

[0120] S307: Generate visualization information of the target image, and generate and display a visualization page of the target animation according to the visualization information of each frame of the target image of the target animation.

[0121] S308: When the memory resources required for rendering the target image are greater than a preset resource threshold, generate an alarm prompt message for the target image.

[0122] Here, there is no strict execution order between S307 and S308, and they can also be executed simultaneously.

[0123] Regarding the specific implementation steps of S301 to S308 above, reference may be made to the above embodiments, which will not be described in detail here.

[0124] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0125] Based on the same inventive concept, the embodiment of the present disclosure also provides a device for determining the occupied memory when the image is loaded, which corresponds to the method for determining the occupied memory when the image is loaded. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the method for determining the occupied memory when the image is loaded in the above-mentioned embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0126] like Figure 4 FIG. 1 is a schematic diagram of a device for determining memory usage when loading an image provided by an embodiment of the present disclosure, including:

[0127] A loading module 401 is used to load a target animation for a target application based on an animation view function in a target animation adding tool in response to an animation loading trigger operation;

[0128] A first acquisition module 402 is used to acquire component object information for the target animation returned by a loading listener pre-added in the animation view function;

[0129] The second acquisition module 403 is used to acquire basic attribute information corresponding to each frame target image of the target animation from the component object information;

[0130] The determination module 404 is used to determine the memory resources required for rendering the target image according to the basic attribute information.

[0131] In a possible implementation, the device further includes:

[0132] A display module 405 is used to generate visualization information of the target image for each frame of the target image based on the target image, the basic attribute information of the target image and the memory resources required for rendering the target image after determining the memory resources required for rendering the target image according to the basic attribute information;

[0133] According to the visualization information of the target image of each frame of the target animation, a visualization page of the target animation is generated, and the visualization page displays the visualization information of each frame of the target image.

[0134] In a possible implementation, the device further includes:

[0135] The prompt module 406 is used to generate an alarm prompt message for the target image for each frame of the target image after determining the memory resources required for rendering the target image based on the basic attribute information, if the memory resources required for rendering the target image are greater than a preset resource threshold.

[0136] In a possible implementation, the first acquisition module 402, when acquiring the component object information for the target animation returned by the loading listener pre-added in the animation view function, is used to start the loading listener pre-added in the animation view function in response to the animation view function successfully loading the target animation, and acquire the component object information for the target animation returned by the loading listener.

[0137] In a possible implementation, the device further includes:

[0138] Adding module 407 is used to add the loading listener according to the following steps:

[0139] For each application location in the target application that uses the target animation adding tool, the plug-in is determined by using the memory occupied information of the target application, and the target code corresponding to the loading listener is deployed in the constructor of the animation view function to add the loading listener to the animation view function at the application location.

[0140] In a possible implementation manner, the second acquisition module 403, when acquiring the basic attribute information respectively corresponding to each frame target image of the target animation from the component object information, is used to determine the image object information of each frame target image required to load the target animation from the component object information;

[0141] According to the picture object information, basic attribute information of each frame of the target picture is obtained.

[0142] In a possible implementation manner, the basic attribute information includes at least one of picture size information, picture name, picture path information of the target picture, and a bitmap of the target picture.

[0143] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0144] Based on the same technical concept, the embodiment of the present application also provides a computer device. Figure 5 FIG. 1 is a schematic diagram of a computer device provided in an embodiment of the present application, including:

[0145] Processor 51, memory 52 and bus 53. The memory 52 stores machine-readable instructions executable by the processor 51, and the processor 51 is used to execute the machine-readable instructions stored in the memory 52. ​​When the machine-readable instructions are executed by the processor 51, the processor 51 performs the following steps: S101: In response to the animation loading trigger operation, the target animation is loaded for the target application based on the animation view function in the target animation adding tool; S102: Obtain the component object information for the target animation returned by the loading listener added in advance in the animation view function; S103: From the component object information, obtain the basic attribute information corresponding to each frame target image of the target animation; and S104: According to the basic attribute information, determine the memory resources required for rendering the target image.

[0146] The above-mentioned memory 52 includes a memory 521 and an external memory 522; the memory 521 here is also called an internal memory, which is used to temporarily store the calculation data in the processor 51, as well as the data exchanged with the external memory 522 such as a hard disk. The processor 51 exchanges data with the external memory 522 through the memory 521. When the computer device is running, the processor 51 and the memory 52 communicate through the bus 53, so that the processor 51 executes the execution instructions mentioned in the above-mentioned method embodiment.

[0147] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for determining the memory occupied when loading an image described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0148] The computer program product of the method for determining the occupied memory when loading an image provided in the embodiment of the present disclosure includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the steps of the method for determining the occupied memory when loading an image described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0149] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK) and the like.

[0150] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0151] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0152] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0153] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, 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, which is stored in a storage medium and includes 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 method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0154] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

[0155] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for determining the memory occupied when loading an image, characterized in that: include: In response to the animation loading trigger operation, loading the target animation for the target application based on the animation view function in the target animation adding tool; Obtaining component object information for the target animation returned by the loading listener pre-added in the animation view function; From the component object information, obtain basic attribute information corresponding to each frame target image of the target animation; Determining the memory resources required for rendering the target image according to the basic attribute information; The method for determining the occupied memory, after determining the memory resources required for rendering the target image according to the basic attribute information, further includes: For each frame of the target image, when the memory resources required to render the target image are greater than a preset resource threshold, generating an alarm prompt information for the target image; For each frame of the target image, based on the target image, basic attribute information of the target image, and memory resources required for rendering the target image, generate visualization information of the target image; According to the visualization information of the target image of each frame of the target animation, a visualization page of the target animation is generated, and the visualization page displays the visualization information of each frame of the target image.

2. The method according to claim 1, characterized in that The obtaining of the component object information for the target animation returned by the loading listener pre-added in the animation view function includes: In response to the animation view function successfully loading the target animation, the loading listener pre-added in the animation view function is started, and the component object information for the target animation returned by the loading listener is obtained.

3. The method according to claim 2, characterized in that The method further comprises the step of adding the loading listener: For each application location in the target application that uses the target animation adding tool, the plug-in is determined by using the memory occupied information of the target application, and the target code corresponding to the loading listener is deployed in the constructor of the animation view function to add the loading listener to the animation view function at the application location.

4. The method according to claim 1, characterized in that The step of obtaining basic attribute information corresponding to each frame target image of the target animation from the component object information includes: Determining the picture object information of each frame of the target picture required for loading the target animation from the component object information; According to the picture object information, basic attribute information of each frame of the target picture is obtained.

5. The method according to claim 1, characterized in that The basic attribute information includes at least one of picture size information, picture name, picture path information of the target picture and a bitmap of the target picture.

6. A device for determining the memory occupied when loading an image, characterized in that: include: A loading module, configured to load a target animation for a target application based on an animation view function in a target animation adding tool in response to an animation loading trigger operation; A first acquisition module is used to acquire component object information for the target animation returned by a loading listener pre-added in the animation view function; A second acquisition module is used to acquire basic attribute information corresponding to each frame target image of the target animation from the component object information; A determination module, used to determine the memory resources required for rendering the target image according to the basic attribute information; A prompt module, configured to generate an alarm prompt message for each frame of the target image, after determining the memory resources required for rendering the target image according to the basic attribute information, when the memory resources required for rendering the target image are greater than a preset resource threshold; A display module, for generating visualization information of the target image for each frame of the target image based on the target image, the basic attribute information of the target image and the memory resources required for rendering the target image, after determining the memory resources required for rendering the target image according to the basic attribute information; According to the visualization information of the target image of each frame of the target animation, a visualization page of the target animation is generated, and the visualization page displays the visualization information of each frame of the target image.

7. A computer device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor executes the steps of the method for determining the occupied memory when loading an image as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program. When the computer program is executed by a computer device, the computer device executes the steps of the method for determining the occupied memory when loading an image as described in any one of claims 1 to 5.