Skip to content

Public NetworkLists potentially being auto instantiated but not disposed leading to a memory leak #3136

Closed
@ezoray

Description

@ezoray

Description

When a network list is declared public sometimes as part of the serialisation process it looks like the list is instantiated, or at least partially, but it's never disposed leading to a Leak Detected message on the next recompile or play through. The list doesn't appear usable unless Initialise is called on it. Due to this instantiation there's no requirement for your own in Awake but if there is one it has no effect on this.

Public NetworkVariables are also auto instantiated but show no ill effects.

Reproduce Steps

There's a discussion and code example here.

Actual Outcome

Leak log - Leak Detected : Persistent allocates 4 individual allocations.

Expected Outcome

Public network lists are not auto instantiated.

Environment

  • OS: macOS Big Sur
  • Unity Version: 2023.3
  • Netcode Version: 1.11.0

Additional Context

Having a network list public seems to be the only way to see the contents of the list in the inspector as it won't show with [SerializeField].

This issue is also mentioned in #2862.

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions