0

I've got a question regarding the following memory allocation trace: Huge memory hog on draw As you can see there is a huge memory hog in the draw method of my custom "GaugeView" view. This draw method, however, consists merely of this:

@Override
protected void onDraw(Canvas canvas) {
    outerGauge.draw(canvas);
    canvas.rotate(rotation, rotateX, rotateY);
    canvas.drawBitmap(innerGaugeBitmap,0,0,null);
}

Because of the problem posed in this question it is not easy to rotate the image ahead of time without quality loss. My questions are as follows:

  1. Is my suspicion right, and is this memory hog caused by the canvas.rotate?
  2. How could I rid myself of this problem?
Community
  • 1
  • 1
Daniël van den Berg
  • 2,197
  • 1
  • 20
  • 45
  • The Android Developer reference recommends that a vector image be limited to a maximum of 200 x 200 dpi, as the initial loading of a vector graphic can be relatively expensive, leading to long draw times. Taken from [here](http://thenewstack.io/vector-images-come-android-devs-need-know/) also, since the outer part and circle in the middle does not need rotation(I guess), you could make a 9-Patch or PNG of it,and draw only indicator spike with VectorDrawable. – Harshiv May 30 '16 at 16:25
  • @Harshiv the indicator is drawn to a bitmap elsewhere, and is therefore not a vector image. The problem could indeed lay in the 'outerGauge' being a vector, I will try drawing that one to a bitmap sooner on too, to see if that improves performance. – Daniël van den Berg May 30 '16 at 16:38

0 Answers0