com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Memory leak in the spawning system

Open PinoEire opened this issue 1 year ago • 2 comments

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

  • Server hosted on Multiplay
  • NGO v2
  • Unity 6

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.

PinoEire avatar Aug 14 '24 11:08 PinoEire

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

Thank you!

fluong6 avatar Aug 19 '24 15:08 fluong6

@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)

NoelStephensUnity avatar Aug 20 '24 15:08 NoelStephensUnity

Disabling Active Scene Synchronization for whatever Network Object you're spawning resolves the memory leak.

NAsejevs avatar Jan 30 '25 20:01 NAsejevs

@NAsejevs Out of curiosity, do you have the NetworkManager.LogLevel set to LogLevel.Developer?

NoelStephensUnity avatar Feb 05 '25 00:02 NoelStephensUnity

This issue has been automatically marked as stale because it has been awaiting response for over 30 days without any activity. Please update the issue with any new information or it may be closed in 30 days.

github-actions[bot] avatar May 02 '25 00:05 github-actions[bot]

This issue has been automatically closed because it has been stale for 30 days without any activity. Feel free to reopen if you have new information to add.

github-actions[bot] avatar Jun 01 '25 00:06 github-actions[bot]