question

Upvotes
Accepted
1 0 0 1

EMA OmmConsumer memory leak in Java API?

In our application we often need to do ad-hoc snapshot data queries. For that we create OmmConsumerConfig, read dictionary file (from local filesystem), pass config to w newly created OmmConsumer, then use consumer to subscribe for data, collect it, then unregister the handler. Finally we uninitialize() the consumer and then all references to it (and to config) are cleared (they are both local variables in the method).

This method is called several times a day and we noticed problem with memory usage of our application. We observed it with VisualVM and it was clear to us, that our method was causing it.

Weird thing was that string values from the Dictionary file were appearing there in VisualVM as many times as the method was called, which lead us to thinking some references were not cleared and GC not happend for the whole Consumer/Config structure.

We implemented a pool of consumers now and since then the memory usage is no longer increasing per method call (which indicates problem within the OmmConsumer/OmmConsumerConfig and not in our code which uses it).

Has anyone tried creating many consumers and deleting them during a single app lifecycle? (with loading of dictionary file from local filesystem - this may play a role, or not - I don't know).

Is there anything we need to do apart from calling uninitialize() on the consumer and clearing references to consumer and the config?

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apijavaconsumermemory
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
9.5k 10 5 7

I have provided the following answers to the client in the case's email:

Q1: Has anyone tried creating many consumers and deleting them during a single app lifecycle? (with loading of dictionary file from local filesystem - this may play a role, or not - I don't know).

A1: Does your application allow multiple users to access/request data simultaneously?

If yes, many consumers(OmmConsumer instances) are required because one consumer allow only one user to login and request data. Hence, the application should create many consumers to serve all users and can deleting them during a single app life cycle.
If no, only a single consumer(OmmConsumer instance) is required:

  • If there is only one user in the whole application lifecycle. You just use the one consumer instance and call OmmConsumer.registerClient(..) method to query snapshot data whenever the client requests data. The application should calls consumer = EmaFactory.createOmmConsumer (..) once before requesting data; this EMA method performs establish network communication, Log in, Load dictionary files automatically. Before the application shuts down, call OmmConsumer.uninitialize() method to log out and disconnect from the connected server.
  • If there are multiple users in the whole application lifecycle but only one user can access the application at the time; the other users must wait till the current user leave from the application, only single OmmConsumer instance is required. After the current user gets data of all items he requests, call OmmConsumer.uninitialize() method to log out the user and disconnect from the connected server. The, you can clear references to the consumer. When the new user requests data, the application should calls consumer = EmaFactory.createOmmConsumer (..) to connect, login the new user to the server then call OmmConsumer.registerClient(..) to request data. Once the new user gets data of all items he requests, call OmmConsumer.uninitialize() method to log out the new user and disconnect from the connected server. The, you can clear references to the consumer.

Q2: Is there anything we need to do apart from calling uninitialize() on the consumer and clearing references to consumer and the config?
A2: No. Calling uninitialize() on an OmmConsumer object causes the application to log out and disconnect from the connected server. This is to destroy the OmmConsumer Object. Your application clears references to consumer and the config as well. Hence, these should be enough.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
9.5k 10 5 7

Hello @pawel.salawa

Normally Developer Community Forum is for how-to/general questions but your question seems to be complex and requires a deep investigation e.g. review your source code, configuration, try to reproduce the problem from Elektron API specialist team(my team).

If you would like to be a premium user, please send an email to rdc.administrator@thomsonreuters.com After you are a premium user, please submit your problem to my team directly via Premium Support . For any difficulties submitting the query to us, please contact rdc.administrator@thomsonreuters.com

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea