How do I control the size of the reserved memory pool

Our Game consistently uses Approx 300Mb but periodically fails to launch successfully in NaCl showing an out of memory error. According to the Unity profiler running the editor build, Unity is regularly (but not always) attempting to set a start-up size for the Reserved Memory Pool that is more than 750Mb.

How can I control this?

So with help from the support team (especially @Graham) we have a theory on what the problem was and a fix which seems to be working so many thanks everyone. Along the way we learned some stuff I thought it would be good to highlight and we are left with a few loose ends I hope someone can help with.

Our problem was an out of memory condition on NaCl that happened before we had loaded any assets. The memory profiler in windows showed inconsistent values but hinted that we might be exceeding the NaCl platform limitation of 750 Mb. The game runs fine on iOS with much less than 750 Mb so indicated a platform specific issue. We thought that perhaps the problem was occurring when the pools were set up and originally asked if we could control the pool size.

Our new theory is that the error happens as the first asset is in the process of being extracted. It looks like on NaCl the temporary memory required to extract assets from the unity3d file is proportional to the unity3d file rather than the asset being extracted. (On iOS there is no single amalgamated compressed asset). Our solution is to break out the large main unity3d file and dynamically load multiple asset bundles. This seems to have reduced the peak memory usage to within platform limits

Here is what we learned but maybe someone can confirm or clarify

  • No you cant control the initial or peak memory pool size
  • As far as we can tell you cant attach the profiler to NaCl
  • Asset unpacking algorithms are platform dependent and worst case you will be storing packed, unpacked and temporary data in memory simultaneously.
  • NaCL 32 Bit has a 750Mb limit - 64Bit is much higher - 4Gb?
  • NaCl on Mac is (currently) 32 bit even when Mac is 64 bit.

In the memory dump from a out of memory allocation - we could not find description of these values or how they map to the simple view we get in the profiler - help appreciated

05/07/2013 17:15:40.820 [0x0-0x4e94e9].com.google.Chrome.canary: [ ALLOC_TEMP_THREAD ] used: 32752B | peak: 0B | reserved: 65536B

05/07/2013 17:15:40.820 [0x0-0x4e94e9].com.google.Chrome.canary: [ ALLOC_DEFAULT ] used: 587554625B | peak: 589012121B | reserved: 598593083B

05/07/2013 17:15:40.820 [0x0-0x4e94e9].com.google.Chrome.canary: [ ALLOC_GAMEOBJECT ] used: 5872B | peak: 5872B | reserved: 6712B

05/07/2013 17:15:40.820 [0x0-0x4e94e9].com.google.Chrome.canary: [ ALLOC_GFX ] used: 34194B | peak: 34194B | reserved: 34682B

05/07/2013 17:15:40.820 [0x0-0x4e94e9].com.google.Chrome.canary: [ ALLOC_PROFILER ] used: 396B | peak: 396B | reserved: 561B