multithreading - Java thread stack memory occupation -


As I was studying thread and memory (thread stack), I decided to do a simple load test Taken how the number of threads affect the RAM on my computer.

So, I used tomatkets for testing and at least 200 and maximum web container thread pools were set in settings.xml. After that I did the same while setting the pool in 2000. I was surprised 'because there was no difference in the memory business (the Windows Task Manager was checking) and it was almost the same. So I thought those threads should be in the state of running, using a load test tool to "bombard" the server and I managed to load heavily, most of the threads were now in the state but no one There was no change between the memory consumption between 200 and 2000 threads.

So I am wondering what is the stack memory of this thread and these results mean that the thread at the thread stap is not allocated while creating the thread? How will I be able to simulate the thread stack memory growth in size, where the difference in the consumption of RAM on the village is seen as "naked eye"?

Thanks in advance!

Thread stacks are allocated in native memory (not in Java Hap), default stack sizes of 256 And between 1m (depending on the OS and whether the JVM is 32 or 64-bit), you can control it with the XSR JVM option. If you run away from stack memory, you get "java.lang.OutOfMemoryError: Unable to create new original thread" error.

If you want to track stack memory usage on windows at the OS level, use instead of Task Manager, as it shows you stack memory.

If you are recently with JDK -XX: Native Memorial Tracking and JCMD, you can track stack memory usage in Java.

I do not know what is wrong in your test, I want to make sure to have a thread in your code. I recommend sleeping that all the threads are running.


Comments