-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[browser] why is the garbage collector not doing its job? #108397
Comments
This GC issue seems to be specific to wasm, couldn't replicate on a maccatalyst target for example. |
@DierkDroth could you please try to reproduce on non-Uno template ?
|
@pavelsavara unfortunately this is beyond my expertise. I do know how to code a UI in WinUI3 - which is why I'm using UNO WASM, since this basically is WinUI3 code running as WASM in browser. But I would not know how to code a different, but equivalent, repo in a different technology. Sorry... So, if you feel the issue might be related to Platform UNO WASM support and not to .NET WASM support, then I suggest you get in touch with @jeromelaban (CTO UNO). AFAIK the UNO guys are in close contact with the Microsoft team anyway... |
This is not an issue specific to Uno, and Uno does not do anything related to the GC. This specific behavior is likely reproducible on net8/net9 by overallocating close to 1.5GB, then allocate/release small amounts just below the limit, and the GC will not run unless explicitly told. |
@pavelsavara would you mind explaining why you closed this issue although @jeromelaban and I can easily demonstrate and reproduce the problem and - according all we know at this point - it appears to be MONO WASM GC issue? |
I would appreciate simpler repro, thanks |
@pavelsavara I definitely can understand your request - as probably @jeromelaban can. However, you likely needed to go by the trustworthy confirmation of @jeromelaban that UNO is not 'part of this game'. |
@pavelsavara could you please elaborate what else - apart from the repo which is available on link above - you would need from me? |
@jeromelaban does Uno allocate some native memory via |
@pavelsavara this is .NET 8 latest. I'm staying clear of any .NET 9 and VS previews/RCs (learnt from past experience). |
There are no native allocations in this context, only managed ones. Running the GC manually effectively reclaims what needs to be reclaimed. Could it be that the threshold of allocations makes it that the GC does not trigger, and that the pressure of reaching 1.5GB is not considered? |
Good question. Are there delegates/events in this repro ? |
Not in my user/repo code. Not sure if there would be anything from UNO's perspective ... @jeromelaban ?!? |
There are many delegates, yes. This is used all over the place in Uno, and also in the sample itself. Do they play a play a role because of their GC pressure (or lack thereof)? |
It would be good to test if this reproduces with Net9. @jeromelaban is Uno Net9 compatible ? |
The example allocates 1.5 GB of data as 1MB large arrays. @DierkDroth does your application really allocate many arrays bigger than 64KB ? Or this is just synthetic example that demonstrates same symptoms ? |
@pavelsavara AFAIK UNO is compatible with .NET9. However, I will not install any .NET9 or VS previews/RCs on my machine ... installing previews (.NET/VS) screwed up my machine big time a few years back ... I won't do that again. The repo is just a 'synthetic example'. The allocation in the repo is to 'preload' the GC. You also can reproduce the problem by removing the 'preload' code. You then have to wait (much) longer to experience the failure. |
Yes, it's net9 compatible. RC2 should help. |
Large allocations (LOS) are triggering Net8/emscripten dummy implementation of There is slightly better custom cc @kg |
@pavelsavara you could amend the repo and allocate smaller memory blocks (64KB?) to eliminate the LOS variable... |
I don't have Uno on my box. |
It will be best to try the sample with net9/net10 where the runtime is using the official workloads. It will be easier to do starting from RC2. |
AFAIK this is not needed. VS should download the required NuGet packages when building no? |
Could you please collect console logs after you set
from the real app, not from synthetic repro |
@DierkDroth you can use this instead: https://platform.uno/docs/articles/external/uno.wasm.bootstrap/doc/features-environment-variables.html for Uno. |
@pavelsavara I'm sorry, but this won't help. I personally did never encounter the underlying OutOfMemory problem. However, I have a user who reported is randomly after using the app for many hours. This is what I came up with the repo. |
Fixed by #108512 |
@pavelsavara I plan to update to .NET 9 soon. Is the fix implemented by the official .NET 9 release as of next week? |
@pavelsavara I just ran a test using latest .NET9 and found that the issue is not resolved. Here is the updated repo: What am I missing? Could you please re-open the issue? |
Description
I was working an 'out of memory' issue with the UNO guys where I created a repo which chased the MONO WASM runtime in an 'out of memory' exception unexpectedly. Basically the user code is just fine, it's the MONO WASM GC which throws the towel at some point.
However, if I - as per @jeromelaban's recommendation - would place
GC.GetTotalMemory(true)
calls in the repo code, then everything would be fine.This raises the question: why isn't the garbage collector doing its job?
My layman's thinking is: if the GC experiences a situation where it runs out of memory then it should "stop the presses" and do whatever is needed to free up some memory. Why would I have to call
GC.GetTotalMemory(true)
to tell the GC "get your job done and free up some memory"?Reproduction Steps
I could paste the repo here rather pointed to the (UNO) scenario here.
Expected behavior
The GC should do its job.
Actual behavior
The GC does not free up memory although it could.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: