4 ms·
Do you know which mechanism is used for this?
by rhn_mk1 7y ago
Do you know which mechanism is used for this?
- magicalhippo 7y agoIn 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/nf-memoryapi-offervirtualmemory https://docs.microsoft.com/en-us/windows/win32/api/memoryapi... [2]: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-reclaimvirtualmemory https://docs.microsoft.com/en-us/windows/win32/api/memoryapi...
- rhn_mk1 7y agoThat 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.
- magicalhippo 7y agoHow 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.
- rhn_mk1 7y agoYou're right, the missing info I didn't notice was the return value.