Skip to content

Leaking 10GB memory per minute with wrong type alias def type Foo = Foo for some ghc versions #352

Closed
@anka-213

Description

@anka-213

Opening this file in vs code

import Control.Monad.State
import Control.Applicative
import Data.List

data T = T [T] deriving (Show)
type Parser = Parser

ch :: Char -> Parser Char
ch c = mfilter (== c) $ StateT uncons

parens :: Parser T
parens = T <$ ch '(' <*> many parens <* ch ')'

parse :: Parser a -> String -> Maybe (a, String)
parse = runStateT

causes HLS to consume a lot of ram quickly. This is the result after just a few minutes of having the file open.
Screenshot 2020-08-25 at 21 17 07

Log
[client] run command: "/Users/anka/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.3.0-darwin-8.8.3 --lsp"
[client] debug command: "/Users/anka/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.3.0-darwin-8.8.3 --lsp"
[client] server cwd: /Users/anka/projekt/haskell/bug
haskell-language-server version: 0.3.0.0 (GHC: 8.8.3) (PATH: /Users/anka/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.3.0-darwin-8.8.3) (GIT hash: d36bb9929fdd0df76f86d3635067400272f68497)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell"]
  in directory: /Users/anka/projekt/haskell/bug
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.00s
2020-08-25 22:14:15.349258 [ThreadId 31] - Opened text document: file:///Users/anka/projekt/haskell/bug/ParserInTweet.hs
2020-08-25 22:14:15.350402 [ThreadId 90] - Data.HashMap.Internal.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Internal.hs:753:16 in nrdrd-cntnrs-0.2.12.0-a2bf77ff:Data.HashMap.Internal
  !, called at src/Development/IDE/Import/DependencyInformation.hs:107:40 in ghcide-0.2.0-inplace:Development.IDE.Import.DependencyInformation
2020-08-25 22:14:15.350857 [ThreadId 87] - Consulting the cradle for "/Users/anka/projekt/haskell/bug/ParserInTweet.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/anka/projekt/haskell/bug", cradleOptsProg = CradleAction: Default}
2020-08-25 22:14:15.496314 [ThreadId 87] - Using interface files cache dir: /Users/anka/.cache/ghcide/main-da39a3ee5e6b4b0d3255bfef95601890afd80709
2020-08-25 22:14:15.496422 [ThreadId 87] - Making new HscEnv[main]
2020-08-25 22:14:17.522717 [ThreadId 202] - Plugin.makeCodeLens (ideLogger)

Regardless of if this specific bug is fixed, we should probably add some limit, so HLS won't consume all available memory on the system when problems arise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcideperformanceIssues about memory consumption, responsiveness, etc.type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions