<div dir="ltr">Thanks Paul,<div><br></div><div>The API is a fair bit wordier, but that's the price you pay in exchange for greater expressiveness and flexibility I suppose.</div><div>I'll likely go forward with the MemorySegment implementation then -- I appreciate the reply!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 22, 2022 at 2:21 PM Paul Sandoz <<a href="mailto:paul.sandoz@oracle.com">paul.sandoz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Gavin,<br>
<br>
This is the right place to reach out.<br>
<br>
Using MemorySegment will given you far more control over the description (layout) and management (freeing and pooling) than ByteBuffer. Also, if it’s an issue you will also not be constrained by ByteBuffer’s size limitation. Performance wise using MemorySegment should be as good as or better than ByteBuffer.<br>
<br>
In many respects MemorySegment is a better API to interact with native memory. ByteBuffer was introduced in Java 1.4 with NIO and had additional design constraints in mind that are less relevant today (such as an internal mutable index).<br>
<br>
Paul.<br>
<br>
> On Aug 20, 2022, at 10:35 AM, Gavin Ray <<a href="mailto:ray.gavin97@gmail.com" target="_blank">ray.gavin97@gmail.com</a>> wrote:<br>
> <br>
> Hiya, I hope it's okay that I ask questions here (if not, please direct me elsewhere)<br>
> <br>
> I tried to ask on StackOverflow without much luck, and there aren't many resources<br>
> available at the moment to read about the Foreign Memory API so I'm reaching out here.<br>
> <br>
> I'm implementing a basic database on the JVM and am trying to understand the<br>
> technical implications of using either ByteBuffer or MemorySegment for heap page management and in-memory buffer allocation.<br>
> <br>
> Details are in this thread:<br>
> database - Java: Performance of ByteBuffer versus jdk.incubator.foreign (Panama) Foreign Memory methods (MemoryLayout/Segment) - Stack Overflow<br>
> <br>
> Would appreciate any information folks would be willing to share =)<br>
> <br>
> Thank you,<br>
> Gavin Ray<br>
> <br>
> (By the way, I'm not subscribed to the mailing list, will I be able to reply to responses?)<br>
<br>
</blockquote></div>