Open evacchi opened 1 month ago
I'm in favor of .withMemoryFactory()
:+1: as it also covers the possibility of experimenting with new JVM features and offheap memory.
updated the top post with a reference to off-heap 👍
I think these are complementary features. The MemoryFactory
interface would accept MemoryLimits
. We shouldn't mix the allocation or access strategy with memory limits.
Related, I noticed that Instance.Builder#validateHostMemoryType
allows MemoryLimits.MAX_PAGES
(65536) and converts that to Memory.RUNTIME_MAX_PAGES
(32767). But any intermediate value would fail. Is this the intended behavior?
Memory.RUNTIME_MAX_PAGES
I don't think that's intended...
Modules are able to define their own memory constraints, but one useful feature of Wasm engines is to allow the host to control the use of resources of the guests.
We should allow end-users to refine the memory constraints of a Wasm module so that 1) we can impose finer restrictions on modules that have been compiled with default values (i.e. unrestricted limits) 2) rogue instances cannot grow their memory indefinitely
.withMemoryLimits()
on theInstanceBuilder
..withMemoryFactory()
for other use cases (e.g. experiment with alternative allocation strategies, such as off-heap/MemorySegment) In this case, however, it would be also useful to define a specific, built-in factory that allows to easily constrain memory limits; e.g..withMemoryFactory(MemoryLimits.of(...))