GeeCON Prague 2014*
The moose likes Threads and Synchronization and the fly likes Number of threads, performance, heapsize Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Number of threads, performance, heapsize" Watch "Number of threads, performance, heapsize" New topic
Author

Number of threads, performance, heapsize

Jiri Janecek
Greenhorn

Joined: Sep 19, 2013
Posts: 1
Hi,

I am facing interesting behavior when working with threads in Java. I would like to ask for explanation of this behavior.

Let's say we have graph (in terms of graphs theory) with 220 vertexes. We are iterating through this graph. When visiting vertex, we start
thread to generate an image.

We can set number of threads used to generate images in general.

If I use only two threads for generating images, memory management is much worse than eg. 20 threads (Out of memory exceptions etc.
3GB not enough) 20 threads run is OK, using approx 2GB. That's smt. I don't understand. This doesn't make sense. Intuitively using 20 threads memory
management should be worse because every thread needs it's own memory to generate an image (in the same time).

Only one theory I have is that this is related to how often is GC called when using 2 or 20 threads.

Thanks for suggestions.

Jiri




Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

I think we don't have enough information. It depends on what data is generated where. Could be a producer thread creating data that gets stored, waiting to be processed. But with 2 threads it is being generated faster than processed to it backs up.


Steve
 
GeeCON Prague 2014
 
subject: Number of threads, performance, heapsize