Private mem.require function that preallocates memory and counts gas fee