Let thread wait till memory is available

S

senges

hi all,
a basic question:

i have a memory consuming encoding process which runs in its own
thread.

To preseve OutOfMemory errors when a lot of those treads are running,
i want this thread to check the current memory heap, and maybe wait as
long as there's some available.

Is that possible ?
I think this must be a very common problem in thread programming?

Greets,
chris
 
I

Ingo R. Homann

Hi,
hi all,
a basic question:

i have a memory consuming encoding process which runs in its own
thread.

To preseve OutOfMemory errors when a lot of those treads are running,
i want this thread to check the current memory heap, and maybe wait as
long as there's some available.

Is that possible ?
I think this must be a very common problem in thread programming?

You may take a look at java.lang.Runtime.free/max/totalMemory.

Hth,
Ingo
 
R

Robert Klemme

Hi,


You may take a look at java.lang.Runtime.free/max/totalMemory.

Other options are to start and catch any OOM errors. Or use a thread
pool with limited size to limit concurrent processing.

Kind regards

robert
 
I

Ingo R. Homann

Hi,

Robert said:
Other options are to start and catch any OOM errors.

But that might crash other threads (with low mem usage) with an OOME as
well!
> Or use a thread
pool with limited size to limit concurrent processing.

OK.

Ciao,
Ingo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top