Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy all actors on runtime termination #2058

Merged
merged 1 commit into from
Jul 19, 2017

Conversation

Praetonus
Copy link
Member

The memory for actors that were still alive on runtime termination wasn't being freed, leading to memory leaks.

@SeanTAllen
Copy link
Member

Nice.

@SeanTAllen
Copy link
Member

I think this change is interesting enough that it deserves a CHANGELOG - FIXED. Thoughts?

@Praetonus
Copy link
Member Author

Agreed.

@Praetonus Praetonus added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Jul 19, 2017
@jemc
Copy link
Member

jemc commented Jul 19, 2017

Just to be clear, I think this only makes a difference for when the pony runtime is being run as embedded in a larger program, and that larger program isn't over yet - right?

(for example, when embedding the pony runtime in your own C program, or when running JIT tests in the compiler test suite)

In cases where the pony runtime termination is immediately followed by the termination of the OS process (as is the case for a normal Pony binary), I think this only matters from a pedantry perspective, because the OS will free memory allocated by the OS process when it gets terminated - is that correct?

I'm not trying to say we shouldn't do this change - obviously we still should - I just want to make sure we're being clear and not overstating the scope of the problem that was fixed.

@@ -139,6 +139,9 @@ DEFINE_HASHMAP(ponyint_perceivedmap, perceivedmap_t, perceived_t,
perceived_hash, perceived_cmp, ponyint_pool_alloc_size,
ponyint_pool_free_size, perceived_free);

DECLARE_STACK(ponyint_actorstack, actorstack_t, pony_actor_t);
DEFINE_STACK(ponyint_actorstack, actorstack_t, pony_actor_t);
Copy link
Member

@jemc jemc Jul 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we choose a name for this stack instance that makes it more clear that it is only used at termination time?

My first thought when I saw this stack declaration is that we'd be pushing to it at creation time for every actor, which is a much scarier concept in terms of program overhead and coordination than what's actually going on (pushing to it and popping from it at runtime termination).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see what could be a better name. Maybe we could move the stack declaration closer to where it is used instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think terminate could be included in the name somehow.

If you don't want to change the name, can you add a comment above the declaration that explains how/when it is used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see how it looks like in the code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with pendingdestroystack, since that's what it's storing.

@Praetonus
Copy link
Member Author

@jemc Yes, it doesn't make any difference if the program exits immediately after the runtime terminates and the OS claims the memory back.

The memory for actors that were still alive on runtime termination
wasn't being freed, leading to memory leaks.
@Praetonus Praetonus force-pushed the runtime-terminate-actor-free branch from c8944d0 to b0d1585 Compare July 19, 2017 17:40
@SeanTAllen SeanTAllen merged commit f57cc2f into ponylang:master Jul 19, 2017
ponylang-main added a commit that referenced this pull request Jul 19, 2017
@Praetonus Praetonus deleted the runtime-terminate-actor-free branch July 19, 2017 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants