Struct/value types + stack allocations

Ismael Juma mlists at juma.me.uk
Thu Jan 19 00:18:10 PST 2012


Kirk Pepperdine <kirk at ...> writes:
> Sorry, but I'm still not seeing a use case for this.
> What is it that you're trying to do that you can't accomplish with a class?

The issue is that objects have a lot of memory overhead. John Rose talks about 
the Complex example with a description of a potential implementation here:

http://blogs.oracle.com/jrose/entry/tuples_in_the_vm

Say you want to store a long array of a tuple of ints. The common way to avoid
overhead these days is to use 3 int arrays with inferior cache locality to
avoid the huge memory overhead (Yes, I know an alternative is to use one long
array for two ints for better cache locality for the pair and I've done that
at times). This is not great.

"What would this look like in the language or are we only talking about changes
in the JVM?"

If Java the language decided to adopt this (which is not a strict requirement),
then the C# model seems like the obvious one to draw inspiration from.

Best,
Ismael



More information about the hotspot-runtime-dev mailing list