Skip to content

Blazor WASM does not free memory - possibly a memory leak #64047

@jahnotto

Description

@jahnotto

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When allocating large arrays in Blazor wasm 6.0.1, the memory is never freed up when the reference is set to null. Consecutive allocations ends up with an OutOfMemoryException.

Either I'm doing something very wrong, or there is a memory leak.

Expected Behavior

The GC should free the memory that is no longer used, and should not result in an OutOfMemoryException.

Steps To Reproduce

Minimal repro project is here: https://github.com/jahnotto/BlazorWasmMemoryIssue

Try to click multiple times on "Allocate DotNet memory". The memory keeps increasing. Clicking "Free DotNet memory" does not make any difference. Same behavior is seen in debug, release and even AOT.

Allocating JS memory, on the other hand, works as expected.

Exceptions (if any)

OutOfMemoryException

.NET Version

6.0.101

Anything else?

Blazor wasm 6.0.1
Tested on both Edge and Chrome

Note: GCSettings.GCLatencyMode is set to Batch in Blazor wasm and can't be changed. I don't know if this relevant, but I'd expect it to be Interactive for an interactive client side application.

image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions