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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:11:42+00:00 2026-06-18T08:11:42+00:00

I have searched for an answer, but I didn’t find anything that could answer

  • 0

I have searched for an answer, but I didn’t find anything that could answer 100% my question. 😀
So, I need to create from an hashmap other 3 new hasmaps, exchanging 2 of its values in 3 different ways (I use map2.putAll(map1) and later switch 2 values), later I have to store the hashmaps in a ordered priorityqueque, and later poll one of them and repeat the process.

The problem starts since I have to do this A LOT of times, since a special condition isn’t satisfied…and there’s no way to reduce the number of maps I do (well, I may block duped ones, but it would be very expensive i think :/ ).

Actually, I don’t really mind if I store all the maps somewere (from what I read, I figured out that’s GC fault) or if I have to do other tricks… I just want to get my code working, without (if possible) using stuff like that ‘-XX:-UseGCOverheadLimit’ because it’s a sort of homework (even if with no mark), and it must work with ‘java classname’ from prompt.

The only limit is on time (which is not a problem, 100% sure about it, already tested), and it will be tested with just simple inputs (in which is already good), but I’d like to made it able to do even difficult ones.

I thank you in advice.

Oh, the maps are of this kind: <Integer,Integer> and have size of 16. Unfortunately, I can’t post the code here since the homework is not ended yet (even if I submitted mine).

  • 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-18T08:11:43+00:00Added an answer on June 18, 2026 at 8:11 am

    It’s hard to judge from the description what happens in your code exactly, but if the memory overhead of allocating and trashing maps is what’s killing you you can just cache Map instances and reuse them. Use some object pooling implementation, there’s loads around, or just use a Stack as an object pool if there’s just one thread.

    The other issue you have is using Integer will cause massive memory churn, and as Integer is immutable, that’s a bit of a pain. Replace your Map with the Trove int/int map and you’re sorted 🙂

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

Sidebar

Related Questions

I have searched for an answer but couldn't find it anywhere. My question is
Hello I searched for an answer to this question but didn't find any here.
Searched, but couldn't find a good answer. I have an ASP.NET application that I
HI! I have searched a lot, but I didn't find the answer to this
I have searched many topics and didn't find the answer, or question was too
I searched across the web but I didn't find any satisfying answer. I have
I have searched a lot to find the exact answer but didn't find any.
I have searched this question but didn't get / or understood the answer I
sorry for this question, but I searched it and I didn't find an answer
I have searched a bit on google, but didn't really found an answer to

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.