0

So I have a simple Activity with following code:

public class MainActivity extends FragmentActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag("tag");

            if(fragment == null) {
                fragment = new SupportMapFragment();

                getSupportFragmentManager().beginTransaction()
                        .replace(android.R.id.content, fragment, "tag").commit();
            }
        }
    }

When I keep on rotating the screen I can see the memory heap is increasing in DDMS. Even if I do several GCs the memory never returns to a normal level. Am I doing something wrong or did Google just release their new maps api with a serious memory leak?

Tested on HTC Desire - Android 2.2.2

Edit: Also tested on Samsung galaxy S3 - Android 4.1.2

Edit: Didn't give OOM but the heap doesn't fall down before I move around on the map etc.

Warpzit
  • 27,966
  • 19
  • 103
  • 155

1 Answers1

0

Must be something different. I have a maps app and it doesn't do that - but I run android 2.3.3 (API 10+)

meredrica
  • 2,563
  • 1
  • 21
  • 24
  • I'm not talking about the maps app. I'm talking about your own implementation with the new android maps api. – Warpzit Jan 09 '13 at 14:01
  • Yes I know - I was not talking about google maps either. I have written an app that uses the supportMapFragment and I do not see any memory leaks. – meredrica Jan 09 '13 at 14:07
  • I've just tested on my samsung galaxy s3 and I get the same results. The heap slowly increased for each time the view is reloaded (rotated) and never returns to a reasonable level again. – Warpzit Jan 09 '13 at 14:09
  • Seems like I've been jumping the gun, it does increase and doesn't fall right away but it never reaches a critical level. I guess it gets more aggressive the less memory there is available. – Warpzit Jan 09 '13 at 14:34