richardbiely / Voxelmetric

An efficient voxel framework for Unity3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A MarshalMemPool crash fix for ya..

XeonG opened this issue · comments

commented

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.

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