Use 64-bit counters for the memory usage, to avoid easy overflows.