Skip to content

Except high memory used when use use socket server loop #37485

Open

Description

Julia version 1.5.0
my code just start a socket server, I run the code,the Julia main process memory will increase very fast and high,but I can not found the memory used where in my code.
image

my code as below:

import Sockets
import Future
import Distributed
# import JuMP
# import Plots
function clientHandle(client)
    println("Client EST")
    local fileHandler = open(raw"./clientRecordMsg.txt","w+")
    while isopen(client)
        msgVector = readavailable(client)
        clientMsg=""
        for byte in msgVector
            clientMsg*=string(Char(byte))
        end
        println(clientMsg)
        if  occursin(raw"writeFile",clientMsg)
            write(fileHandler,clientMsg*"\n")
            write(client, "write to file")
        elseif occursin(raw"printMsg",clientMsg)
            println(clientMsg)
            write(client, "print Msg to console\n")
        elseif occursin(raw"server Quit",clientMsg)
            println("server Quit")
            runFlag=false
            break;
        end
    end
    close(fileHandler)
end
function tcpServerTest(port)
    server = Sockets.listen(port)
    local runFlag = true
    local counter = UInt64(0)
    while runFlag
        Sockets.accept(clientHandle,server)
    end
    close(server)
end
println("Start\n")
# @async tcpServerTest(8888)
tcpServerTest(8888)
println("End\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions