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

Memory exhausts rapidly when closing stream after writing/reading with --gc:arc on Windows10 #150

Open
gogolxdong opened this issue Jan 22, 2021 · 1 comment

Comments

@gogolxdong
Copy link

gogolxdong commented Jan 22, 2021

Tried

    proc sendFileStreamHandler(api: DaemonAPI, stream: P2PStream) {.async.} =
      {.gcsafe.}:
        var name: string
        var length: int
        while true:
          var line = await stream.transp.readLine()
          if line == "":
            continue
          var parts = line.split(":")
          name = parts[0]
          length = parts[1].parseInt
          var buffer = newString(length)
          await stream.transp.readExactly(buffer[0].addr, length)
          writeFile(name, buffer)
          discard await stream.transp.write "received\r\n"
    proc requestFileStreamHandler(api: DaemonAPI, stream: P2PStream) {.async.} =
      {.gcsafe.}:
        consoleString = peerDomainTable[$stream.peer] & strformat.`&` "\r\n"
        console.add consoleString
        var content = ""
        while true:
            if stop: break
            var line = await stream.transp.readLine()
            if len(line) == 0:
                continue
            if fileTable.hasKey line:
              content = readFile(fileTable[line])
              echo await stream.transp.write $content.len & "\r\n"
              echo await stream.transp.write content 
    await data.api.addHandler(RequestProtocols, requestFileStreamHandler)
    await data.api.addHandler(SendProtocols, sendFileStreamHandler)
@gogolxdong gogolxdong changed the title Memory exhausts rapidly when writing with --gc:arc Memory exhausts rapidly when writing with --gc:arc on Windows10 Jan 22, 2021
@gogolxdong gogolxdong changed the title Memory exhausts rapidly when writing with --gc:arc on Windows10 Memory exhausts rapidly when writing/reading with --gc:arc on Windows10 Jan 22, 2021
@arnetheduck
Copy link
Member

does arc support {.shallow.}?

@gogolxdong gogolxdong changed the title Memory exhausts rapidly when writing/reading with --gc:arc on Windows10 Memory exhausts rapidly when closing stream after writing/reading with --gc:arc on Windows10 Jan 27, 2021
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