OMJulia.jl
OMJulia.jl copied to clipboard
Closing of OMCSession
When I run perform batch processes based on OMJulia, several hundret calls of OMCSession are performed.

After that I have many abandonded processes which push the RAM consumption of my (Linux) computer to its limits.
I could neither find in the documentation nor in the examples, how I can free the memory resources by closing the used OMCSession. My question thus refers to an equivalence of close, used after openening and writing a file. Is such closing alread implemented? If not, it possibly should be implemented.
@christiankral to delete a session you have to use quit() like sendExpression(omc, "quit()")
I tried the following:
using OMJulia
mod = OMJulia.OMCSession()
sendExpression(mod, "quit()")
The third line causes an error message:
ERROR: OMJulia.Parser.ParseError("Expected EOF, got output Any[OMJulia.Parser.Identifier(\"requested\"), Symbol(\",\"), OMJulia.Parser.Identifier(\"shutting\"), OMJulia.Parser.Identifier(\"server\"), OMJulia.Parser.Identifier(\"down\")]")
Stacktrace:
[1] parseOM(tokens::Vector{Any})
@ OMJulia.Parser ~/.julia/packages/OMJulia/GiA9Y/src/parser.jl:121
[2] parseOM
@ ~/.julia/packages/OMJulia/GiA9Y/src/parser.jl:127 [inlined]
[3] sendExpression(omc::OMJulia.OMCSession, expr::String; parsed::Bool)
@ OMJulia ~/.julia/packages/OMJulia/GiA9Y/src/OMJulia.jl:184
[4] sendExpression(omc::OMJulia.OMCSession, expr::String)
@ OMJulia ~/.julia/packages/OMJulia/GiA9Y/src/OMJulia.jl:180
[5] top-level scope
@ REPL[3]:1
@christiankral , It seems there is a problem with Julia parser when parsing the results from omc, please disable the parser like below
julia> omc = OMJulia.OMCSession()
julia> sendExpression(omc, "getVersion()")
"OpenModelica v1.20.0-dev-101-g55feca18f5 (64-bit)"
julia> sendExpression(omc, "quit()", parsed=false)
"quit requested, shutting server down\n"
OK. the option parsed=false seems to work:
sendExpression(omc, "getVersion()")
"OpenModelica 1.20.0~dev-121-gfa321a0"
sendExpression(omc, "quit()", parsed=false)
"quit requested, shutting server down\n"
@arun3688 Is the option parsed=false already the full solution to my request or is it a parsing issue that needs to be solved?
@christiankral Well the immediate solution is to use parsed = false, but offcourse we need to fix the parser
Hi OliWard,
From the error message i can see that you are using old version of OMJulia, please update your OMJulia package with the latest master and perform the test.
regards arun
On Tue, Feb 14, 2023 at 3:35 PM Oli Ward @.***> wrote:
@arun3688 https://github.com/arun3688 Apologies that this is an old thread but I am also encountering issues closing OMCSessions. Using sendExpression(omc, "quit()") produces ERROR: OMJulia.Parser.ParseError as @christiankral https://github.com/christiankral posted above. However, when I try sendExpression(omc, "quit()", parsed=false), I get a method error:
ERROR: MethodError: no method matching sendExpression(::OMJulia.OMCSession, ::String; parsed=false) Closest candidates are: sendExpression(::Any, ::Any) at ~/.julia/packages/OMJulia/ZLXEs/src/OMJulia.jl:1012 got unsupported keyword argument "parsed" Stacktrace: [1] test() @ Main.OMJ_V2 ./REPL[53]:15 [2] top-level scope @ REPL[54]:1```
— Reply to this email directly, view it on GitHub https://github.com/OpenModelica/OMJulia.jl/issues/62#issuecomment-1429845310, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUNPJO6FYKRPZLBQE3IOQDWXOJ23ANCNFSM5YMM4OLA . You are receiving this because you were mentioned.Message ID: @.***>
Hi @arun3688,
Thank you for your quick reply. My issue stopped when I restarted my Julia session but I have also updated OMJulia since, thanks for pointing that out!