-
Notifications
You must be signed in to change notification settings - Fork 202
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
Huge memory usage (10GB+) during Phoenix debugging on a new project #1017
Comments
Did you try attaching observer to the node to see what is actually taking up the memory? You can set sname/name via |
@lukaszsamson |
It's hard to tell what is the cause. It may be a drawback of OTP debugger. Excluding some modules from auto interpreting may help here. |
TBH I don't know this side of Erlang/Elixir, so it is no easy for me to move around in this. Anyhow here you can find the repo where I reproduced the issue. |
I've excluded almost every module (in a real Phoenix project) except from the code from the actual application and the issue persists. Tried whit OTP26 as well, nothing changes. In the demo project the situation is better but the queries are small (just a couple of records from a single table) I think this is very impacting and make the debugger unusable, Any thoughts? |
@lukaszsamson |
@fnicastri There is interest. I'm not closing the issue but currently I'm involved in language server stability fixes |
@lukaszsamson |
@fnicastri I reproduced easily the problem with your sample app. The memory goes even up to 20GB after a few breakpoints. I'm not sure what is the cause. As you mentioned one of the processes that starts taking up insane amounts of memory is cowboy_stream_h but also ElixirLS.Debugger.Server. It seems the state is not the problem here as it holds only a few kB there. I suspect binaries - if I force GC it goes back to manageable 4GB. I will experiment with Jason settings (the only place I know when one can control how the binaries are handled).
In the example you did not exclude anything. That will not work as this option needs full module names
Instead try this:
This will disable interpreting of everything but modules matching the glob. In case of the example app this completely resolves the issue and debugger stays at ~90MB. |
It's not binaries but heap process heap as you wrote.
I tried setting |
Sorry, I never pushed that but I excluded them |
Tried on a real project, no changes... :( |
Just to be clear in Debugger dumps to console all interpreted modules
I wonder which process is taking up memory in your project when you disable interpretting cowboy. Some other ideas to try:
|
Closing as this is not addressable in this project. Please reopen an issue to either cowboy or OTP |
@fnicastri can you share your launch.json that I could use with an empty phoenix app? Last time I tried the workarounds from #1017 (comment) fixed the issue. Other people also reported that it works in their case |
Doing some tests with current releases... |
Things are better now but still, if you add some db calls or try to debug the Web app, memory goes up. I've tried many scenarios, some are okayish, repo LiveView is much worse than a plain view
{
"version": "0.2.0",
"configurations": [
{
"type": "mix_task",
"name": "mix (Default task)",
"request": "launch",
"task": "phx.server",
"projectDir": "${workspaceRoot}",
"env": {},
"exitAfterTaskReturns": false,
"debugAutoInterpretAllModules": false,
"debugInterpretModulesPatterns": [
"DebuggerTestWeb.*"
],
}
]
}
|
With the Erlang debugger the memory always remains around 100 MB with the same project |
Some related discussion occurred in this issue as well: #1101. Copying relevant message here:
def gen_data() do
StreamData.list_of(StreamData.fixed_map(%{
"e" => StreamData.string(:utf8)
}), min_length: 1, max_length: 1)
end
def gen_data_all() do
gen all fixed_map <- gen_data() do
fixed_map
end
end
test "greets the world" do
data = Enum.at(gen_data_all(), 0)
assert ElixirLsFailure.hello() == :world
end
|
Minimal reproduction : https://github.com/jsermeno/elixir_ls_debug_failure. |
Current behavior
During a debug session thru ElixirLS Debugger there is a huge spike in memory usage during Ecto's query.
Loading the index page (no queries) the memory spike is under a gigabyte.
I've noticed this behavior previously in the last few months.
Steps to Reproduce
mix phx.gen.html
beam.smp
processes consume GBs of memory (10+)Expected behavior
Not consuming over 10 GB of memory ;)
Environment
macOS 13.6.1 (22G313)
VSCode
ElixirLS: Elixir support and debugger v0.17.5
v1.7.9
The text was updated successfully, but these errors were encountered: