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

Rising memory problem and OutOfMemory [Scala] #794

Closed
emrahoruc opened this issue Feb 23, 2021 · 2 comments
Closed

Rising memory problem and OutOfMemory [Scala] #794

emrahoruc opened this issue Feb 23, 2021 · 2 comments

Comments

@emrahoruc
Copy link

emrahoruc commented Feb 23, 2021

Hi there,

I use netty-socketio 1.7.18 in my Scala application, but after a while it shutdowns the application with an out of memory error. In production the virtual memory goes up to 130g. Memory raises up faster(~100mb) when the page refreshes by the browser(client).

I manual call GC but it doesn't release.

When looking from the VisualVM, it seems that the reason are netty buffers. You can see it from screenshots.

I still haven't found a solution, can you help me please?

Capture00

Capture1

Capture0

@emrahoruc
Copy link
Author

While testing with the demo application in the repository, I noticed, when I convert the application to the Scala and constantly refresh the page to connect/dissconnect in the browser, the heap size rises very fast and it is never released.

Scala version.

package com.wstest

import com.corundumstudio.socketio.{AckRequest, Configuration, SocketIOClient, SocketIOServer}
import com.corundumstudio.socketio.listener.DataListener
import com.wstest.Main.chats


object ScalaLauncher {

  @throws[InterruptedException]
  def main(args: Array[String]): Unit = {
    val config = new Configuration
    config.setHostname("localhost")
    config.setPort(9092)
    val server = new SocketIOServer(config)
    server.addEventListener("chatevent", classOf[String], new DataListener[String]() {
      override def onData(client: SocketIOClient, data: String, ackRequest: AckRequest): Unit = { // broadcast messages to all clients
        server.getBroadcastOperations.sendEvent("chatevent", data)
      }
    })
    server.start()
}

@emrahoruc emrahoruc changed the title Rising memory problem and OutOfMemory Rising memory problem and OutOfMemory [Scala] Feb 25, 2021
@emrahoruc
Copy link
Author

I solved with Config.setWorkerThreads(1)
Each time the page is refreshed, a new nioEventLoopGroup thread was started and the old ones were not closed.

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

No branches or pull requests

1 participant