This is my second question today. It turned out (experimentally confirmed) that the leak is due to animation. This is a simple js, html and css:

<img id='myId' src='images/myImg.gif'> 

So, in the first version, I found a js-script, which changes the gif in the fly. I figured that src is not effective every time, and the problem is this. Then I created 3 pictures and began to hide unnecessary ones with the help of that script. To my surprise, there is less memory! Gifok three, 300Kb, 300Kb and 700Kb. For a minute of operation, this function consumes 100 MB from the application. All this works in WebView (for Cardova).

Why do you think this happens? And how is it more rational to fix?

Addition: The effect does not disappear anywhere. It is enough to add 1 line with gif, as the leak begins. I certainly comment on the cycle during the experiment.

  • 2
    Add a minimally reproducible sample code. - XelaNimed
  • no additional code. 1 line. When she starts to play, I get 100 memory leaks - Georgy Chebotarev
  • There are no miracles in the world. Either something in the code, or see what is in the GIF, but it makes sense if the GIF is not yours ... - XelaNimed
  • God, what can I see in the hyphae?) Gif as a hyphae - the designer sent. And the problem is exactly that. I would get rid of webView, but here everything is absolutely done for him - Georgy Chebotarev
  • one
    How arbitrary code is implemented in GIF: marviher.com/topic/6789-zarazhenie-s-pomoschyu-gif It looks like something is happening in your loop. Then you can guess for a long time ... - XelaNimed

1 answer 1

I had to replace the animation with my own js code. This turned out to be much more efficient than the WebView implementation of WebView animation WebView . I would refuse it, but the application entirely is it. What can I say, Cardova 2.9 ... For myself, I explained the problem by saying that the animation is parsed into pictures that are shown in turn. All shots to keep in memory. If there are too many of them, then the animation will survive your memory. So for example, after I replaced the animation with a script, instead of 420 MB of memory, it turned out only 190 MB.