During pack, we read all the files into buffers, then copy them into a plaintext buffer and then encrypt to a cipher buffer.
Resulting in all the file data being stored three times in memory.
This patch moves processing of the crypto to be file based instead of memory buffer based and eliminates two of the three copies being stored in memory.
This greatly reduces the memory footprint when creating the pkg. Example: Peak memory consumption when creating the PKG for a PSX Classics of ResidentEvil2 goes from ~3.7G to ~1.2G.
…ffers
During pack, we read all the files into buffers, then copy them into a plaintext buffer and then encrypt to a cipher buffer. Resulting in all the file data being stored three times in memory. This patch moves processing of the crypto to be file based instead of memory buffer based and eliminates two of the three copies being stored in memory.
This greatly reduces the memory footprint when creating the pkg. Example: Peak memory consumption when creating the PKG for a PSX Classics of ResidentEvil2 goes from ~3.7G to ~1.2G.