Hacker News new | ask | show | jobs
by winrid 1088 days ago
Well it's kind of tough because the JVM does a lot of this for you! The JVM will try to pack "related" memory closer together. It can even do really cool things for tree structures (like a Node class) and linked lists - which is why you see java perform so well on these types of data structure benchmarks.

In Java we have to worry about different things, like the number of fields on an object and object header sizes. A lot of advice in the article is still good to keep in mind when optimizing code on the JVM, though, like keeping frequently accessed fields next to each other.

1 comments

That sounds interesting, what does the JVM do for tree structures and linked lists? Is that just about compacting memory?