aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

WASM: Cannot enlarge memory arrays.

Open phanronald opened this issue 8 years ago • 8 comments

I get this error when I am trying to do some complex c# foreach loops and recursion. Did not see anywhere that I can add any of these settings.

WASM: Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 2147352576, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0

phanronald avatar Jun 27 '18 07:06 phanronald

Can you please post a minimal repro?

Blazor's build of the Mono WebAssembly runtime does have the ALLOW_MEMORY_GROWTH=1 flag. Is it possible you're doing something extremely nonstandard with a custom build of Mono WebAssembly?

If not, we'd really need a repro case to be able to investigate. Maybe there's some totally unrelated bug that's getting reported in a strange way.

SteveSandersonMS avatar Jun 28 '18 08:06 SteveSandersonMS

I had similar issue and the reason was a recursive/infinite loop due to a property's set calling itself and adding bunch of elements in a list in each recursion.

On Thu, Jun 28, 2018, 2:09 PM Steve Sanderson [email protected] wrote:

Can you please post a minimal repro?

Blazor's build of the Mono WebAssembly runtime does have the ALLOW_MEMORY_GROWTH=1 flag. Is it possible you're doing something extremely nonstandard with a custom build of Mono WebAssembly?

If not, we'd really need a repro case to be able to investigate. Maybe there's some totally unrelated bug that's getting reported in a strange way.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aspnet/Blazor/issues/1045#issuecomment-400958460, or mute the thread https://github.com/notifications/unsubscribe-auth/ACnwPw8mOKbYt19sEGtembsSqSA4d_uAks5uBJYvgaJpZM4U5MEH .

neerajbharti avatar Jun 28 '18 09:06 neerajbharti

Okay, I will post my code when I get a chance. Actually this code was originally in tyescript and I just ported it to c#, so I will post both version so you can see both and maybe I missed something.

Thanks,

phanronald avatar Jun 28 '18 18:06 phanronald

Just a minimal (short) C# repro will be relevant, thanks!

SteveSandersonMS avatar Jun 28 '18 18:06 SteveSandersonMS

Here is the code on github to help resolove this issue. The issue occurs when:

  1. You launch the site, and click on the first image on the landing page
  2. click on the third button (under the text "Warn...") and a modal should pop up.
  3. click a radio button and then hit the select button and in the console you will see the error

https://github.com/phanronald/KawasakiReproject/tree/AXBuilder/KawasakiReproject/AxBuilder

phanronald avatar Jul 01 '18 20:07 phanronald

@phanronald Thanks for posting. If you want to track this down, I'd suggest:

  • Figure out exactly which line of code is running immediately before the error occurs. Since it's not currently possible to attach a debugger to .NET running on Mono WebAssembly (though we're working on that!), the best way is to put a series of Console.WriteLine calls in different places to find out how far the execution is progressing.
  • When you have determined exactly which bit of code triggers the error, recreate the error in a clean new project as a minimal block of standalone code that produces it. Hopefully you can reduce it down to 10-20 lines or less.
    • At that point, there's a good chance you'll realise there was some bug in the application code causing it to allocate memory infinitely, or something like that
    • Or if at that point you believe your repro code should be valid and in fact there's a bug in Blazor or Mono, please post that minimal standalone repro code (not an entire project) and we'll be happy to have a look

Hope that's OK and makes sense. Please let us know whether you plan to undertake this investigation. If so we'll leave the issue open for a short while.

SteveSandersonMS avatar Jul 02 '18 08:07 SteveSandersonMS

@SteveSandersonMS you are right there was an infinite loop, sorry for the trouble. Thanks,

phanronald avatar Jul 03 '18 06:07 phanronald

Thanks for confirming.

SteveSandersonMS avatar Jul 03 '18 08:07 SteveSandersonMS