DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Data
  4. Size of an entry in a Map

Size of an entry in a Map

Peter Lawrey user avatar by
Peter Lawrey
·
Aug. 01, 11 · Interview
Like (0)
Save
Tweet
Share
5.31K Views

Join the DZone community and get the full member experience.

Join For Free

There have been some very good articles on the size of a map. However as a map grows, it initial size become less important and the size per entry is what matters.

How are the sizes measured

In these tests an int key and long values are used. This adds a small but realistic size to each entry.

Size per entry of a medium sized Map

The following are the size per entry in bytes. The Map has 1024 entries.

Type of Map 32-bit 64-bit compressed 64-bit not compressed
TIntLongHashMap 26.9 26.9 27.0
FastMap (recycled) 32.0 39.9 47.9
IdentityHashMap 48.0 56.0 80.0
ConcurrentSkipListMap 68.3 76.1 108.3
TreeMap 64.0 80.0 112.0
HashMap 64.0 80.0 112.0
SynchronizedMap 64.0 80.0 112.0
ConcurrentHashMap 65.2 81.4 114.0
Properties 68.0 84.0 120.0
Hashtable 68.0 84.0 120.0
LinkedHashMap 72.0 88.0 128.1
WeakHashMap 80.0 88.0 136.1
 
The Javolution FastMap needed to be recycled. If it is not recycled, it was the largest per entry.

Conclusion

It may be worth considering The GNU Trove collections if you have primitive keys and/or values. However if you have non-trivial keys or values classes, the size of the collection is less likely to matter.

The Code

SizeOfMapsTest.java

 

From http://vanillajava.blogspot.com/2011/07/size-of-entry-in-map.html

64-bit Data structure 32-bit Javolution Testing Trove Property (programming) Data Types GNU

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Chaos Engineering Tutorial: Comprehensive Guide With Best Practices
  • Assessment of Scalability Constraints (and Solutions)
  • Top 5 Data Streaming Trends for 2023
  • Keep Your Application Secrets Secret

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: