Re: Finalizers are dangerous
On the contrary I welcome OpenMAMA forks If you want to fork and maintain all fixes etc from the upstream that's entirely your decision and part of the beauty of Open Source software. More power to you.
I simply don't agree that always leaking is the right solution when it's avoidable. It's as simple as that.
After another look I think the solution should live in the C++ destructor method where it can:
1. Cache the payload type in the C++ layer as soon as it is known.
2. On destructor, find out if the bridge referred to in #1 is still active using mamaInternal_findPayload from mamaMsg_destroy. Therefore the destroy calls can intercept bridge specific calls before they are made which would otherwise cause a crash.
The mama internal lock may also need to be opened up to avoid race conditions.
You can do something similar in Java finalizer methods via a JNI method.
Alternatively you could have a mama property which will simply prevent the payload bridges from being deallocated and will instead only destroy the middleware bridges. This way it will do what you want (i.e. always leak memory), but not be turned on for everyone unless they want it.
On Thu, Dec 28, 2017 at 4:25 PM, Bill Torpey <wallstprog@...> wrote:
No, we shut down the bridges to prevent events from firing. In some cases (and certainly *not* all) that also releases resources acquired when the bridges were opened, which is a Good Thing.
It’s not up to you. As I said before, it’s my application, and I get to decide what leaks are worth worrying about. One-time leaks that don’t grow over time don’t concern me, and the cost of eliminating them is not worth it in almost all cases. (Again, that’s my choice — “Perfect is the enemy of good enough”).
As you are well aware, that is not a solution — it doesn’t stop events from firing, which is the real reason for shutting down the transport.
What configuration option is that? How would it work?
I would be happy to submit a PR, but it doesn’t sound like it would be accepted. If we can agree on an approach I’ll see what I can come up with.
In the meantime I gave up and forked the code. As project maintainer I don’t imagine that’s what you want, but you’re not giving me a choice.