예제 #1
0
 void OnEnable()
 {
     CerasSerializer.ClearGenericCaches();
     Application.runInBackground = true;
     SetupSerializer();
     StartStreaming();
 }
예제 #2
0
 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();
 }
예제 #3
0
파일: Internals.cs 프로젝트: zvinless/Ceras
        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);
        }