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

  • Home
  • SEARCH
  • 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 9177231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:16:35+00:00 2026-06-17T17:16:35+00:00

I already tried to find a solution to my problem in this and in

  • 0

I already tried to find a solution to my problem in this and in some other sites but with no luck. I have a map (Google map V2) set on my app. This map is full of markers (around 450) and each marker has an icon set from a drawable file. The drawable files are in total 6 so there are about 450 markers repeating 6 drawables (each different icon refers to a location on the map). When I first launch the map, there are no problems and everything works fine. But if I go back to the previous screen and launch again the map, the app crashes with an out of memory error. I think the problem is due to the fact that the system is keeping in memory all the bitmaps, with an incredible waste of resources, seen that the drawables are only six.

I tried to reference the bitmaps to the application context as suggested here with no good results. Is there an easy way to solve this issue?

Line 324:

if (IDTipologia.get(i).equals("1")) {
            setLoghino(R.drawable.chieseluoghidiculto);
            //iconcina = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);
            Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
                    R.drawable.markerchiese);
            iconcina = BitmapDescriptorFactory.fromBitmap(icon);
}

ad so on until the 6th drawable.

Logcat:

E/AndroidRuntime(10990): FATAL EXCEPTION: main
E/AndroidRuntime(10990): java.lang.OutOfMemoryError
E/AndroidRuntime(10990):    at android.graphics.Bitmap.nativeCreateFromParcel(Native   Method)
E/AndroidRuntime(10990):    at android.graphics.Bitmap.access$000(Bitmap.java:28)
E/AndroidRuntime(10990):    at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:1052)
E/AndroidRuntime(10990):    at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:1044)
E/AndroidRuntime(10990):    at com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate$Stub.onTransact(IBitmapDescriptorFactoryDelegate.java:101)
E/AndroidRuntime(10990):    at android.os.Binder.transact(Binder.java:297)
E/AndroidRuntime(10990):    at com.google.android.gms.internal.h$a$a.a(Unknown Source)
E/AndroidRuntime(10990):    at com.google.android.gms.maps.model.BitmapDescriptorFactory.fromBitmap(Unknown Source)
E/AndroidRuntime(10990):    at it.eventitrapani.appaeventitp.ElencoMappaTutteCoseDaVedere.addMarkersToMap(ElencoMappaTutteCoseDaVedere.java:324)
E/AndroidRuntime(10990):    at it.eventitrapani.appaeventitp.ElencoMappaTutteCoseDaVedere.setUpMap(ElencoMappaTutteCoseDaVedere.java:269)
E/AndroidRuntime(10990):    at it.eventitrapani.appaeventitp.ElencoMappaTutteCoseDaVedere.setUpMapIfNeeded(ElencoMappaTutteCoseDaVedere.java:257)
E/AndroidRuntime(10990):    at it.eventitrapani.appaeventitp.ElencoMappaTutteCoseDaVedere.onCreate(ElencoMappaTutteCoseDaVedere.java:208)
E/AndroidRuntime(10990):    at android.app.Activity.performCreate(Activity.java:4470)
E/AndroidRuntime(10990):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
E/AndroidRuntime(10990):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
E/AndroidRuntime(10990):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
E/AndroidRuntime(10990):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
E/AndroidRuntime(10990):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
E/AndroidRuntime(10990):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(10990):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(10990):    at android.app.ActivityThread.main(ActivityThread.java:4511)
E/AndroidRuntime(10990):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(10990):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(10990):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
E/AndroidRuntime(10990):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
E/AndroidRuntime(10990):    at dalvik.system.NativeStart.main(Native Method)
  • 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-17T17:16:37+00:00Added an answer on June 17, 2026 at 5:16 pm

    First of all, why are you loading your bitmaps from resources like that? You can get a Drawable directly from your resources getResources().getDrawable(R.drawable.blah). If you retrieve the Drawable like that, they will all share the underlying Bitmap, so there would only be N (where N is the number of marker icons you have) bitmaps loaded in memory.

    Now, if you are applying some transformation to the drawable you might need to call mutate() on it first to get a new Drawable with a separate state (otherwise if you make one transparent ALL of them will become transparent).

    Update:
    Solution was to use the marker icon initialization that uses a resource ID instead of a bitmap directly:

    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to find a solution to my problem already in google and here
I've tried googling for a solution to this problem but haven't yet found one.
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
Getting the active application is not a problem, I already have this implemented. What
So i tried for some time to find a case like mine but couldnt
I have already tried multiple ways. defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME=YourNameHere;}' Also i've tried
The problem is in the title, I'll try to list what I've already tried
I cannot import a maven project with WTP features enabled. I have already tried:
Yes, this is probably yet another greatest-n-per-group question... But I've tried at least a
I know this question has been asked before, but I've tried everything I could

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.