A few FFM questions

Brian S O'Neill bronee at gmail.com
Mon Jul 10 15:02:22 UTC 2023


I want to avoid polluting the other thread, which no longer has a valid 
subject line anyhow...

1) The size limit of a memory segment is defined by a signed value, thus 
limiting the address space to be 63-bit. Is it likely that all 64-bit 
architectures today and in the future only use the lower half of the 
address range?

2) The MemorySegment copy operation is safe for use against overlapping 
ranges, and is thus a "memmove" operation. My application would benefit 
from also having a "memcpy" operation, for those cases where I know that 
the ranges don't overlap. Can such an operation be added?

3) Dynamic memory allocation is performed against Arenas, but freeing 
the memory is only allowed when the Arena is closed. I find this to be 
cumbersome at times, and in one case I ended up creating a single Arena 
instance paired with each allocation. The other solution is to directly 
call malloc/free, which is what I'm using in some places. Both solutions 
are messy, so is it possible to add a simple malloc/free API?

4) GuardUnsafeAccess. I understand that this was added to ensure that 
accessing a memory mapped file which was been truncated doesn't crash 
the JVM. What is the overhead of this check? Given that my module 
requires restricted access anyhow, it can already crash the JVM. Would 
it be possible to support unguarded memory access operations too?


More information about the panama-dev mailing list