WebAssembly and file upload to a module

Damn. Completely lost track of this thread. Sorry about that. The GC should run automatically in a (javascript) timer (ie after your code isn’t running anymore and control returned to javascript).

Note that all native Island stuff has the same memory usage as on other platforms, what has a bit of overhead is dynamic dispatch, but there are tricks to avoid that. One example is above, instead of asking for data by iterating a js byte array , get all data over in 1 go.

1 Like

Carlo, thank you for the clues. As I’ve mentioned before I made changes in my project and now I copy JS arrays instead of iterating through them. It improved the situation a little bit but still the amount of consumed memory is excessive. The same code run on .NET takes a tiny fraction of memory compared to WASM. I’ve tried to tinker with GC, hand control over back to JS but nothing seems to help. Would you please write me a piece of code that forces garbage collection and/or disposal of an object?

GC.Collect should force a GC ofc, but I’m now curious as to what you’re doing exactly that causes this. Can you show a hot path? So I can see whats going on.

Sorry for the long pause, unfortunately covid hit me few days ago and I wasn’t in a “working condition” up to now…

GC.Collect should force a GC

I don’t see a global GC object, only SimpleGC but it doesn’t have a Collect method. SimpleGCExt has it but what does the c argument mean? Is it the max generation to collect (as in .NET)? How to get the max generation value then?

but I’m now curious as to what you’re doing exactly that causes this. Can you show a hot path?

I’ve discarded all the code changes before the last post in hope that you’ll send me something that works :smile:.

1 Like

It looks like you’ll want Utilities.Collect

@ck, this seems wrong; why, for WebAsse,nly/SimpleCG, is this an extension for Utilities, and not on SimpleGC? For BoehmGC (i.e. non-WebAssembly), it’s on the BoehmGC class itself — this seems inconsistent? Want me to fix this?

Please yes.

2 Likes

Is Utilities.Collect() the same as SimpleGCExt.Collect()? And what about the integer you need to pass to the method? What is it and what should be its value?

I believe the integer is the level of GC to run. It’s mainly there for consistency, on WebAssmebnly it is ignored, as there is only one level

I believe so. note that in 2687 this is moved to SimpleGC.Collect and/or the cross-platform compatible DefaultGC.Collect, which is a type alias to the platform’s default GC.

@mh & @ck, I started playing with GC outside of our big project and immediately found why it failed there. It seems that it’s way too aggresive and wipes things it shouldn’t. A test case:
wasm_gc.zip (13.5 KB)

Logged as bugs://E25500.

Thanks; Ill take a look

My apologies for missing this, on Friday.

@mh & @ck, three issues:

  1. The GC problem I recently reported doesn’t appear if I don’t manually call Collect. This leads to a conclusion that GC never collects anything if not forced to and that’s where the huge memory consumption comes from. When is GC expected to automatically collect?

  2. I think I’ve already asked it somewhere above - is there any way to force disposal of a particular object? I’ve tried this SimpleGC.ForceRelease(IntPtr(InternalCalls.Cast(_obj))) but it doesn’t seem to get the job done.

  3. WASM debugging is broken in the latest Elements preview (11.0.0.2687) - when you try to start debugging it says it cannot find the WASM file. Also, after the installation the debugger reported missing coloader80.dll - I had to register it manually.

Water or VS?

Curious; never heard of that .dll, that’s not ours or part of our debugger, as far as I know…

I’ll have to leave 1. and 2. for @ck,

Debugger problem is in VS.

1 Like

Thanx. FTR, Water works fine for me with 2687. Does it work for you too, as a workaround for now?

Logged as bugs://E25502.

Hello!

I can’t reproduce the problem in VS with Elements 11.0.0.2688 . What VS version do you use?

Hi,

I experience the problem on VS 2015.

@mh thanks for the suggestion. I decided to downgrade for now.

Ah. VS2015 is on legacy support for a while now. i suggest updating to VS2017 or later.

which version did you downgrade to, that works.