PrabhaT
PrabhaT

Reputation: 888

Executor using Hazelcast

I have been debugging a memory issue in Hazelcast instances. I am using Hazelcast to implement my executor service. I dont need the results back from the executor and I just keep going on submitting the jobs via

executorService.executeOnMember(Runnable, member);

It runs good for some time and after that the memory is full.

I tool a thread dump and I could see this

        at com.hazelcast.executor.RunnableAdapter.call(RunnableAdapter.java:49)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at com.hazelcast.executor.DistributedExecutorService$CallableProcessor.run(DistributedExecutorService.java:187)
    at com.hazelcast.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:186)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
    at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
    at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)

The first thing that struck to me was the submitted jobs destroyed after completion or I need to manually code for that. This came as we are using the FutureTask which is the same stuff used while returning an object.

Upvotes: 0

Views: 754

Answers (1)

pveentjer
pveentjer

Reputation: 11307

You don't need to destroy your jobs after completion. Hazelcast removes the job from the work queue when it is executed and gc takes care of the rest.

About memory is full: you are running into an OOME? By default the IExecutorService will keep on accepting tasks and doesn't look at how much memory is available. And this can lead to an OOME if you produce tasks faster than they are consumed.

But you can set the queueCapacity on the ExecutorConfig. As soon as the maximum capacity is reached, on the invoking side you will get a RejectedExecutionException. You can use this to apply some backpressure

Upvotes: 1

Related Questions