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 8036503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:38:32+00:00 2026-06-05T02:38:32+00:00

I am having OOM issues with java.util HashMap so I am looking for memory

  • 0

I am having OOM issues with java.util HashMap so I am looking for memory friendly HashMap alternatives to standard Java Hashmap. I tried Trove and it improved a little but still ends up with OOM from time to time. I can accommodate some speed loss if memory is efficient.

I am not looking for a DB. File-based HashMap implementations are also fine as long as they are working offline. I am storing primitives like int and byte.

Also, please indicate if you had any experience and how much improvement you had in terms of 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-05T02:38:34+00:00Added an answer on June 5, 2026 at 2:38 am

    I can think of two options that would work for you — which is the best entirely depends on your application.
    The first is to use WeakReference or SoftReference. Now keep in mind that as of Android 2.3 the VM has become much more agressive so collecting VM may collect these type of references more frequently. Personally, I’m not a huge fan of using these type of references for this sole reason but some individuals might argue differently.
    The second option, and the one which I would recommend, is to look in to an LRU cache. You can implement your own LRU cache using a LinkedHashMap. But if you are using your map for storing Bitmaps I would strongly suggest you have a look at the Bitmap Cache provided by the Android compatibility package which includes a bitmap cache.
    Here’s a few links you can use to read up on:

    Weak References

    Soft References

    LRU Cache using LinkedHashMap

    Android Bitmap Cache and why you should avoid Weak/Soft References

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

Sidebar

Related Questions

Having a standard WinForms 2.0 PropertyGrid control I'm looking for a way to either
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and
I'm having issues with threads not executing. I followed the docs on how to
Having a little trouble in getting image attachment urls in wordpress. This is my
Having val hm: HashMap[org.joda.time.DateTime, MyType] I am trying to get the first and the
Having a bit of a problem, Due to the source-control set-up we use, each
Having volunteered to maintain a stagnant CPAN package (GnuPG) I'd like improve the install
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having just pulled my hair off because of a difference, I'd like to know
Having the following class: public class SomeClass { private readonly int[] _someThings; public SomeClass()

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.