In native plugin getPixelSizeFromInternalFormat returns size in bits! Therefore, you allocate 8 times more memory than necessary.