net.ActorChannelPool
net.ActorChannelPool
#Overview
name: net.ActorChannelPool
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If nonzero, actor channels will be pooled to save memory and object creation cost.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.ActorChannelPool is to enable actor channel pooling in Unreal Engine’s networking system to save memory and reduce object creation costs.
This setting variable is primarily used in the networking subsystem of Unreal Engine, specifically within the NetDriver module. It affects how actor channels, which are used for replicating actor properties over the network, are managed.
The value of this variable is set through a console variable (CVar) named CVarActorChannelPool. It is initialized with a default value of 1, meaning actor channel pooling is enabled by default.
The associated variable CVarActorChannelPool directly interacts with net.ActorChannelPool. They share the same value and purpose.
Developers should be aware that:
- When this variable is set to a non-zero value, actor channels will be pooled.
- Pooling can significantly impact memory usage and performance, especially in games with many networked actors.
Best practices when using this variable include:
- Monitor performance and memory usage with pooling enabled and disabled to determine the optimal setting for your specific game.
- Consider disabling pooling (setting to 0) if you encounter issues with actor replication or if your game has a small number of networked actors.
Regarding the associated variable CVarActorChannelPool:
- It is used to directly control the behavior of actor channel pooling in the code.
- It is checked in the UNetDriver::GetOrCreateChannelByName and UNetDriver::ReleaseToChannelPool functions to determine whether to use the actor channel pool.
- When creating a new channel, if pooling is enabled, the system will first try to reuse a channel from the pool before creating a new one.
- When releasing a channel, if pooling is enabled, the channel is added back to the pool instead of being destroyed.
Developers should be cautious when modifying this variable at runtime, as it could lead to unexpected behavior in ongoing network communications. It’s generally safer to set this value at the beginning of a game session and maintain it throughout.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:403
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarActorChannelPool(
TEXT("net.ActorChannelPool"),
1,
TEXT("If nonzero, actor channels will be pooled to save memory and object creation cost."));
static TAutoConsoleVariable<int32> CVarAllowReliableMulticastToNonRelevantChannels(
TEXT("net.AllowReliableMulticastToNonRelevantChannels"),
1,
#Associated Variable and Callsites
This variable is associated with another variable named CVarActorChannelPool
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:402
Scope: file
Source code excerpt:
TEXT("(0 = Disabled, 1 = Allowed (default), 2 = Required)"));
static TAutoConsoleVariable<int32> CVarActorChannelPool(
TEXT("net.ActorChannelPool"),
1,
TEXT("If nonzero, actor channels will be pooled to save memory and object creation cost."));
static TAutoConsoleVariable<int32> CVarAllowReliableMulticastToNonRelevantChannels(
TEXT("net.AllowReliableMulticastToNonRelevantChannels"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:5989
Scope (from outer to inner):
file
function UChannel* UNetDriver::GetOrCreateChannelByName
Source code excerpt:
{
UChannel* RetVal = nullptr;
if (ChName == NAME_Actor && CVarActorChannelPool.GetValueOnAnyThread() != 0)
{
while (ActorChannelPool.Num() > 0 && RetVal == nullptr)
{
RetVal = ActorChannelPool.Pop();
if (RetVal && RetVal->GetClass() != ChannelDefinitionMap[ChName].ChannelClass)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:6046
Scope (from outer to inner):
file
function void UNetDriver::ReleaseToChannelPool
Source code excerpt:
LLM_SCOPE_BYTAG(NetChannel);
check(IsValid(Channel));
if (Channel->ChName == NAME_Actor && CVarActorChannelPool.GetValueOnAnyThread() != 0)
{
ActorChannelPool.Push(Channel);
Channel->AddedToChannelPool();
}
}