Replies: 5 comments 5 replies
-
I fixed it by searching for the specific data type i needed and using load_custom_struct in a similar manner to however, something should probably be done about how load_data_type_definitions can use so much memory... |
Beta Was this translation helpful? Give feedback.
-
Which version of the library are you using? Are you using the current master? We had a change of #1484 |
Beta Was this translation helpful? Give feedback.
-
I am using 1.0.5. For the load_data_type_definitions, I could see my memory fill up while the function was being called, I may be able to provide a minimum reproducible example, debugging my other implementations right now. Will investigate further. |
Beta Was this translation helpful? Give feedback.
-
The following minimally reproducible example: from asyncua import Client
import asyncio
opcua_target_url = "opc.tcp://redacted_ip:4840"
client = Client(url=opcua_target_url)
async def async_main():
async with client:
print('loading data type definitions')
await client.load_data_type_definitions()
print('loaded data type definitions!')
asyncio.run(async_main()) consumes all the memory on my PC(32 GB, windows 10) with a requirements.txt of:
and does not consume all the memory on my PC(32 GB, windows 10) with a requirements.txt of:
|
Beta Was this translation helpful? Give feedback.
-
Similarly, the following example consumes all the memory on asyncua==1.0.5. from asyncua import Client, Node
import asyncio
opcua_target_url = "opc.tcp://redacted_ip:4840"
client = Client(url=opcua_target_url)
async def find_node(root_node: Node, display_name: str) -> Node|None:
'''
Recursively search the OPCUA server for a node with the given display_name.
Parameters:
- root_node (asyncua.Node): node in the OPCUA server to start searching from.
- display_name (str): display_name of the node to find.
Returns: asyncua.Node object of node or None if not found.
'''
if display_name is not None and (await root_node.read_display_name()).Text == display_name:
return root_node
for child_node in await root_node.get_children():
result = await find_node(root_node=child_node, display_name=display_name)
if result is not None:
return result
return None
async def async_main():
async with client:
display_name_to_find = 'redacted_node_name'
print(f'attempting to find node by display name: {display_name_to_find}')
node = await find_node(root_node=client.get_root_node(), display_name=display_name_to_find)
if node:
print(f'found node: {node}')
else:
print(f'did not find node')
asyncio.run(async_main()) |
Beta Was this translation helpful? Give feedback.
-
I am running a data logger and need to access custom types from my OPCUA server.
I have limited RAM available (about 2 GB) and it appears that my application is getting out-of-memory killed on load_data_type_definitions()
How can I limit the memory usage of this function?
Beta Was this translation helpful? Give feedback.
All reactions