Reputation: 365
Using ScheduledExecutorService from hazelcast 3.8 i've got an out of memory exception. The thing is i'm making a service which should remind to user about some event during a day. Execution of task should be fault-tolerant. A user sets new reminder which is a task for ScheduledExecutorService, thus amount of tasks can be several thousands per day. Each task adds to scheduler as one-shot action using schedule(Runnable command, long delay, TimeUnit unit). A delay can't be longer then 24 hours. When i've started to make tests and add tasks in loop, i've got an oom exception. I thought a task after execution will be removed from memory, but probably i was wrong.
Can you answer for several question:
Upvotes: 2
Views: 2905
Reputation: 53
We are using schedule executor service to run a Runnable Task after certain delay but looks like task was not removed from memory after execution. We are validating by iterating through executorService.getAllScheduledFutures() and check the size.
Upvotes: 0
Reputation: 261
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
IScheduledExecutorService scheduler = instance.getScheduledExecutorService("scheduler");
IScheduledFuture future = scheduler.schedule(named("MyTask",
new EchoTask("foobar")), 1, TimeUnit.SECONDS);
Object result = future.get();
System.out.println(future.getHandler().getTaskName() + " result: " + result);
future.dispose();
System.out.println("Press any key to exit");
System.in.read();
Hazelcast.shutdownAll();
Upvotes: 2