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

[Bug] Memory leaks in the TEventBus.Post() method. #10

Closed
edwinyzh opened this issue Sep 30, 2017 · 3 comments
Closed

[Bug] Memory leaks in the TEventBus.Post() method. #10

edwinyzh opened this issue Sep 30, 2017 · 3 comments

Comments

@edwinyzh
Copy link
Contributor

edwinyzh commented Sep 30, 2017

The cloned LEvent local variable is not freed.

My partial (read only handling the freeing when in main-thread mode):

      for LSubscription in LSubscriptions do
      begin
        LEvent := CloneEvent(AEvent);
        PostToSubscription(LSubscription, LEvent, LIsMainThread);

        // edwin: fix memory leaks
        if AEventOwner and (LSubscription.SubscriberMethod.ThreadMode in [Posting, Main]) then
          LEvent.Free;
        // edwin end.
      end;

But my code doesn't free the LEvent var when in async mode...

@jkour
Copy link

jkour commented Mar 14, 2018

It looks like this bug has been fixed after the commit in Jan, right?
You just need to free the event manually in the code.

@spinettaro
Copy link
Owner

Yes, you're right @jkour

@wxinix
Copy link
Contributor

wxinix commented Aug 19, 2020

This doesn't seem to be fixed, even with the latest commit as of Aug 18, 2020. When TEventMM = mmManual or mmManualAndFreeMainEvent, LEvent is NEVER properly free-ed, and will result in memory leak!

The test cases do not cover mmManual and mmManualAndFreeMainEvent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants