What do you think about the possibility of filling free (not really used) pages with zero bytes? Can this improve performance in Windows as well as in VMWare and other virtual machines? For example, VMWare and HyperV compute a hash of memory pages, and if the contents are the same, mark this page as “shared” inside the virtual machine and between virtual machines on the same host until the page is resized. This effectively reduces memory consumption. Windows does the same - it treats zero pages differently, treating them as free.
We could have a heap manager that would automatically fill memory with zeros when calling FreeMem / ReallocMem. As an alternative, we can have a function that resets empty memory on demand, i.e. Only with an explicit call to this function. Of course, this feature must be thread safe. The disadvantage of filling memory with zeros is memory that may have already been turned into virtual memory, which leads to page errors. In addition, any operations with the data warehouse are performed slowly, so our program will be slower, although unknown (possibly insignificant).
If we manage to completely fill 4-K pages with zeros, the hypervisor or Windows will explicitly mark it as a zero page. But even partial nulling can be useful, because the hypervisor can compress pages using LZ or similar algorithms to preserve physical memory.
I just want to know your opinion whether the advantages of filling the empty heap memory with zero bytes by the heap manager itself outweigh the disadvantages of this method.
Does value dip when we buy a reduction in physical memory consumption?
source
share