Not Enough Storage Available While Using Jstack (Win)
Luke Hebert
- One minute read - 201 wordsIf Support asks you to grab a thread dump on a Windows box and jstack throws a “not enough storage available” error, the culprit is almost always a user-context mismatch. The JVM is running under the Local System Account, and jstack can only attach to JVMs in the same user context. Here are two ways around it.
Problem
You may be instructed by Support to generate a thread dump using the jstack tool on a Windows platform. This error is thrown when trying to execute the command.
Cause
Jstack only allows you to connect to JVMs running in the same user context. Many people use a service wrapper to start their products, which puts the JVM in the Local System Account user context. Since this special account has no login shell, you won’t be able to force a thread dump normally.
Workarounds
Workaround 1: Use Psexec
Use Psexec to execute the jstack command as the relevant user:
psexec -s "%JAVA_HOME%\bin\jstack.exe" PID >stack.txtWorkaround 2: Use JMX Remote Monitoring
Follow the Live Monitoring Using the JMX Interface directions and set up a JMX monitoring tool like VisualVM acting remotely on the JVM. Many of these tools can generate thread dumps externally.