Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7816379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:50:49+00:00 2026-06-02T05:50:49+00:00

So, I am working on a game in android, and I was checking out

  • 0

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.

Will

Edit:

I wasn’t exactly clear on what was happening, sorry, was late when I posted this.

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

    public void onDraw(Canvas c)
    {
        c.drawColor(Color.BLACK);
        Point[] touchPlacesHolder = touchPlaces;
        for(int i = 0; i < 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 < event.getPointerCount(); i++) 
        {
            touchPlaces[i] = new Point((int) event.getX(i), (int) event.getY(i));
        }
        return true;
    }

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.

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);
        }
    });
}

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.

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!

Edit again:

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.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:50:51+00:00Added an answer on June 2, 2026 at 5:50 am

    possible optimizations for both speed and memory:

    1.how about using a fixed size array of max touch events and update it instead of creating a new one every time ? it’s a single thread that handle both so there should not be anything to worry about it .

    2.invalidate only the areas that should be updated. this could improve speed.

    3.update the touch events only before you know you wish to update .

    4.not sure what is the game , but you can use a fixed size bitmap and write to it instead of saving the touch events.

    5.since it’s a game , most of the memory is probably used for images ,sounds and videos . try to check if that’s a problem. since the classes that you’ve checked are 1-byte arrays , it might be the case of images. for more information on loading heavy resources, check :
    http://developer.android.com/training/displaying-bitmaps/index.html

    having a large heap size might indicate that you are creating a lot of small objects or a few large objects in a short time , since the gc take some time till it does something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title says, I'm going to start working on a 2D Android game
I'm working on an android game with OpenGL, and I have a game update
I am developing a game for android an i'm working on the menu screen
I'm working on a game bot. I'd like to place there something like a
I am working on a cross-platform mobile game for Android and iOS devices. I
I'm new to android game development. I currently working on a simple android app
Ahoy, I'm working on an OpenGL ES based game for Android using the NDK.
I'm trying out some game engines for android and came across cocos2d-android-1 . I've
I am working on a game in Android and I have Bitmap objects being
I'm working on a game for Android where the explorable areas will be randomly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.