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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:46:38+00:00 2026-05-23T16:46:38+00:00

I have a HashMap that stores external uids and then it stores a different

  • 0

I have a HashMap that stores external uids and then it stores a different id ( internal for our app ) that has been set for the given uid.

e.g:

  • 123.345.432=00001
  • 123.354.433=00002

The map is checked by uid to make sure the same internal id will be used. If something is resent to the application.

DICOMUID2StudyIdentiferMap defined as follows:

private static Map DICOMUID2StudyIdentiferMap = Collections.synchronizedMap(new HashMap());

The load however will overwrite it, if we successfully load, otherwise it will use the default empty HashMap.

Its read back from disk by doing:

FileInputStream f = new FileInputStream( studyUIDFile );  
ObjectInputStream s = new ObjectInputStream( f );

Map loadedMap = ( Map )s.readObject();
DICOMUID2StudyIdentiferMap = Collections.synchronizedMap( loadedMap );

The HashMap is written to disk using:

FileOutputStream f = new FileOutputStream( studyUIDFile );
ObjectOutputStream s = new ObjectOutputStream( f );

s.writeObject(DICOMUID2StudyIdentiferMap);

The issue I have is, locally running in Eclipse performance is fine, but when the application is running in normal use on a machine the HashMap is taking several minutes to load from disk. Once loaded it also takes a long time to check for a previous value by say seeing if DICOMUID2StudyIdentiferMap.put(…, …) will return a value.

I load the same map object in both cases, its a ~400kb file. The HashMap that it contains has about ~3000 key-value pairs.

Why is it so slow on one machine, but not in eclipse?

The machine is a VM running XP it has only recently started becoming slow to read the HashMap, so it must be related to the size of it, however 400kb isn’t very big I don’t think.

Any advice welcome, TIA

  • 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-23T16:46:38+00:00Added an answer on May 23, 2026 at 4:46 pm

    Not sure that serialising your Map is the best option. If the Map is disk-based for persistance, why not use a lib that’s designed for disk? Check out Kyoto Cabinet. It’s actually written in c++ but there is a java API. I’ve used it several times, it’s very easy to use, very fast and can scale to a huge size.

    This is an example I’m copy/pasting for Tokyo cabinet, the old version of Kyoto, but it’s basically the same:

    import tokyocabinet.HDB;
    
    ....
    
    String dir = "/path/to/my/dir/";
    HDB hash = new HDB();
    
    // open the hash for read/write, create if does not exist on disk
    if (!hash.open(dir + "unigrams.tch", HDB.OWRITER | HDB.OCREAT)) {
        throw new IOException("Unable to open " + dir + "unigrams.tch: " + hash.errmsg());
    }
    
    // Add something to the hash
    hash.put("blah", "my string");
    
    // Close it
    hash.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read that LinkedHashMap has faster iteration speed than HashMap because its elements
I have a Hashmap that stores a student name as the key and an
I have hashmap that was created on a page using the struts2 <s:set> tag.
I have a HashMap that I am serializing and deserializing to an Oracle db,
I have a HashMap that I'm using in Processing and I'd like to increment
If I have a HashMap that looks like this: HashMap<String, MyObject> where the String
Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap
I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String,
I have an in-memory cache which stores a set of information by a certain
I have a need to create a report in DynamicJasper that has multiple subreports

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.