title: Android Heap 1-Byte array type extremely large
body: <p>So, I am working on a game in android, and I was checking out the heap and allocations to see if there was anything going wrong with memory and what not. When I got to the heap, it told me that it had allocated 33 mb for my game, and 31 mb was allocated to 1-byte array types. I went through trying to figure out why this was as large as it was, but I had no luck, and no idea what to look for even. Does anyone have any ideas? Thanks in advance! Let me know if you need any more info.</p>
  
  <p>Will</p>
  
  <p>Edit:</p>
  
  <p>I wasn't exactly clear on what was happening, sorry, was late when I posted this.</p>
  
  <p>Basically I made a simple multitouch checker, code below, and when I ran it, I decided to check the heap. As I said above it was extremely large for what I was doing, just getting points and sticking a circle on it using draw</p>
  
  <pre><code>    public void onDraw(Canvas c)
      {
          c.drawColor(Color.BLACK);
          Point[] touchPlacesHolder = touchPlaces;
          for(int i = 0; i &lt; touchPlacesHolder.length; i++)
          {
              c.drawCircle(touchPlacesHolder[i].x, touchPlacesHolder[i].y, 100, paint);
          }
      }
  
      public boolean onTouchEvent(MotionEvent event){
          touchPlaces = new Point[event.getPointerCount()];
          for (int i = 0; i &lt; event.getPointerCount(); i++) 
          {
              touchPlaces[i] = new Point((int) event.getX(i), (int) event.getY(i));
          }
          return true;
      }
  </code></pre>
  
  <p>I am running this activity by linking it to a button on another via intent, the code is below. I am not sure if it has anything to do with the way I linked the 2 or not, maybe I caused a memory leak there.</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      final Window win = getWindow();
      win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.main);
  
      final Button newGame = (Button) findViewById(R.id.new_game_button);
      newGame.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
              // Perform action on clicks
              Intent intent = new Intent(v.getContext(), Platformer.class);
              startActivity(intent);
          }
      });
      final Button levelEditor = (Button) findViewById(R.id.level_editor);
      levelEditor.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
              Intent intent = new Intent(v.getContext(), LevelEditor.class);
              startActivity(intent);
          }
      });
  }
  </code></pre>
  
  <p>As you can see, I have another activity attached to the buttons in the second bit of code I showed, but I figured I would ask about the simpler example because they are both using the same amount of memory, even though one is using bitmaps and the other isn't. </p>
  
  <p>So, basically my question is, why would something as simple as this require such a large heap, and why would it use so much of it when something much more complex like cut the rope is about half the size. Thanks!</p>
  
  <p>Edit again:</p>
  
  <p>I just changed the manifest to start with the simplest one and left the main menu and the other activity out. The multitouch tester had about 12 mbs used of its 13 mb heap. I did the same thing for the menu and it had about 25 mb allocated and was using most of it, and the other class I didn't show used about 25 as well. </p>
  
  <p>So, I'm guessing the extra memory being used it from it holding the menu in memory, but I am not sure why it is using so much memory for the menu in the first place. Any idea how to fix that or fix the way it is holding it in memory?</p>