Memory Leak using Python API

71 views
Skip to first unread message

ajfi...@gmail.com

unread,
Dec 14, 2022, 6:41:10 PM12/14/22
to OpenVSP
Hi all,

I've been struggling to keep my memory Python usage from growing as I use OpenVSP to batch run analyzing multiple geometries.

I made a relatively simple test to demonstrate this, python code is attached.

The attached image shows a plot with the results I'm seeing.OpenVSPPythonMemoryLeak.png
As you can see, even though I'm running vsp.ClearVSPModel() and vsp.DeleteAllResults() at the top of the loop, the ram used continues to climb, even if all I do is ReadVSPFile.

Any suggestions on something I could do to prevent this memory growth, other than shutting down Python and restarting it fresh for each design point?

-AJ
testVSPMemory.py

Rob McDonald

unread,
Dec 15, 2022, 2:44:35 PM12/15/22
to OpenVSP
That is really interesting.  Pretty sure this is a bug (nothing you can do to fix it).  There are a few places for me to look -- if it isn't there, then this will get 'interesting'...

My first step will be to convert this example to an equivalent *.vspscript test.  This is really just so I can run the test in my normal debugger and with Valgrind and other diagnostic tools.  I don't know how to connect those to a Python instance and while it is probably possible, it is surely easier for me to duplicate your test case in AngelScript.

Rob

jordi nosaurio

unread,
Mar 6, 2023, 12:49:21 PM3/6/23
to OpenVSP
I think I faced something similar and solved it closing the API each loop with:
vsp.VSPExit(0)
Not sure if it is your case

AJ Field

unread,
Mar 6, 2023, 4:01:05 PM3/6/23
to ope...@googlegroups.com
Jordi,

That's an interesting idea, thanks for the suggestion! But when I add a call to 'vsp.VSPExit(0)' into my loop, it exits the entire python process, not just the OpenVSP module. Did you find some way around this?

-AJ

--
You received this message because you are subscribed to a topic in the Google Groups "OpenVSP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openvsp/sQZU7RzVK88/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openvsp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openvsp/1217f9b4-4e91-4bdb-b007-97e43178b3f8n%40googlegroups.com.

jordi nosaurio

unread,
Mar 7, 2023, 2:37:38 PM3/7/23
to OpenVSP
Hi AJ,
I cannot find the specific example I was dealing with, but I remember It was related to the python IDE (I was using Spyder). If I run the python script alone (no IDE), it did not close the python process, and the memory did not grow. Sorry If I am messing the things, was just it sounded familiar.
cheers
Reply all
Reply to author
Forward
0 new messages