Using the off-heap memory to store and process large amounts of data didn't change in Java since Java SE 4, when ByteBuffer was introduced. Since then, operating systems moved from 32 bits to 64 bits, and the available RAM in a regular machine moved from megabytes to gigabytes, and more. Another API was much needed, as a ByteBuffer is a 32 bits buffer, not enough for modern applications. First published as a preview feature in Java SE 19, the Foreign Function and Memory API made it as a final feature in Java SE 22. The Memory part brings several new concepts. Among them Arenas and MemorySegments now give you the possibility to manage gigabytes of contiguous off-heap memory, with a very elegant layout model. On the other hand, MemoryLayout allows for a C-struct like organization of your data in memory.
This presentation shows you this complex API, in a step by step approach. It explains how your data is organized and aligned in memory, and the impact it has on the API. It also focuses on the delicate use of VarHandle, a critical element to access your data. It then shows you how you can load large files in memory segments, and shows you the performance you can get in the processing of billions of data elements.
This presentation shows you this complex API, in a step by step approach. It explains how your data is organized and aligned in memory, and the impact it has on the API. It also focuses on the delicate use of VarHandle, a critical element to access your data. It then shows you how you can load large files in memory segments, and shows you the performance you can get in the processing of billions of data elements.
José Paumard
José Paumard
José is a Java Developer Advocate at Oracle. He holds a PhD in applied mathematics and computer science. He has been an assistant professor at the University Sorbonne Paris Nord for 25 years. He is an active member of the Paris Java User Group, and a disorganizer of the JChateau unconference. He contributes Java learning content on the dev.java website. He publishes "Java Coding Tips", a biweekly series of shorts, and the "JEP Café", a video series, both on the Java YouTube channel.
Remi Forax
Université Gustave Eiffel
I'm a tenured assistant professor at Université Gustave Eiffel (near Paris France).
I worked on writing the spec (and sometimes small part of the implementation) of invokedynamic and the package java/lang/invoke, the new string concatenation, lambdas, modules to Java. I'm currently working on the OpenJDK projects Amber (record, sealed types, pattern matching) and Valhalla (value types and specialized generics).
I've spoken to numerous conference in France, Europe and in the US.
I worked on writing the spec (and sometimes small part of the implementation) of invokedynamic and the package java/lang/invoke, the new string concatenation, lambdas, modules to Java. I'm currently working on the OpenJDK projects Amber (record, sealed types, pattern matching) and Valhalla (value types and specialized generics).
I've spoken to numerous conference in France, Europe and in the US.