Am 24.04.2015 um 11:26 hat Stefan Hajnoczi geschrieben:
> The posix_memalign() call wastes memory. I compared:
>
> posix_memalign(&memptr, 65536, 2560 * 65536);
> memset(memptr, 0, 2560 * 65536);
>
> with:
>
> for (i = 0; i < 2560; i++) {
> posix_memalign(&memptr, 65536, 65536);
> memset(memptr, 0, 65536);
> }64k alignment is too much, in practice you need 512b or 4k, which probably wastes a lot less memory. But I just looked at the qcow2 cache code and you're right anyway. Allocating one big block instead of many small allocations in a loop looks like a good idea either way. Kevin
pgpXwoMpn_aeC.pgp
Description: PGP signature
