Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

Memory leak in the spawning system #3010

Open PinoEire opened 3 months ago

PinoEire commented 3 months ago

Description

I left the server running the whole night and the memory allocation kept growing. No clients were connected during this period, but the server was running a simulation with 30 bots. When two bots collide, the smaller bot is despawned (with the option of destroying the game object) and a new bot is spawned from the prefab. Nothing else really happening in the simulation.

Screenshots

image

Environment

Additional Context

This is an Agar.io clone, very simple. The "food" when eaten is simply moved to a different random location. I didn't think I needed to create a pooling system for just 30 bots floating around and eating another bot every now and then, but apparently this becomes necessary.

fluong6 commented 3 months ago

Hi @PinoEire Could you please provide us a sample of your project for investigation? You can submit the project via:

Thank you!

NoelStephensUnity commented 3 months ago

@PinoEire Also, it would be helpful to know if you get the same results running the server locally and not hosted as a VM in multiplayer services. If so, running the profiler and looking at what is allocating memory could be useful.

The other thing to look at would be if you have the multiplayer tools package installed. If so, you might try removing that package and see if you get the same kind of stair-step saw tooth memory usage results.

(Just trying to narrow down where this growing allocation could be happening)