Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.socket.client.IO::managers leaks resources #742

Open
valeriyo opened this issue May 16, 2023 · 1 comment
Open

io.socket.client.IO::managers leaks resources #742

valeriyo opened this issue May 16, 2023 · 1 comment
Labels

Comments

@valeriyo
Copy link

Describe the bug
The IO::managers map is added to, but never removed from, and there is no method to clear it - so a bunch of stuff leaks.

To Reproduce

Use LeakCanary to watch OkHttpClient instances passed into IO::Options.callFactory / webSocketFactory - after IO.socket.close() - those OkHttpClient will leak, being held by IO::managers - which is added to, but is never cleared.

Socket.IO java client version: 2.1.0

Expected behavior
Either automatically remove entries from IO::managers when sockets are closed, or provide a method to clear IO::managers map - and release the resources held by it.

Platform:

  • Device: Pixel 4a
  • OS: Android 13
@valeriyo valeriyo added the bug label May 16, 2023
@valeriyo
Copy link
Author

BTW, the workaround is:

    IO::class.java.declaredFields.first { it.name == "managers" }.apply {
      isAccessible = true
      val managers = get(null) as ConcurrentHashMap<*, *>
      managers.clear()
    }

and then in proguard-rules.pro:

-keepclassmembers class io.socket.client.IO {
    private static final ** managers;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant