castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
423 stars 25 forks source link

[solargraph socket] process make me computer crash, because memory takes up 99% #138

Closed doraemon0711 closed 4 years ago

doraemon0711 commented 5 years ago

system is ubuntu18.04 solargraph gem is 0.35.2

castwide commented 5 years ago

Does this happen when you open a particular folder or workspace? There might be something in a gem dependency that makes Solargraph choke, or the problem might be the sheer size of the project, or it might be something I'm incapable of guessing .

doraemon0711 commented 5 years ago

It's happened when i use vscode,but i'm not sure happened when open a particular folder or workspace.I can confirm is project is not sheer size. Did you know what's gem will make Solargraph choke?

castwide commented 5 years ago

I don't know of a particular gem that might make it happen. Some gems like google-api-client are too large to handle, but you should get a warning about it instead of a crash.

Can you provide a minimal example of a project that causes the problem?

doraemon0711 commented 5 years ago

When my computer next crash, i can provide some code for issue, But i can provide a used gemfile,it's not all be used in my project

ruby '~> 2.5.0'

gem 'rails', '~> 5.2.1'
gem 'sqlite3'
gem 'activerecord-oracle_enhanced-adapter', '~> 5.2.0'
gem 'ruby-oci8', '~> 2.2', '>= 2.2.6.1'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'config', '~> 1.7'
gem 'dotenv-rails', '~> 2.5'
gem 'act_form', '~> 0.3.2'
gem 'rest-client', '~> 2.0', '>= 2.0.2'
gem 'redis', '~> 4.0', '>= 4.0.2'
gem 'hiredis', '~> 0.6.1'
gem 'uuid', '~> 2.3', '>= 2.3.9'
gem 'grape', '~> 1.1'
gem 'grape_on_rails_routes', '~> 0.3.2'
gem 'grape-middleware-logger', '~> 1.10'
gem 'webpacker', '>= 4.0.x'
gem 'bunny', '~> 2.12', '>= 2.12.1'
gem 'pundit', '~> 2.0'
gem 'byebug'
gem 'rspec-rails', '~> 3.8'
gem 'pry-rails', '~> 0.3.6'
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'rubocop', require: false
gem 'annotate', '~> 2.6.5'
gem 'tzinfo-data'
gem 'sunspot_rails', '~> 2.3.0'
gem 'sunspot_solr', '~> 2.3.0'
gem 'enumerize', '~> 2.2.2'
gem 'kaminari', '~> 1.1', '>= 1.1.1'
gem 'ransack', '~> 2.1'
gem 'oauth2', '1.3.1'
gem 'omniauth', '1.3.1'
gem 'omniauth-oauth2', '1.3.1'
gem 'jwt', '~> 1.0'
gem 'acts_as_tree', '~> 2.8'
gem 'faraday', '0.9.0'
gem 'whenever', '~> 0.10.0', require: false
gem 'sidekiq-cron', '~> 1.0', '>= 1.0.4'
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
gem 'aasm', '~> 5.0.1'
gem 'graylog_exception_notifier', '~> 0.1'
gem 'exception_notification', '~> 4.3'
gem 'oj', '~> 3.7', '>= 3.7.11'
gem 'jb', '~> 0.7.0'
gem 'roo', '~> 2.8.2'
gem 'rubyXL', '~> 3.4.3'
gem 'rubyzip', '>= 1.2.1'
gem 'axlsx', path: 'vendor/axlsx'
gem 'axlsx_rails', '~> 0.5.2'
castwide commented 5 years ago

I created a Gemfile with two minor changes:

  1. Added source 'https://rubygems.org'
  2. Deleted the path to axlsx

Then I ran bundle install and opened the folder in VS Code. I created a Ruby file with require 'bundler/require' so it would map all the gems. It took about 20 seconds to map, but it worked. The process used about 470MB of memory.

Assuming the problem is not a physical memory limitation, there might be something else in your code that's choking the language server.

doraemon0711 commented 5 years ago

Thanks for your reply. And just now,my coputer is crashed.At that time,opened ruby is two models and some used Grape created api file, and in thie file maximum number of rows is 200, some model used Solr gem. Is this information useful? Thanks

castwide commented 5 years ago

Are you running the Rails app and Solargraph at the same time? If so, can you determine how much memory Rails alone is using?

How much memory does your system have?

Do you have a swap file?

doraemon0711 commented 5 years ago

No,i'm not running rails server or rails console, just use VSCode to coding.

This is puma used memory 2019-08-09 14-18-50 的屏幕截图

My system memory is 8G, and swap file is 2G

This is Solargraph socket process used memory, but i'm not open any ruby file 2019-08-09 14-24-47 的屏幕截图

As time goes on, one Solargraph socket process's MEM% will be 15%

castwide commented 5 years ago

Thanks for the info. I suspect Solargraph's mapper is hitting code it can't process.

One more thing you can try. Go to your project's root directory and run solargraph scan -v. If the output throws an error or freezes, that might tell us where the problem is occurring. More information: https://solargraph.org/guides/scanning-workspaces

doraemon0711 commented 5 years ago

I use solargraph scan -v for my project,it's output many info(39767 lines) in console, i'm tee this info to a txt file, but i can't find what's problem happend.

In weblink's info, possible bug will tell me error's location,but output info is like this Contact | (/xxxxx/app/models/contact.rb 75) | :ref_type (/xxxxx/app/models/contact.rb 75) | :class_name (/xxxxx/app/models/contact.rb 76) i think is not error's location. And another possible is entered an infinite loop, but in output end, print xxxxxx (39765 pins) in 81.8124532569991 seconds. i think it's ok

castwide commented 5 years ago

Hmm. Yeah, if it got all the way to the end, it's probably not a mapper bug.

Are there any errors reported in VS Code's developer console (Help -> Toggle Developer Tools)?

doraemon0711 commented 5 years ago

Thank you,when i find some errors, i'm talking to you, have nice day : )