Unity WWW download crash in CompressedFileStream(out of memory)

Recently our project experienced some random crash during WWW downloads streaming files on win32 platform.

And the crash message is out of memory, log said it’s in CompressedFileStream.cpp line 10.

Also, the memory allocation size in log is 8388608B, which is exactly 8MB.

After some research, I found that it is because Unity WWW streaming uses Lzma to decompress files.

And the default value of dictionary size is exactly 8MB.

(I can’t find the option in Unity to choose dictionary size value so I assume Unity use the default 8MB value.)

That means each time a file has been downloaded, it takes at least 8MB Ram for Unity to decompress it.

This would cause a serious memory issue if there’s lots of files finished downloading at same time, system memory could easily ran out because of massive file decompression.

And I think this explains why our project had so much random crash during download process.

Is there any way we can specify Unity web player or asset file’s setting to choose a smaller dictionary value?

8MB is just too big for this, user who have smaller ram could easily get the out of memory crash because of rapid memory consume.

Ok… after days of searching and experimenting, I’ve found a solution to this.

Lzma speed up


Use this project can let user specify the compression value, including dictionary size.

After I changed the dictionary setting to -d16 (64KB), the out of memory issue significantly decreased.

So basically this issue can be easily solved by change the compression setting.

I just don’t know why Unity doesn’t give us the option to change assetbundle compression setting, forcing us have to use an alternative solution like this one.