You're calling them MB but allocating MiB. 1 MB = 1000000 bytes 1 MiB = 1048576 bytes Please use the correct prefixes in your documentation. https://en.wikipedia.org/wiki/Byte#Multiple-byte_units