Skip to content

Commit

Permalink
Trigger GC for actors when they tell the cycle detector they're blocked
Browse files Browse the repository at this point in the history
Prior to this commit, if an actor blocked, it did not run GC to free
any memory it no longer needed. This would result in blocked actors
holding on to (potentially lots of) memory unnecessarily.

This commit causes GC to be triggered when the cycle detector asks
an actor if it is blocked and the actor responds telling the cycle
detector that it is blocked. This should result in memory being
held by blocked actors to be freed more quickly even if the cycle
detector doesn't end up detecting a cycle and reaping the actors.
  • Loading branch information
dipinhora committed Mar 17, 2019
1 parent 774aeaa commit 38376d2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libponyrt/actor/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ static bool handle_message(pony_ctx_t* ctx, pony_actor_t* actor,
// We're blocked, send block message.
set_flag(actor, FLAG_BLOCKED_SENT);
ponyint_cycle_block(ctx, actor, &actor->gc);

// trigger a GC if we're blocked and have done work since the last GC
if((actor->msgs_since_gc > 0) && (actor->heap.used > 0))
pony_triggergc(ctx);
}

return false;
Expand Down

0 comments on commit 38376d2

Please sign in to comment.