Wasm32, graceful handling of 4GB limit

For rust/wasm32, is there any graceful way to handle the 4GB limit?

Ideally, I want something where, at 3.5GB usage, some handler gets called, and then this handler displays some message and starts evicting objects / disabling parts of the application (instead of everything out right crashing).

I use cap to watch memory usage (that's a polling approach, it doesn't have a callback/signal). There's also fallible collections.

Looks like the functionality for that is in core::arch::wasm32::memory_size.