-
Notifications
You must be signed in to change notification settings - Fork 128
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
EMA C#: OmmDate object modified during the for-each iteration #291
Comments
@y-intercept2018 Thank you for raising this issue and the information provided. For performance reasons RTSDK EMA Library reuses objects whenever possible. That's why objects returned from data access methods are transient and short-lived. Values that they contain are not guaranteed to live outside of scope. In the case described above it is application's responsibility to copy data it needs from the object returned by the |
Hi @V-Anyakin from a C++ point of view this explanation makes sense as in C/C++ we have the idea of ownership and enlightened C++ programers are required to understand the implication of referring to a non-owning object. But in terms of C# this is very confusing as C# does not use the ownership concept to manage memory and users rely on reference counting (which is usually transparent to typical programmers). As long as users are still referring to an object, the expectation is that it will never be cleared. I believe this is also one of the major selling points of the "easier" languages such as Java and C#--lets not burden programmers with the complexity of C++ and in return they must tolerate the overheads of automatic GC. Now you are bringing this back to C#, which is not ideal i would say. Also seems the same issue does not occur on Java, why is there such a difference? |
Hello, @y-intercept2018 Decision to reuse class instances whenever possible instead of creating new objects on the heap was made because of performance considerations. This approach is followed across all three flavors, including Java. However, the Java When accessed via iterator returned by the Real-Time-SDK/Java/Ema/Core/src/main/java/com/refinitiv/ema/access/FieldListImpl.java Line 99 in 244e87d
When accessed via iterator returned by the Real-Time-SDK/Java/Ema/Core/src/main/java/com/refinitiv/ema/access/FieldListImpl.java Line 108 in 244e87d
|
Real-Time: For Real-Time SDK C#, looks like the OmmDate object will be modified during the for-each iteration. This strange behavior does not happen to all RICs, for example, it does not happen on RIC
/0005.HK
, it does happen on RIC/HCEIX4
.This function is used to extract one specific field with fieldId == 16 (i.e., TRADE_DATE) into my date object. The output I get is this:
date (in-place): 29 OCT 2024
date (after-foreach): (blank data)
This issue was also discussed on a LSEG forum here and it seems to be a bug.
My environment:
DotNet 6.0 with LSEG.Ema.Core 3.3.0
The text was updated successfully, but these errors were encountered: