Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python scripting memory leak

Status
Not open for further replies.

bajsi

Materials
Mar 22, 2007
10
0
0
SI
I wrote a script to propagate cracks through material and I found a peculiar memory leak.

For instance I delete existing seams like this:

for e in aPart.edges:
mModel.rootAssembly.engineeringFeatures.
deleteSeam(regions=regionToolset.Region(
edges=aPart.edges.findAt((e.pointOn[0], ))))

But this puny codepiece causes .cae file to grow ~50 KB whenever executed.
After 100 extensions .cae grows to a few MB irreversibly - I deleted parts, assembly, cracks (basicaly everything that is deletable througs ABAQUS GUI) saved it under a new name and still ended up with this huge .cae.
I use ABAQUS 6.6-1
 
Replies continue below

Recommended for you

I had the same problem. I have not found any solution yet...better than restarting ABAQUS.

The interesting part is than under v6.4 this problem did not occur. I could run the same model generation script repeatedly without any memory leak.

Also, in v6.5 when generating 2D parts with holes, CAE takes a huge amount of memory for no reason, but this does not happen in 6.6.

I think the problem is objects remain referenced internally by CAE, for some reason, and the occupied memory cannot be collected.

 
Did you try a save-as?

The way the cae database is architected is such that deleting objects does not necessarily free the memory allocated in the database for those objects - it just marks those objects as "deleted" and they are no longer referenced by anything. (This is the same behavior as a lot of databases e.g. Microsoft Office pst files - and the reason why they provide a "compact now" facility)

Anyway, doing a save as only copies the "live" objects, so the resulting .cae file will be much smaller.
 
In Python, if an object is no longer referenced by anything, then the garbage collector will try to free the memory.

Probably, the objects defining the model still remain referenced in CAE internally, even after using "del object_reference", and therefore the memory cannot be freed.


 
In our work with Python-ABAQUS interface I found Python never returning memory to the operating system. For instance, if you write a python program realized an iteration process and you expect to run it for a long time then it's total allocated memory will reach a peak and pretty much stay there, no matter what you do.
This is known issue and there is a patch under development to try and fix this problem in Python 2.5.
One way to possible workaround is to run python as separate child process for one iteration and kill sometimes it to free memory to the operating system.
 
Status
Not open for further replies.
Back
Top