Reputation: 2451
This code:
while (true) {
new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
return null;
}
};
}
make the JVM go out of memory very quickly.
Why?
Upvotes: 0
Views: 190
Reputation: 6533
I have tried to run this code with JRE 1.7.0_60 x86_64 on Windows 7 with default options and here are the results:
threadFactory
s to System.out
results in "saw-like" heap usage pattern:Which means that both allocation and garbage collection takes place.
Back to your question: I think you missed some significant parts of the code, or put -Xmx to extremely low value, or some other reason. The code you posted is ok, though.
Upvotes: 3