flow icon indicating copy to clipboard operation
flow copied to clipboard

Add configuration for shared mem size

Open patrick-lewandowski opened this issue 12 years ago • 19 comments

Hi all,

I am trying to do one of the examples and keep receiving the following error:

/flow/examples/01_HelloWorld # flow check Error initializing: Cannot allocate memory

Any ideas what might the issue might be? I am running this on:

SUSE Linux Enterprise Server 11 (x86_64) VERSION = 11 PATCHLEVEL = 3

Thanks in advance for the support!

patrick-lewandowski avatar Nov 21 '14 15:11 patrick-lewandowski

Maybe you can try running it with flow check --debug and see if that has any more useful info?

tcoopman avatar Nov 21 '14 20:11 tcoopman

Unfortunately, debug does not yield any additional information:

/flow/examples/01_HelloWorld # flow check --debug Error initializing: Cannot allocate memory

patrick-lewandowski avatar Nov 21 '14 21:11 patrick-lewandowski

Also, I would like to mention this error is consistent across both versions (0.1.0 & 0.1.1).

patrick-lewandowski avatar Nov 21 '14 21:11 patrick-lewandowski

And do you get the same error running flow start? Maybe try running it as root to see if that changes anything?

I'm just taking some guesses here...

On Fri, 21 Nov 2014 22:07 patryk0605 [email protected] wrote:

Also, I would like to mention this error is consistent across both versions (0.1.0 & 0.1.1).

— Reply to this email directly or view it on GitHub https://github.com/facebook/flow/issues/99#issuecomment-64037721.

tcoopman avatar Nov 21 '14 22:11 tcoopman

How much RAM do you have? It might be that we have a setting around how much space we eagerly allocate that you can change and recompile. (This is some code we bring in from Hack, not entirely familiar with what's going on there, but you can try playing around with the constants in https://github.com/facebook/flow/blob/master/hack/heap/hh_shared.c.)

avikchaudhuri avatar Nov 21 '14 22:11 avikchaudhuri

I have been running flow as root. The result of flow start is:

/flow/examples/01_HelloWorld # flow start Spawned flow server (child pid=11700) Logs will go to /tmp/flow_root/root-zSoptzSflowzSflowzSexampleszS01_HelloWorld.log

And the log just contains the same information (Error initializing: Cannot allocate memory).

Regarding RAM, I have 2GB total with around 200MB free.

patrick-lewandowski avatar Nov 24 '14 14:11 patrick-lewandowski

I have the same issue. strace shows flow tries to allocate 23GB memory:

mmap(0x500000000000, 23756541952, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED|MAP_ANONYMOUS|MAP_NORESERVE, 0, 0) = -1 ENOMEM (Cannot allocate memory)

gdb backtrace at that mmap:

(gdb) bt
#0  0x00007ffff73fcaba in mmap64 () from /usr/lib/libc.so.6
#1  0x00007ffff738113c in __GI__IO_file_doallocate () from /usr/lib/libc.so.6
#2  0x00007ffff738dd20 in __GI__IO_doallocbuf () from /usr/lib/libc.so.6
#3  0x00007ffff738d1a8 in __GI__IO_file_overflow () from /usr/lib/libc.so.6
#4  0x00007ffff738c3ba in __GI__IO_file_xsputn () from /usr/lib/libc.so.6
#5  0x00007ffff735d540 in vfprintf () from /usr/lib/libc.so.6
#6  0x00007ffff7367e39 in printf () from /usr/lib/libc.so.6
#7  0x0000000000574e68 in hh_shared_init ()
#8  0x000000000050a2b7 in camlSharedMem__init_1252 ()
#9  0x000000000043dc74 in camlServerFunctors__main_1586 ()
#10 0x000000000043dfa1 in camlServerFunctors__start_1893 ()
#11 0x000000000040a02b in camlFlow__entry ()
#12 0x0000000000404d59 in caml_program ()
#13 0x00000000005884ca in caml_start_program ()
#14 0x0000000000000000 in ?? ()

heap_size passed to hh_shared_init is 21474836480, which is the problem.

Then the question is, why default heap size is hardcoded 20 GB (in hack/heap/sharedMem.ml)?

let default_config =
  let gig = 1024 * 1024 * 1024 in
  {global_size = gig; heap_size = 20 * gig}

quark-zju avatar Jul 07 '15 02:07 quark-zju

Someone just ran into this problem at my work. We have a flow server running as part of our build process, and for some reason /tmp/flow was filled up with 5 gigs of stuff, maxing out the drive and causing an ENOSPC error.

Unfortunately I have no more details -- someone killed the flow processes and cleared out the directory before I could get to it.

Running flow-bin 0.13.1.

bradencanderson avatar Jul 24 '15 22:07 bradencanderson

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

ghost avatar Aug 04 '15 18:08 ghost

Ubuntu 14.04 x86 / 3.8 GiB RAM / core 2 duo / 5.6 G disk available. I cloned from git (master branch at f45d331ce4035b94d2f2ab3a6ba512a51b07a162) & ran make & then ran the tests and the mostly all failed. A lot had this "Cannot allocate memory" message. And finally reported Passed: 3, Failed: 183, Skipped: 3 (I didn't see a log file generated?)

If I try to launch flow itself, instead of running the tests, it fails to start. Flow server launched for /home/superman/Dev/flow Spawned flow server (child pid=19550) Logs will go to /tmp/flow/zxSflow.log Out of retries, exiting! df -h /tmp gives 2G available, fwiw.

raould avatar Sep 27 '15 17:09 raould

I have the same problem here, 50MB free RAM. If this is too little, perhaps there should be a warning somewhere about how much RAM this thing consumes.

fiatjaf avatar Jan 01 '16 22:01 fiatjaf

Right now we allocate a bunch of memory up front for the server, which is great for us internally where we have beefy machines and want super fast type feedback.

Making this configurable isn't a high priority for us internally, but community contributions to add a config option are very welcome.

samwgoldman avatar Jan 27 '16 20:01 samwgoldman

I also ran into this and worked around it with "ulimit -v unlimited", but it was surprising to learn from this ticket that Flow crashed because Hack (?) mmaps a couple dozen gigabytes of memory for its own heap.

dsilva avatar Mar 15 '16 19:03 dsilva

@gabelevi fixed?

mroch avatar May 31 '16 21:05 mroch

is there anyway to specify how much memory should flow use?

arypurnomoz avatar Jun 12 '16 05:06 arypurnomoz

Pretty sure this is fixed now. Will close soon unless someone here chimes in.

nmn avatar Mar 04 '17 03:03 nmn

How is it fixed ? I don't see any command line options mentioned in the readme .

ysangkok avatar Mar 04 '17 09:03 ysangkok

@ysangkok The Flow docs are slightly outdated. Please try looking at the output from flow --help.

Also, I was talking about the Error initializing: Cannot allocate memory thing being fixed now.

nmn avatar Mar 06 '17 18:03 nmn

I believe this been fixed a while ago but please re-open if not.

vicapow avatar Feb 01 '19 03:02 vicapow