Skip to content

Instantly share code, notes, and snippets.

@rsrini7
Created April 30, 2016 05:41
Show Gist options
  • Select an option

  • Save rsrini7/a31c250db89cc72288dd78429072bed2 to your computer and use it in GitHub Desktop.

Select an option

Save rsrini7/a31c250db89cc72288dd78429072bed2 to your computer and use it in GitHub Desktop.
My application has a lot of threads and is running out of memory, why? You may be running into a problem with the default stack size for threads. In Java SE 6, the default on Sparc is 512k in the 32-bit VM, and 1024k in the 64-bit VM. On x86 Solaris/Linux it is 320k in the 32-bit VM and 1024k in the 64-bit VM. On Windows, the default thread stack size is read from the binary (java.exe). As of Java SE 6, this value is 320k in the 32-bit VM and 1024k in the 64-bit VM. You can reduce your stack size by running with the -Xss option. For example: java -server -Xss64k Note that on some versions of Windows, the OS may round up thread stack sizes using very coarse granularity. If the requested size is less than the default size by 1K or more, the stack size is rounded up to the default; otherwise, the stack size is rounded up to a multiple of 1 MB. 64k is the least amount of stack space allowed per thread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment