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

out of memory #11

Closed
s0kil opened this issue Nov 20, 2019 · 7 comments
Closed

out of memory #11

s0kil opened this issue Nov 20, 2019 · 7 comments

Comments

@s0kil
Copy link

s0kil commented Nov 20, 2019

Server Crashes with message:

INFO Jester is making jokes at http://0.0.0.0:8000
Starting 1 threads
DEBUG GET /ws
out of memory

Server

import jester
import ws, ws/jester_extra

settings:
  port = Port(8000)

routes:
  get "/ws":
    var ws = await newWebSocket(request)
    await ws.send("Welcome to simple echo server")
    while ws.readyState == Open:
      let packet = await ws.receiveStrPacket()
      await ws.send(packet)

Client

let ws = new WebSocket("ws://localhost:8000/ws")
ws.send("hi")
@s0kil
Copy link
Author

s0kil commented Nov 21, 2019

@treeform Do you think this could be a Mem leak?

@s0kil
Copy link
Author

s0kil commented Nov 22, 2019

I have managed to get a stack trace

DEBUG GET /ws
Traceback (most recent call last)
/home/sokil/Desktop/Lab/nim_spa_server/src/server.nim(11) server
/home/sokil/.nimble/pkgs/jester-0.4.3/jester.nim(482) serve
/home/sokil/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(423) run
/home/sokil/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287) eventLoop
/home/sokil/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(219) processEvents
/home/sokil/.nimble/pkgs/jester-0.4.3/jester.nim(485) :anonymous
/home/sokil/.nimble/pkgs/jester-0.4.3/jester.nim(386) handleRequest
/home/sokil/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(313) dispatch
/home/sokil/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(34) dispatchNimAsyncContinue
/home/sokil/.nimble/pkgs/jester-0.4.3/jester.nim(285) dispatchIter
/home/sokil/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(313) match
/home/sokil/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(34) matchNimAsyncContinue
/home/sokil/Desktop/Lab/nim_spa_server/src/server.nim(18) matchIter
/home/sokil/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(313) newWebSocket
/home/sokil/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(34) newWebSocketNimAsyncContinue
/home/sokil/.nimble/pkgs/ws-0.3.3/ws/jester_extra.nim(8) newWebSocketIter
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(111) genericAssign
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(100) genericAssignAux
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(24) genericAssignAux
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(20) genericAssignAux
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(100) genericAssignAux
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(24) genericAssignAux
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(20) genericAssignAux
/home/sokil/.choosenim/toolchains/nim-#devel/lib/system/assign.nim(51) genericAssignAux
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

@me7
Copy link

me7 commented Nov 25, 2019

Same with me. Do you have a workaround on this?

@s0kil
Copy link
Author

s0kil commented Nov 25, 2019

@me7
Copy link

me7 commented Nov 26, 2019

Ok, that's mean something wrong when casting jester.Request to Future[Websocket] ?
Anything I can to solve this problem?

@me7
Copy link

me7 commented Nov 26, 2019

Hi @s0kil I've got work around for this issue. You should compile program with -d:useStdLib

e.g. nim c -r -d:useStdLib sample_ws.nim

The problem is when using linux jester will run using httpBeast but ws fail to detect it.

it's help fix the problem but when using using asynchttpserver will slower than using httpbeast. In my simple benchmark request/second drop from 80k to 50k

@s0kil
Copy link
Author

s0kil commented Nov 26, 2019

@me7 Huh, I thought Jester uses stdlib server by default, I guess not.

@s0kil s0kil closed this as completed Nov 26, 2019
s0kil added a commit to s0kil/nim_spa_server that referenced this issue Nov 28, 2019
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

2 participants