richardbiely / Voxelmetric

An efficient voxel framework for Unity3d
GNU General Public License v3.0
158 stars 27 forks source link

A MarshalMemPool crash fix for ya.. #36

Closed XeonG closed 7 years ago

XeonG commented 7 years ago

Think I remember reporting a Unity/Game crash to do with a MarshalMemPool error before... well I finally found out what was actually causing it to eventually trigger, no matter how much I increased the default pool memory :) ....

StructSerialization.cs .... public static T[] DeserializeArray(byte[] data, MarshalMemPool pool) where T : struct { ... IntPtr buffer = pool.Pop(data.Length); ... pool.Push(objSize); //Which is returning this... int objSize = TSSize.ValueSize; size of which is tiny compared to the average data.length being taken from the taken from the memory pool above.. pool.Push(data.Length); //Fixed

}

I think it got missed for so long as memory pool size was enough for the average saved chunk files... except I was starting to practically fill up entire chunks and the saved file sizes are like 160kb (I believe you plan on adding compression for this?) anyway it was eventually crashing unity which didn't help me with finding what the real culprit cause of the crashing was all along.

richardbiely commented 7 years ago

Thank you a lot for reporting this. Fixed in 8e42517fc221f467f4c73f0ed76de3d1eea89018