Connection crashes after 10 seconds
Hi Folks,
I am using Unity with the photon realtime networking SDK. I serialize a message class to a byte array using protobuf-net. I put this byte array together with its length in a hash table and transfer it via the photon command OpRaiseEvent.
I noticed that Photon.Service() consumes 99% of the runtime and causes a low fps rate of 1-2. This causes the connection to break and I get a "unexpected disconnect". As far as I analysed it the mail problem is the garbage collection. The allocation increases with every frame, until the connections breaks. I set a profiling section around the command OpCustom. This is what it looks like. (70 kb PER FRAME!)
Do you have any Idea what i did wrong?
I am using Unity with the photon realtime networking SDK. I serialize a message class to a byte array using protobuf-net. I put this byte array together with its length in a hash table and transfer it via the photon command OpRaiseEvent.
I noticed that Photon.Service() consumes 99% of the runtime and causes a low fps rate of 1-2. This causes the connection to break and I get a "unexpected disconnect". As far as I analysed it the mail problem is the garbage collection. The allocation increases with every frame, until the connections breaks. I set a profiling section around the command OpCustom. This is what it looks like. (70 kb PER FRAME!)
Do you have any Idea what i did wrong?
0
Comments
-
My Problem was a sum of several problems.
1. I used a MemoryStream with a fixed length of 1000 bytes. This prevented a memory allocation, but the memory was copied in OpCustom (which is still not good, an update would be great).
2. The next thing was, that I forgot to set the position in the MemoryStream to 0, that causes the network traffic to cummulate - after 1000 Interations the game sent 1 MB per frame.
3. I noticed that there is no way to send a byte array with photon realtime by defining the array and the length. That means that I still send 1 kb per frame.
Here is what I did:
https://forum.photonengine.com/discussion/118830