void OnEnable() { CerasSerializer.ClearGenericCaches(); Application.runInBackground = true; SetupSerializer(); StartStreaming(); }
void OnDisable() { // According to // https://stackoverflow.com/questions/24312265/should-a-udpclient-be-disposed-of // You should use .Close() rather than .Dispose() _socket.Close(); CerasSerializer.ClearGenericCaches(); DataPool.ReceivedFrame.Clear(); DataPool.SendFrame.Clear(); }
public void ClearGenericCaches() { var ceras = new CerasSerializer(); var list = new List <Cat>(); for (int i = 0; i < 1000; i++) { list.Add(new Cat()); } var data = ceras.Serialize(list); var clone = ceras.Deserialize <List <Cat> >(data); var capacityBefore = ObjectCache.RefProxyPool <Cat> .GetPoolCapacity(); Assert.True(capacityBefore > 500); CerasSerializer.ClearGenericCaches(); var capacityAfter = ObjectCache.RefProxyPool <Cat> .GetPoolCapacity(); Assert.True(capacityAfter < capacityBefore); }