Hacker News new | past | comments | ask | show | jobs | submit login

Do you know which mechanism is used for this?



In addition to the MEM_RESET, MEM_RESET_UNDO mentioned, there's also OfferVirtualMemory[1], ReclaimVirtualMemory[2] to let the system potentially use the memory if it needs it.

Unlike MEM_RESET, this allows you to prioritize the memory you offer, as well as provides some extra safeguards it seems.

No idea if Firefox uses this or MEM_RESET.

[1]: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi...

[2]: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi...


That seems to be something different; instead of getting the memory when some other application needs it, the OS receives the memory when the application (browser) doesn't need it any longer, so it can't be used for caching.

This actually looks exactly like the malloc/free use case.


How can't it be used for caching? Say you decode an image, then offer the memory backed by it to the OS. If you need to access the image data again you try to reclaim the memory, if it fails it's a cache miss.


You're right, the missing info I didn't notice was the return value.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: