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

High memory usage (possible memory leak) #70

Closed
Couto opened this issue Apr 13, 2017 · 9 comments
Closed

High memory usage (possible memory leak) #70

Couto opened this issue Apr 13, 2017 · 9 comments

Comments

@Couto
Copy link

Couto commented Apr 13, 2017

This seems to happen regulary... and unfortunately I can't provide much information (mostly because I don't know where to start)

Still I'm trying to attach as much information as I can gather:

screen shot 2017-04-13 at 18 23 33

screen shot 2017-04-13 at 18 24 26

screen shot 2017-04-13 at 18 24 49

screen shot 2017-04-13 at 18 25 21

I'm also attaching a sample taken with the OSX dialog.
Sample of flow.txt

By the end of writing this post flow is now consuming >9Gb of memory:

screen shot 2017-04-13 at 18 29 00

@TimothyKrell
Copy link

TimothyKrell commented May 3, 2017

I'm seeing this problem too. I was able to narrow it down to a specific piece of code.

Steps I took to narrow it down:

  1. Run flow init in empty dir and run flow start to make sure everything is working
  2. Ignore source folders using .flowconfig until problem stops. Test by running flow start, then killall flow if cpu goes high.
  3. Once you find problematic files, copy them into a fresh flow init folder and begin commenting out parts of file until you've found the problematic code using the flow start killall flow cycle.

This was the code that was giving me issue. Seems related to facebook/flow#3370.

let createRelationshipPaths = (path = "", rels = []) => {
  return rels.length
    ? rels.reduce((acc, [name, nested]) => {
        return [
          ...acc,
          ...createRelationshipPaths(path ? `${path}.${name}` : name, nested)
        ];
      }, path ? [path] : [])
    : [path];
};

After narrowing down to the file and this specific piece of code I was able to get it to work without hanging by annotating the function's return value.

let createRelationshipPaths = (path = "", rels = []): string[] => {
// This fixes it --------------------------------------^
  return rels.length
    ? rels.reduce((acc, [name, nested]) => {
        return [
          ...acc,
          ...createRelationshipPaths(path ? `${path}.${name}` : name, nested)
        ];
      }, path ? [path] : [])
    : [path];
};

Version: v0.45.0
OS: MacOS 10.12.3

@ajostergaard
Copy link

I'm seeing the same regardless of version - tested all from v0.40.0 to v0.46.0.

Just a thought but should this be raised against flow itself rather than this binary? There appear to be lots of similar issues there, for example facebook/flow#3370.

@sarkistlt
Copy link

sarkistlt commented May 16, 2017

I found one more way around, in my case even if I'll ignore node_modules it always overload CPU, I'm also using option all=true and in the same project if I'll add comment // @flow as a first line and change to all=false everything works. But I want to be able check my code without adding that new line. You can try it in your project, the most convenient way to add new line for multiple files I found, is (for OSX): find . -type f -name '*.js' -exec sed -i '' '1s/^/\/\/ @flow\'$'\n/' {} \;

@couturecraigj
Copy link

I am seeing this too and often times it gives me such memory pressure that it is not even improving my developer experience.

@brentmulligan
Copy link

I had this issue while using flow-typed and was able to fix it by removing the flow-typed directory and re-installing.

@patrickgordon
Copy link

This is almost certainly still a problem. has anyone had any success in reducing the memory leak / footprint of using flow? Particularly noticed when using with VS Code

@Victor-Jansson
Copy link

This caused my Macbook pro to crash. After that crash I got around 10 kernel panics the following few days, they didn't stop until I reset the smc. This issue still exists where flow-bin consumes all vitual memory and max on cpu. My app is basically a react-native create-app.

@jbrown215
Copy link
Contributor

Have you tried using lazy modes? Start the server with flow start --lazy-mode fs.

@Couto
Copy link
Author

Couto commented Oct 25, 2019

Either this has been fixed, or is unlikely to be fixed in the near future. I'm closing this issue.
Feel free to reopen if some work is done.

@Couto Couto closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants