Skip to content

Memory leak caused by creating a unique logger for each KrpcServerService instance #541

@akowal

Description

@akowal

krpc version: 0.10.1

I found that kotlinx.rpc.krpc.server.internal.KrpcServerService creates a unique logger for each instance:

private val logger = RpcInternalCommonLogger.logger(rpcInternalObjectId(descriptor.fqName))

Since KrpcServerService is created on each service registration (basically, on each new connection) over time this leads to a huge number of loggers created and kept in memory by logging framework implementations (e.g. Logback).

A simple example reproducing the issue: https://github.com/akowal/krpc-log-memleak

Here's a couple of heap charts:

Image Image

And some picks from the heapdump after JVM OOM (can be found in the example repo):

Image Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions