Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Memory leak in fsautocomplete #94

Open
Disco-Dave opened this issue Jul 11, 2017 · 14 comments
Open

Memory leak in fsautocomplete #94

Disco-Dave opened this issue Jul 11, 2017 · 14 comments

Comments

@Disco-Dave
Copy link

I'm consistently getting a memory leak. If I try to autocomplete my memory keeps rising and I believe the fsautocomplete is the culprit. Is there anything I can do about this? If not is there is a way I can disable the fsautocomplete, as the auto completion is not necessary for me.

Also please let me know if I can provide any more info, thank you.

Image of vim and htop

My vim version is the following

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun  8 2017 20:51:28)
Included patches: 1-628
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl             +cscope          -footer          +menu            +num64           +startuptime     +virtualedit
+arabic          +cursorbind      +fork()          +mksession       +packages        +statusline      +visual
+autocmd         +cursorshape     +gettext         +modify_fname    +path_extra      -sun_workshop    +visualextra
+balloon_eval    +dialog_con_gui  -hangul_input    +mouse           +perl/dyn        +syntax          +viminfo
+browse          +diff            +iconv           +mouseshape      +persistent_undo +tag_binary      +vreplace
++builtin_terms  +digraphs        +insert_expand   +mouse_dec       +postscript      +tag_old_static  +wildignore
+byte_offset     +dnd             +job             +mouse_gpm       +printer         -tag_any_white   +wildmenu
+channel         -ebcdic          +jumplist        -mouse_jsbterm   +profile         +tcl/dyn         +windows
+cindent         +emacs_tags      +keymap          +mouse_netterm   +python/dyn      +termguicolors   +writebackup
+clientserver    +eval            +lambda          +mouse_sgr       +python3/dyn     +terminfo        +X11
+clipboard       +ex_extra        +langmap         -mouse_sysmouse  +quickfix        +termresponse    -xfontset
+cmdline_compl   +extra_search    +libcall         +mouse_urxvt     +reltime         +textobjects     +xim
+cmdline_hist    +farsi           +linebreak       +mouse_xterm     +rightleft       +timers          -xpm
+cmdline_info    +file_in_path    +lispindent      +multi_byte      +ruby/dyn        +title           +xsmp_interact
+comments        +find_in_path    +listcmds        +multi_lang      +scrollbind      +toolbar         +xterm_clipboard
+conceal         +float           +localmap        -mzscheme        +signs           +user_commands   -xterm_save
+cryptv          +folding         +lua/dyn         +netbeans_intg   +smartindent     +vertsplit
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0
 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-
2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/
include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/i
nclude/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/in
clude/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe
 -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpat
h,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3
-lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lS
M -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5
/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_pe
rl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lieee -lm

my vimrc is the following

let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'

call plug#begin('/$HOME/.vim/plugged')

Plug 'flazz/vim-colorschemes'
Plug 'itchyny/lightline.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'scrooloose/syntastic'
Plug 'fsharp/vim-fsharp', {
      \ 'for': 'fsharp',
      \ 'do':  'make fsautocomplete',
      \}

call plug#end()
" My custom settings
set autoindent
set autoread
set backspace=2 
set expandtab
set foldlevel=5
set foldmethod=indent
set foldnestmax=10
set hidden
set history=500
" set hlsearch
set incsearch
set laststatus=2
set lazyredraw
set magic
set nocompatible
set nofoldenable
set noshowmode
set path+=**
set relativenumber
set shiftwidth=4
set showcmd
set smartcase
set smartindent
set smarttab
set so=7
set softtabstop=4
set tabstop=4
set timeoutlen=50
set wildmenu
syntax on

" Use backup, undo, and swap folders
set backup
set undofile
set undodir=/$HOME/.vim/temp_dirs/undo//
set backupdir=/$HOME/.vim/temp_dirs/backup//
set directory=/$HOME/.vim/temp_dirs/swap//

"Disable all use of a mouse
autocmd BufEnter * set mouse=

" Get rid of indenting at a : for python
autocmd FileType python setlocal indentkeys-=<:>
autocmd FileType python setlocal indentkeys-=:

@kjnilsson
Copy link
Contributor

Are you saying vim is increasing in memory or the fsautocomplete process is increasing in memory? If it is the latter you may want to raise it in https://github.com/fsharp/FsAutoComplete.

It is normal for fsautocomplete to increase in memory as it never release projects it has parsed.

@Disco-Dave
Copy link
Author

Yes it is fsautocomplete that increases in memory indefinitely and also appears to make more processes. This goes on to the point where my memory gets full and starts swapping. This problem doesn't seem to exist in vscode with ionide which also uses fsautocomplete. However i can still raise the issue with fsautocomplete.

Is there anyway I can disable fsautocomplete to keep it from running? Because it is mostly the syntastic support and the fsi commands that attract me to this plugin.

@kjnilsson
Copy link
Contributor

FsAutoComplete does the syntax checking so I wouldn't recommend disabling it. You will get one process per vim instance. There is no restart logic so I can't see how you can get more than one fsautocomplete instance per vim instance.

@Disco-Dave
Copy link
Author

The FsAutoComplete's stay running even after vim is closed. This picture is taken about a minute after closing vim.

Imgage of htop a minute after closing vim

@0x6a62
Copy link
Contributor

0x6a62 commented Jul 12, 2017

Fwiw, I've seen similar issues happen occasionally (fsautocomplete memory and cpu go crazy, and mono instance hangs around). I'm on (vim8 on Windows8). It's been too sporadic for me to track down so far, plus it hasn't quite annoyed me enough yet. I think it's hit me in sessions where I haven't used autocomplete, so I'm not sure if it is one of the periodic syntax checks. Just killing the mono instances and restarting vim gets me back where I need to be. That's not really an help, just commiserating and offering another datapoint.

@kjnilsson
Copy link
Contributor

@Disco-Dave I see the CPU is pegged at 100% on all your instances there. This could be due to ionide/FsAutoComplete#105 which I've occasionally seen. This may also explain why they are being left running as perhaps a background thread is still active and prohibiting the process for exiting.

@kjnilsson
Copy link
Contributor

@Disco-Dave @0x6a62 please add your experiences to ionide/FsAutoComplete#105 which may eventually provide enough information to work out why it happens.

It does look like the issue isn't due to vim-fsharp itself however although we could perhaps try to force kill the process on vim exit.

@Disco-Dave
Copy link
Author

The problem is definitely occurring for me when Syntastic marks something as an error. I also noticed the autocompletion doesn't seem to work for fsharp either, so maybe there is something else going on.

My relevant Syntastic and vim-fsharp settings

" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0

" Fsharp
let g:fsharp_only_check_errors_on_write = 1
let g:fsharp_xbuild_path = "/usr/bin/xbuild"
let g:fsharp_completion_helptext = 1

How my plugins are installed

let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'

call plug#begin('/$HOME/.vim/plugged')

" Appearane Related
Plug 'flazz/vim-colorschemes'
Plug 'itchyny/lightline.vim'

" Enhancements
Plug 'christoomey/vim-tmux-navigator'
Plug 'ervandew/supertab'

" Tools
Plug 'raimondi/delimitmate'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'

" Language Support
Plug 'fsharp/vim-fsharp', {
    \ 'for': 'fsharp',
    \ 'dir': '~/.vim/plugged/vim-fsharp',
    \ 'do':  'make fsautocomplete',
    \}
Plug 'Valloric/YouCompleteMe', {
    \ 'dir': '~/.vim/plugged/YouCompleteMe',
    \ 'do': './install.py  --all',
    \}

call plug#end()

Rest of my vimrc stuff here

Mono

Mono JIT compiler version 5.0.0 (Stable 5.0.0.100/9667aa6 Wed Jul 12 17:00:30 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen (concurrent by default)

@ryukinix
Copy link

ryukinix commented Aug 7, 2017

Just an additional info: I can confirm that problem using fsharp-mode with Emacs too, which uses FsAutoComplete. With a random session I easilly got 1.5 GB of memory usage. :(

@rneatherway
Copy link
Member

Does the memory usage keep rising? Can you put up a repository with instructions of how to reproduce in Emacs?

@ryukinix
Copy link

@rneatherway sorry for the delayed response. Yes, the memory usage keep rising, but this happened in earlier days and I cannot reproduce anymore :(. This happened using the Fable.Template after install the nodejs (nojo.js in portuguese) dependencies. But I'm still using emacs-fsharp-mode, so if I can reproduce this again I'll open a issue on the emacs repo, ok?

@rneatherway thanks for the attention. :)

@Disco-Dave
Copy link
Author

This doesn't seem to be affecting me anymore.

@enricosada
Copy link

@kjnilsson the fsac is a zombie issue can be fixed with new fsac argument --hostPID (ref ionide/FsAutoComplete#190 )
So fsac will terminate itself if the vim process who started it is closed.
Vim should pass that argument with the vim process id

@kjnilsson
Copy link
Contributor

@enricosada nice - thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants