playMaker

Author Topic: Multiplayer minigame causes bad memory leak  (Read 3208 times)

1982

  • Junior Playmaker
  • **
  • Posts: 71
Multiplayer minigame causes bad memory leak
« on: April 25, 2014, 04:54:12 AM »
After two days of experimenting, I was able to make two player multiplayer (IP based) game where we have dynamic physics object and it's position is correctly rendered for both players.

As a basis I used Playmaker official networking tutorial scene "4_SpawnPlayers".

However, we are running into trouble of getting massive memory leak which eventually crashes either server's or client's game. Or then it makes memory dumps that freezes the game for several seconds. Game process can take anything up to 3-4 gigabytes RAM before eventual crash.

How can I stop this happening? Lowering the data send rate only helps the game to run little bit longer until eventual crash, but of course there is also more lag.

We are syncing players vector3 positions, physic object vector3 position and a pair of global string variables. Whole setup is very simple.

Oh boy, any help is very welcomed...


1982

  • Junior Playmaker
  • **
  • Posts: 71
Re: Multiplayer minigame causes bad memory leak
« Reply #1 on: April 25, 2014, 05:38:07 AM »
Seems like the memory leak is caused by having physics object vector3 variable as global (network synced) variable. I've pretty much ruled out everything else...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiplayer minigame causes bad memory leak
« Reply #2 on: April 25, 2014, 08:21:39 AM »
Hi,

 What is your profiling telling you? what kind of feedback do you get with this memoryleak, what tool are you using to witness the memory going up?

 you are using Unity networking right? not Photon isn't it?
bye,

 Jean

1982

  • Junior Playmaker
  • **
  • Posts: 71
Re: Multiplayer minigame causes bad memory leak
« Reply #3 on: April 28, 2014, 03:14:09 AM »
Profiler doesn't really help as the problem mostly occurs with executable and client side. All I know that before the crash system memory consumption goes sky high. So I am pretty much using Windows Task Manager and Resource Monitor to see what is going on.

Yes I am using Unity networking, no Photon at all. I have narrowed down the issue to two global variables that are network synced.

And I can't seem to find a way to make this demo game without using those two particular variables.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiplayer minigame causes bad memory leak
« Reply #4 on: April 28, 2014, 06:29:00 AM »
Hi,

You can profile builds with Unity pro, what is the targeted platforms?

 so, if you completly remove any global variable network synchronization, you don't get any memory leak?

This is a tricky thing to debug because it could be that the synchronisation itself is the problem but what happens prior or after.

 I would do the following: switch off this synchronization and implement a manual ovveride of this value ( like a slider or a joystick input), and feed from the exact same palce the value as if it was sysnchronized, if it doesn't crash anymore then indeed it's the sync, else you'll need to debug further.

It's very rare when a build behaves differently then within the editor, are you sure you don't see any suspicious behavior within the profiler inside Unity? run the server in unity and client publish, and then do the opposite, so you can witness both sides within Unity profiler.

1982

  • Junior Playmaker
  • **
  • Posts: 71
Re: Multiplayer minigame causes bad memory leak
« Reply #5 on: April 28, 2014, 06:45:02 AM »
I have now tested with profiler, but the whole Unity editor crashes when the memory spike occurs. There is not any oddities going on until the editor crash. Of course profiler stops working as well.

Yes, no memory leaks when I tick off the network sync from those two variables. I've also tried manual override but it does not cause any problems.

This is intended to be desktop game.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiplayer minigame causes bad memory leak
« Reply #6 on: April 28, 2014, 08:58:12 AM »
Hi,

 Can you pm me to share your project? I will have a look, you may have found something indeed.

bye,

 Jean