Skip to content

Commit c9e7359

Browse files
authored
Merge pull request #78 from modelix/issues/MODELIX-421
MODELIX-421: Memory leak in light-model-server when clients disconnect and reconnect
2 parents 57e2b62 + d95ed49 commit c9e7359

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

model-server-lib/src/main/kotlin/org/modelix/model/server/light/LightModelServer.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,15 @@ class LightModelServer(val port: Int, val rootNode: INode, val ignoredRoles: Set
116116
}
117117
routing {
118118
webSocket("/ws") {
119+
var session: SessionData? = null
119120
try {
120-
val session = SessionData(this)
121+
session = SessionData(this)
121122
sessions.add(session)
122123
handleWebsocket(session)
123124
} catch (ex: Exception) {
124125
LOG.error(ex) { "Error in websocket handler" }
126+
} finally {
127+
sessions.remove(session)
125128
}
126129
}
127130
}

0 commit comments

Comments
 (0)