0

In other words -- with 1MB stacks (-Xss1m), do you actually bump your RSS by 1M every time you create a thread, or do you just consume 1MB of VSZ, plus a few actual pages top and/or bottom?

In other, other words, on 64b systems, and assuming it does the right thing (just map), is there any real downside to large (say, 10MB) "just-in-case" stacks?

sgb
  • 61
  • 1
  • 3
  • This answer of the duplicate gives the details you want: http://stackoverflow.com/a/12643977/34088 – Aaron Digulla Oct 02 '14 at 12:52
  • 2
    It isn't really a duplicate. In fact, it isn't a duplicate at all. – biziclop Oct 02 '14 at 12:57
  • @AaronDigulla perhaps you were thinking of another answer? – Thorbjørn Ravn Andersen Oct 02 '14 at 13:04
  • @biziclop: Both questions are about memory allocation of the `-Xss` option. How are they different? – Aaron Digulla Oct 02 '14 at 13:12
  • That one is about what the `-Xss` option is for in general. This one is about how allocation works specifically, i.e. how much physical memory vs. virtual memory is committed to the stack of a new thread. – biziclop Oct 02 '14 at 13:26
  • To clarify in case "RSS/VSZ" and the "linux" tag isn't enough: I'm talking specifically about Unix/Linux, and whether the JVM actually causes the kernel to have to commit the memory; in other words, does it write to all the stack's pages (via e.g. a memset() on the whole range). This is quite relevant, because as I indicate it's the difference between 10,000 threads with -Xss of 1MB needs 10GB physical vs. whatever they actually use. Please no "it depends on the platform" and other lawyering, I'm being concrete here. – sgb Oct 03 '14 at 17:36

1 Answers1

-2

As this answer already says: The Java VM will allocate the memory for the whole stack every time you create a new thread.

That means it depends on your OS and its virtual memory subsystem what happens next.

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820