You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Investigations: We are registering the __del__ method of the TwinModel with the atexit module in order to avoid the settings module tries to delete pytwin temp folder of the process before the log file of the TwinRuntime object owned by the TwinModel has been closed. This has a side effect which is that a TwinModel instance is referenced by the atexit module and thus preventing the garbage collector to collect and free the TwinModel at the end of the loop.
🔍 Before submitting the issue
🐞 Description of the bug
When instantiating a TwinModel in a loop, the allocated memory keep increasing.
📝 Steps to reproduce
import os
import tracemalloc
from pytwin import TwinModel
tracemalloc.start()
snapshot = tracemalloc.take_snapshot()
twin_file = os.path.join("path_to_a_twin_model_with_tbrom.twin")
for i in range(1, 100):
twin_model = TwinModel(model_filepath=twin_file)
snapshot2 = tracemalloc.take_snapshot()
top_stats = snapshot2.compare_to(snapshot, 'lineno')
stat_tbrom_read_basis = top_stats[0]
print(stat_tbrom_read_basis)
💻 Which operating system are you using?
Windows
📀 Which ANSYS version are you using?
NA
🐍 Which Python version are you using?
3.9
📦 Installed packages
The text was updated successfully, but these errors were encountered: