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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:00:11+00:00 2026-05-14T00:00:11+00:00

Currently I use a HashMap<Class, Set<Entry>> , which may contain several millions of short-lived

  • 0

Currently I use a HashMap<Class, Set<Entry>>, which may contain several millions of short-lived and long-lived objects. (Entry is a wrapper class around an Object and an integer, which is a duplicate count).

I figured: these Objects are all stored in the JVM’s Heap. Then my question popped in my mind; instead of allocating huge amounts of memory for the HashMap, can it be done better (less memory consumption)?

Is there a way to access Objects in the Java Heap indirectly, based on the Class of the Objects?

With “indirectly” I mean: without having a pointer to the Object. With “access” I mean: to retrieve a pointer to the Object in the heap.

  • 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-05-14T00:00:11+00:00Added an answer on May 14, 2026 at 12:00 am

    No. Basically, each object knows its class, but a class does not know all its objects – it’s not necessary for the way the JRE works and would only be useless overhead.

    Why do you need to know all instances of those classes anyway? Maybe there’s a better way to solve your actual problem.

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

Sidebar

Related Questions

Java Gurus, Currently we have a HashMap<String,SomeApplicationObject> which is being read frequently and modified
I currently use the following method to set the colour of my Row Background.
I currently use Zend_Db to manage my queries $stmt = $db->prepare(INSERT INTO test (ID_Test)
I currently use Devise 2.1 + Rails 3.2.x to authenticate users. I'm also going
I currently use the rectangle shape xml tag to specify borders for my views
I currently use a combination of LVL and Proguard as a first line of
I currently use mysql_real_escape_string to escape a variable when querying the database to prevent
I currently use Berkeley DBs fronted by a Java server for a high-performance disk-backed
I currently use: BufferedReader input = new BufferedReader(new FileReader(filename)); Is there a faster way?
I currently use the free obfuscation tool that ships with VS and it does

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.