microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
9.74k stars 791 forks source link

Intermittent VirtualAlloc failure while the pagefile is growing #894

Closed malkia closed 1 month ago

malkia commented 1 month ago

Hi Daan! First thank you for the amazing project, allowing to shed so much of the time spent during allocations, and especially freeing!

We've hit one issue, which Mozilla & Google also did years ago - e.g. VirtuaAlloc may intermittently fail while growing (in it's default settings when it grows as demand comes). During that grow, if it can't grow on time (my lame understanding), it may intermittently fail, unless you try and retry it a bit later.

I'm wondering if there would be any plans to add this in mimalloc. I'm going to do some local changes, and was thinking why not detour VirtualAlloc (and related), but then it might be even better if mimalloc somehow supported this.

Just tossing out some findings about it: https://source.chromium.org/chromium/chromium/src/+/7ebe3d43d74e8d3d19f5795bbf01cfd3a1595e36 - this is when Chrome added support to it, based on what Mozilla did too. Might be good to have some option, or allow some control to the user through some callbacks.

Thanks!!

daanx commented 1 month ago

The latest dev / dev-slice implement this now (with a new MIMALLOC_RETRY_ON_OOM option to turn it off ). It seems a good thing to have although it will be hard to actually test how well it actually works.. will be interesting to see if it increases stability on other services than a web browser as well.