Hello, I have some action in Java (8) which is performed in parallel threads over a uniform list of data. On one hand I need a single thread for each piece of data, on the other hand, I don't know how many of them I will have, and how much memory each of them needs, so I get OutOfMemoryException for large samples. 

So the question is the following: how to easily estimate in the runtime should the thread be created immediately, or should it wait for some other thread to finish and for garbage to collected.

There are some obvious solutions to this problem like forbidding the action to use more than, say, 3/4  of total JVM memory, but perhaps somebody have a better solution.

More Alexander Nozik's questions See All
Similar questions and discussions