Bug com.unity.logging package

I got error when using Unity.Logging.Log.Info(“msg”) in Custom Player Loop.

: [com.unity.logging] Failed to allocate memory. Make sure you’re unlocking all buffers after LockPayloadBuffer. Or if you’re logging too much - try to change logging settings
[LogMemoryAllocator] state:
Update Count: 3
BufferA: 65536 / 65536 [Active]
BufferB: Not created
Overflow: 163840 / 163840
Locked buffers (with LockPayloadBuffer): 0
Deferred release PayloadHandlesX: 0 [Active]
Deferred release PayloadHandlesY: 0

As the error message says, the Logger in the Logging package only allocates a 64KB buffer by default.
(Also, the internal implementation of the buffer area is a ring buffer. The buffer area should be cleared every frame.)

When initializing the Logger instance, you can specify the buffer size you want to allocate, which should solve the problem.

var loggerConfig = new LoggerConfig();
// (your custom configuration)
LogMemoryManagerParameters.GetDefaultParameters(out var memoryManagerParameters);
memoryManagerParameters.InitialBufferCapacity = /* buffer length you want to allocate */;
var logger loggerConfig.CreateLogger(memoryManagerParameters);