Unsubscribe from events - Any benefits ?

Created at 28 Feb 2023, 11:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NC

ncel01

Joined 19.03.2020

Unsubscribe from events - Any benefits ?
28 Feb 2023, 11:28


Hello,

I wonder if unsubscribing from events can have an impact in performance (e.g.: reduce RAM usage).

It is not that easy to manage cAlgo methods when you don't really know how these manage memory resources.

Is there any documentation about this?

Thank you.


@ncel01
Replies

firemyst
01 Jun 2023, 06:00

This is more a C# thing than a cTrader thing.

If you unsubscribe from events, it could free up some resources and make available for garbage collection.

Do a little Google research.

https://stackoverflow.com/questions/506092/is-it-necessary-to-explicitly-remove-event-handlers-in-c-sharp#:~:text=Yes%2C%20you%20will%20want%20to,reference%20remains%2C%20it%20is%20live.

 


@firemyst

ncel01
01 Jun 2023, 19:20

Hi firemyst,

At that time I made some research on this, however, what I wanted to know is how this is managed internally by cAlgo.

Nonetheless, at this stage I am more than aware that performance issues have nothing to do with my code.


@ncel01