donovano opened Issue #1872:
Hi, If you specify
static_memory_maximum_size(0)
then wasmtime will use dynamic memory for the linear wasm memory. If you don’t set it, by default the memory will be static. I note that settingstatic_memory_maximum_size
to anything less than 4GB on my platform results in wasm using dynamic memory and setting it above that it uses static memory. So the maximum memory (in my case anyway) is 4GB. I can see in the code that it sets the default of 4GB, but I cannot see how this is configurable, if it is?I also note that for my wasm module the memory starts at 22 pages (of size 64K each). On top of that I can only allocate about 1/3 of 4GB before the allocations in the wasm module fail, even though the device has 16GB memory and not running much more than the wasm host and the wasmtime max memory is at 4GB. This observed 1/3 of 4 GB limit is present whether wasmtime uses dynamic memory (
static_memory_maximum_size(0)
) or static memory. Does this make sense?
bjorn3 commented on Issue #1872:
Can other programs use more than 1/3 of the 4 GB limit? If not then maybe the maximum memory usage is limited using ulimit or cgroups?
donovano commented on Issue #1872:
A simple C program can allocate upto 9GB (did not try more). ulimits is unlimited and cgroups show a very high limit.
sunfishcode commented on Issue #1872:
Does your simple C program perform one allocation or multiple smaller allocations? Wasm linear memory needs to be contiguous, and sometimes restricted address spaces which have enough total space lack the ability to allocate a single contiguous region with sufficient space.
donovano commented on Issue #1872:
You are right. I had copied the action of the rust code that was incrementally allocating more memory to debug the issue to the C program to also incrementally allocate for debugging. Changing this to a single allocate fails about at the same point as the wasm. That explains that issue thanks.
The only remaining thing here is that the 4GB default would be nice to adjust lower - this might be possible but I did not see where this is done so far.
bjorn3 commented on Issue #1872:
Should this be closed in favor of #2273?
Last updated: Dec 23 2024 at 12:05 UTC