-
Notifications
You must be signed in to change notification settings - Fork 115
Memory Leak PyMapdl #3041
-
Hello everyone, import os
from ansys.mapdl.core import launch_mapdl
path = os.path.abspath(__file__)
directory = os.path.dirname(path)
temp_dir = os.path.join(directory, 'temp_ansys')
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)
mapdl = launch_mapdl(nproc=4,run_location=temp_dir, override=True)
def calculate_energy():
mapdl.clear()
mapdl.prep7()
mapdl.blc4(0, 0, 1000, 1000)
mapdl.blc4(1000, 0, 1000, 1000)
mapdl.aglue('ALL')
# BC
mapdl.ksel("S", "LOC", "X", 0)
mapdl.ksel("A", "LOC", "X", 1000)
mapdl.ksel("R", "LOC", "Y", 0)
mapdl.dk("ALL", 'UX', 0)
mapdl.dk("ALL", "UY", 0)
mapdl.allsel()
mapdl.clear()
return 1
for i in range(0,1000):
a = calculate_energy() |
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment · 10 replies
-
Hi @lucaRubHsg I did run that scrip on MacOS + docker + MAPDL 2024R2 docker image, and Python 3.12. Can you give us a bit more details about your setup and the memory usage? How much memory takes at the beginning? How much memory does it take at the end? How are you measuring it? Which OS are you using? Which version of MAPDL? With the code you sent, I see no reason for a memory use increase... |
Beta Was this translation helpful? Give feedback.
All reactions
-
For python3.10:
|
Beta Was this translation helpful? Give feedback.
All reactions
-
Here is what i get running this code: Details
|
Beta Was this translation helpful? Give feedback.
All reactions
-
MMhh... that's very strange. Let's see if @clatapie can replicate this. |
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello, I ran the following script using Windows10, MAPDL 2023R2 and process = psutil.Process(os.getpid())
base_memory_usage = process.memory_info().rss
for i in range(0,1001):
memory_usage = process.memory_info().rss
loop_memory_usage = memory_usage - base_memory_usage
if i%5 == 0:
print(f"Iteration {i:4.0f}\t\t| Memory usage: {memory_usage/1024:0.0f}\t| Loop memory: {loop_memory_usage/1024:0.0f}")
a = calculate_energy() Here are the results I obtained: Details
|
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello everyone, Details
|
Beta Was this translation helpful? Give feedback.
All reactions
-
Great! Thank you @clatapie for your work! |
Beta Was this translation helpful? Give feedback.
Hello,
I ran the following script using Windows10, MAPDL 2023R2 and
ansys-mapdl-core 0.68.1
:Here are the results I obtained:
Details