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

[Bug] joern server run out of memory #5138

Open
canliture opened this issue Nov 27, 2024 · 1 comment
Open

[Bug] joern server run out of memory #5138

canliture opened this issue Nov 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@canliture
Copy link
Contributor

canliture commented Nov 27, 2024

Describe the bug
we use joern --server to start joern query server, but it can run out of memory if joern server run after a long time.

To Reproduce
Steps to reproduce the behavior:

  1. ./joern server
  2. request query many many times, the query return a batch of many many json
  3. after a long time
  4. the server hold many many memory, it can't release the memory
  5. run out of my memory in computer

Additional context
I think we can't simply start with joern --server -J-Xmx${N}G to solve the problem, because my workstation server has 1000G memory, I use -J-Xmx500G, the memory will also be up to 500G+

I think I have guessed the reason.

the repl-server simulate a REPL interpreter. Evaluates a expression query every time, it will print a temp variable (with some counter suffix name), like

res27 = ....

if you evaluate again, it will print res28

res28 = ...

we can always use REPL to Forward Reference the temp variable res0, res1, ..., res27, res28, ... resN ..., it will never be released, it will always exists in the memory.

But in server mode, we just want to evaluate a expression and return, and soon release the temp variable memory.

I don't know how to solve the problem. Maybe it is a inherent problem in the REPL.

Thank you for your attention!

@canliture canliture added the bug Something isn't working label Nov 27, 2024
@jyfct356
Copy link

jyfct356 commented Jan 21, 2025

学长你好,我的工作需要使用joern,我正在使用joern开源工具搭建一个程序分析服务。
我是用如下命令启动joern server。

`/home/noisy/codeDigitization/joernPart/joern/joern --server --server-host localhost --server-port 8083 -verbose -debug

`并且使用joern官方提供的client工具访问,我的python脚本如下。


`from cpgqls_client import CPGQLSClient, import_code_query, workspace_query

server_endpoint = "localhost:8083"
client = CPGQLSClient(server_endpoint)

# execute a simple CPGQuery
query = "val a = 1"
result = client.execute(query)
print(result)

# execute a workspace CPGQuery
query = workspace_query()
result = client.execute(query)
print(result['stdout'])

# execute an importCode CPGQuery
query = import_code_query("/home/user/code/x42/c", "my-c-project")
result = client.execute(query)
print(result['stdout'])

query = import_code_query("/home/user/code/x42/java/X42.jar", "my-java-project")
result = client.execute(query)
print(result['stdout'])`

但是永远得到一个503的错误,请问你有遇到过同样的问题嘛,如果有,请问可能的原因是什么,可以怎么解决。报错信息如下,最后的响应结果是我修改了client源码手动打印的。

Image

万分感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants