ps3dev / PSL1GHT

A lightweight PS3 SDK
www.psl1ght.com
MIT License
226 stars 64 forks source link

Use tempfile instead of memory to prepare the plaintext and cipher bu… #145

Open sahlberg opened 7 months ago

sahlberg commented 7 months ago

…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.