Possible Memory Leakage in Fusio 360

Possible Memory Leakage in Fusio 360

Peter__B
Advocate Advocate
1,139 Views
8 Replies
Message 1 of 9

Possible Memory Leakage in Fusio 360

Peter__B
Advocate
Advocate

Hi

 

I have a python script that generates .png 2D picturefiles from a model in order to use the files to animate the geometrical behaviour when changing a parameter value.

It is a time-consuming process and it will be about 3 thousend pictures.

 

When the fusion 360 has been loaded it uses about 350 MB of RAM.

 

NoFile.png

 

When a flie (document) is loaded it increases to about 640 MB RAM.

 

 

JustFile.png

 

When the python code has run for some hours it has increased even more and up to 7 - 10 GB.

 

UseFile.png

 

When it reach this state of necessary RAM it crashes. The only way to shut down Fusion 360 is to kill the process and start Fusion again.

 

Even if I just shut it down and open the file again the program still reserves the 7 - 10 GB. If I use "Clear User Cach Data" it goes down to 350 MB (without loaded file) or 640 MB (with loaded file).

Fusion seems to handle the RAM in a strange way or ? All my drivers are up to date. In order to reach my goal I have to shut down and restart after about 2-3 hours aprox.

 

Best Regards

Peter

0 Likes
Accepted solutions (1)
1,140 Views
8 Replies
Replies (8)
Message 2 of 9

marshaltu
Autodesk
Autodesk

Hello,

 

Thank you for reporting the issue to us. It is interesting. It would be great if you can share the original design/script/steps to reproduce the issue. 

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 3 of 9

Peter__B
Advocate
Advocate

Hi Marshal

 

To share the entire model is a bit difficult but I hope screenshots and explanations will help.

 

What I have noticed this morning is that Fusion 360 never release the memory after the parameter change has been performed by the python code. It can be seen in the activity manager that the maximum amount of RAM is still allocated. When when the code is run again, fusion starts allocating the maximum amount of RAM from the previous run. It now starts with that previous amount and during the execution it allocates ever more RAM on top of the previous amount.

If I let it run to the end (this is only possible if I limit the parameter range), even larger amount of RAM has been allocated. Every time I restart the code fusion starts with the previous amout every time until all off the computers RAM is allocated and fusion 360 stops working.

If I after each run "Clear User Cache Data" Fusion releases the allocated RAM and come back to normal values to start the execution with.

However, when the program of cause also allocates more and more RAM during execution of the python code I am not able to "Clear User Cache Data", in that case I first have to interrupt the execution before I can restart it.

 

The structure is a folded cylinder which I can fold up and down with the attached code. In my case I change the innerdiameter to control the folding. The structure also have additional folded tubes that can be folded up and down by changing an angle. The model is a bit special but it works perfectly during the parameter change procedure but the problem is the memory issue. My computer has 16 GB of RAM and that should be enougth. The issue seems to be that the memory will not be released.

 

 

This is the cross section.

Ex1.png

 

I use Revolve and Extrude to arrive at the geometry below.

 

Ex3.png

 

The Python code below is used. I am not a professional programmer so the code is probably not the most efficient but it works fine for this purpose.

 

#Author-Peter__B
#
#Description-The code changes parameters, take a snapshot of each state and
#            saves the pictures-files in .png format. A textfile will be
#            generated for each parameter. The textfile documents all
#            parameterchanges and is useful when the restarting the process in
#            the case the program of some reason has been interrupted. 
#
#
# GENERAL INPUT DATA:
#
# ResultFolder     - This folder has to be created on the computers harddrive.
#                    (To be set by the user).
# ImageWidth       - The pictures width - resolution.
#                    (To be set by the user). 
# ImageHeight      - The pictures height - resolution.
#                    (To be set by the user).
#
# PARAMETER SPECIFIC INPUT DATA for ParamA:
#
# parametersParamA - Objects variabel storing and communicating with
#                    Fusion 360 model. Only the attribute inside the
#                    paranthesis shall be set by the user.
# StartParamA      - Startvalue for the parametersParamA.value.
#                    (To be set by the user).
# IncrParamA       - The incremental change in parametersParamA.value.
#                    (To be set by the user).
# EndParamA        - The endvalue of parametersParamA.value.
#                    (To be set by the user).
# PictNameParamA   -  Name that identifies the pictures. The code automatically
#                    adds a counting index for numbering of the pictures).
#                    (To be set by the user).
# InfoNameParamA   - Name that identifies the textfile containing information
#                    of the generated pictures.
#                    (To be set by the user).
# CntStartParamA   - Parameters that sets start of the pictures counting index.
#                    (To be set by the user).
# ActivateParamA   - Tells the code in the parametersParamA shall be changed by
#                    the "for loop".
#                    (To be set by the user).
#
# ETC. for PARAMETER SPECIFIC INPUT DATA for ParamB and ParamC:
#
#
# Very small modification of the code have to be done to handle additional
# parameters, see below:
#
# 1) Add another "box" for e.g. ParamD, "# Specific Data for the ParamD".
#
# 2) Add another object under "Creation of objects for inputs parameters of
#    interest" for e.g .ParamD.
#
# 3) Add another object for e.g. ParamD to the lists under
#    "Creates resultfolders for the parameters A, B, C",
#    "Ensures that the parameters are in their initial positions" and
#    "Call of subroutines for parameterchanges".      


import adsk.core, adsk.fusion, adsk.cam, os

app = adsk.core.Application.get()
ui  = app.userInterface  
des = app.activeProduct

# General Input Data.        
ResultFolder = 'D:/EX/'        
ImageWidth =  2560
ImageHeight = 1440        
       
# Specific Data for the ParamA.
parametersParamA = des.userParameters.itemByName('DiameterFolding')       
StartParamA = 80.0        
IncrParamA = 0.05        
EndParamA = 80.2
PictNameParamA = 'ParamA'
InfoNameParamA = 'InfoParamA'        
CntStartParamA = 1        
ActivateParamA = 'True'

# Specific Data for the ParamB.               
parametersParamB = des.userParameters.itemByName('ElevationAngleFront')
StartAngleParamB = 0.001        
IncrAngleParamB = 0.001       
EndAngleParamB = 0.005
PictNameParamB = 'ParamB'
InfoNameParamB = 'InfoParamB'        
CntStartParamB = 1
ActivateParamB = 'False'

# Specific Data for the ParamC.                       
parametersAntRear = des.userParameters.itemByName('ElevationAngleRear')
StartAngleAntRear = 0.001        
IncrAngleAntRear = 0.001        
EndAngleAntRear = 0.005
PictNameAntRear = 'ParamC'
InfoNameAntRear = 'InfoParamC'    
CntStartParamC = 1
ActivateParamC = 'False'

# Function for creation of input objects.
class inp_val:
    def __init__(self,a,b,c,d,e,f,g,h,i,j,k):
        self.param = a
        self.startPar = b
        self.incPar = c
        self.endPar = d
        self.incStartPar = e        
        self.pictName = f
        self.infoName = g        
        self.resDirGlobal = h
        self.imgWidth = i
        self.imgHeight = j
        self.active = k

# Subroutine for saving pictures in png-format.
def chg_par(prop_obj):
    InfoFile = prop_obj.resDirGlobal + prop_obj.pictName + '/'  + prop_obj.infoName + '.txt'          
    while prop_obj.startPar <= prop_obj.endPar:
        prop_obj.param.value = prop_obj.startPar
#        adsk.doEvents()                        
        fileName = prop_obj.resDirGlobal + prop_obj.pictName + '/' + prop_obj.pictName + str(prop_obj.incStartPar).zfill(4)
        app.activeViewport.saveAsImageFile(fileName, prop_obj.imgWidth, prop_obj.imgHeight)  
        InfoText = open(InfoFile,'a')
        InfoText.write("%.20s,%.i\n" %("cnt:", prop_obj.incStartPar))
        InfoText.write("%.25s,%.4f\n" %(prop_obj.param.name, prop_obj.startPar))
        InfoText.write('\n')
        InfoText.close()            
        prop_obj.startPar += prop_obj.incPar
        prop_obj.incStartPar += 1
                      
    InfoText = open(InfoFile,'a')
    InfoText.write('\n')
    InfoText.write('Ready')
    InfoText.close()

# Creation of objects for inputs parameters of interest.
ParamA = inp_val(parametersParamA, StartParamA, IncrParamA, EndParamA,\
                   CntStartParamA, PictNameParamA, InfoNameParamA, ResultFolder,\
                   ImageWidth, ImageHeight, ActivateParamA)

ParamB = inp_val(parametersParamB, StartAngleParamB, IncrAngleParamB,\
                       EndAngleParamB, CntStartParamB, PictNameParamB,\
                       InfoNameParamB, ResultFolder, ImageWidth, ImageHeight,\
                       ActivateParamB)

ParamC = inp_val(parametersAntRear, StartAngleAntRear, IncrAngleAntRear,\
                      EndAngleAntRear, CntStartParamC, PictNameAntRear,\
                      InfoNameAntRear, ResultFolder, ImageWidth, ImageHeight,\
                      ActivateParamC)

# Sets the current directory to "ResultsFolder".
os.chdir(ResultFolder)

# Creates resultfolders for the parameters A, B, C.
for resFold in [ParamA, ParamB, ParamC]:
    resPath = resFold.resDirGlobal + resFold.pictName + '/'
    if not os.path.exists(resPath):
        os.mkdir(resPath)                      
                      
# Ensures that the parameters are in their initial positions.           
for initState in [ParamA, ParamB, ParamC]:
    if initState.active == 'True':   
        initState.param.value = initState.startPar
        adsk.doEvents()
          
# Call of subroutines for parameterchanges.
for comp in [ParamA, ParamB, ParamC]:
    if comp.active == 'True':    
        chg_par(comp)

Regards

Peter

 

0 Likes
Message 4 of 9

Peter__B
Advocate
Advocate

I forgot,

 

Normal values of startParamA = 80 cm, EndParam =100 cm

startAngleParamB = 0.001 rad and startAngleParamB = 1.57 rad

 

0 Likes
Message 5 of 9

Peter__B
Advocate
Advocate

Hi again

 

If anybody would like to use the code you should use this version instead ! The previous contained a bug.

 

/Peter

#Author-Peter__B
#
#Description-The code changes parameters, take a snapshot of each state and
#            saves the pictures-files in .png format. A textfile will be
#            generated for each parameter. The textfile documents all
#            parameterchanges and is useful when the restarting the process in
#            the case the program of some reason has been interrupted. 
#
#
# GENERAL INPUT DATA:
#
# ResultFolder     - This folder has to be created on the computers harddrive.
#                    (To be set by the user).
# ImageWidth       - The pictures width - resolution.
#                    (To be set by the user). 
# ImageHeight      - The pictures height - resolution.
#                    (To be set by the user).
#
# PARAMETER SPECIFIC INPUT DATA for ParamA:
#
# parametersParamA - Objects variabel storing and communicating with
#                    Fusion 360 model. Only the attribute inside the
#                    paranthesis shall be set by the user.
# StartParamA      - Startvalue for the parametersParamA.value.
#                    (To be set by the user).
# IncrParamA       - The incremental change in parametersParamA.value.
#                    (To be set by the user).
# EndParamA        - The endvalue of parametersParamA.value.
#                    (To be set by the user).
# PictNameParamA   -  Name that identifies the pictures. The code automatically
#                    adds a counting index for numbering of the pictures).
#                    (To be set by the user).
# InfoNameParamA   - Name that identifies the textfile containing information
#                    of the generated pictures.
#                    (To be set by the user).
# CntStartParamA   - Parameters that sets start of the pictures counting index.
#                    (To be set by the user).
# ActivateParamA   - Tells the code in the parametersParamA shall be changed by
#                    the "for loop".
#                    (To be set by the user).
#
# ETC. for PARAMETER SPECIFIC INPUT DATA for ParamB and ParamC:
#
#
# Very small modification of the code have to be done to handle additional
# parameters, see below:
#
# 1) Add another "box" for e.g. ParamD, "# Specific Data for the ParamD".
#
# 2) Add another object under "Creation of objects for inputs parameters of
#    interest" for e.g .ParamD.
#
# 3) Add another object for e.g. ParamD to the lists under
#    "Creates resultfolders for the parameters A, B, C",
#    "Ensures that the parameters are in their initial positions" and
#    "Call of subroutines for parameterchanges".      


import adsk.core, adsk.fusion, adsk.cam, os

app = adsk.core.Application.get()
ui  = app.userInterface  
des = app.activeProduct

# General Input Data.        
ResultFolder = 'D:/EX/'        
ImageWidth =  2560
ImageHeight = 1440        
       
# Specific Data for the ParamA.
parametersParamA = des.userParameters.itemByName('DiameterFolding')       
StartParamA = 80.0        
IncrParamA = 0.05        
EndParamA = 80.2
PictNameParamA = 'ParamA'
InfoNameParamA = 'InfoParamA'        
CntStartParamA = 1        
ActivateParamA = 'True'

# Specific Data for the ParamB.               
parametersParamB = des.userParameters.itemByName('ElevationAngleFront')
StartAngleParamB = 0.001        
IncrAngleParamB = 0.001       
EndAngleParamB = 0.005
PictNameParamB = 'ParamB'
InfoNameParamB = 'InfoParamB'        
CntStartParamB = 1
ActivateParamB = 'False'

# Specific Data for the ParamC.                       
parametersParamC = des.userParameters.itemByName('ElevationAngleRear')
StartAngleParamC = 0.001        
IncrAngleParamC = 0.001        
EndAngleParamC = 0.005
PictNameParamC = 'ParamC'
InfoNameParamC = 'InfoParamC'    
CntStartParamC = 1
ActivateParamC = 'False'

# Function for creation of input objects.
class inp_val:
    def __init__(self,a,b,c,d,e,f,g,h,i,j,k):
        self.param = a
        self.startPar = b
        self.incPar = c
        self.endPar = d
        self.incStartPar = e        
        self.pictName = f
        self.infoName = g        
        self.resDirGlobal = h
        self.imgWidth = i
        self.imgHeight = j
        self.active = k

# Subroutine for saving pictures in png-format.
def chg_par(prop_obj):
    InfoFile = prop_obj.resDirGlobal + prop_obj.pictName + '/'  + prop_obj.infoName + '.txt'          
    while prop_obj.startPar <= prop_obj.endPar:
        prop_obj.param.value = prop_obj.startPar
#        adsk.doEvents()                        
        fileName = prop_obj.resDirGlobal + prop_obj.pictName + '/' + prop_obj.pictName + str(prop_obj.incStartPar).zfill(4)
        app.activeViewport.saveAsImageFile(fileName, prop_obj.imgWidth, prop_obj.imgHeight)  
        InfoText = open(InfoFile,'a')
        InfoText.write("%.20s,%.i\n" %("cnt:", prop_obj.incStartPar))
        InfoText.write("%.25s,%.4f\n" %(prop_obj.param.name, prop_obj.startPar))
        InfoText.write('\n')
        InfoText.close()            
        prop_obj.startPar += prop_obj.incPar
        prop_obj.incStartPar += 1
                      
    InfoText = open(InfoFile,'a')
    InfoText.write('\n')
    InfoText.write('Ready')
    InfoText.close()

# Creation of objects for inputs parameters of interest.
ParamA = inp_val(parametersParamA, StartParamA, IncrParamA, EndParamA,\
                   CntStartParamA, PictNameParamA, InfoNameParamA, ResultFolder,\
                   ImageWidth, ImageHeight, ActivateParamA)

ParamB = inp_val(parametersParamB, StartAngleParamB, IncrAngleParamB,\
                       EndAngleParamB, CntStartParamB, PictNameParamB,\
                       InfoNameParamB, ResultFolder, ImageWidth, ImageHeight,\
                       ActivateParamB)

ParamC = inp_val(parametersParamC, StartAngleParamC, IncrAngleParamC,\
                      EndAngleParamC, CntStartParamC, PictNameParamC,\
                      InfoNameParamC, ResultFolder, ImageWidth, ImageHeight,\
                      ActivateParamC)

# Sets the current directory to "ResultsFolder".
os.chdir(ResultFolder)

# Creates resultfolders for the parameters A, B, C.
for resFold in [ParamA, ParamB, ParamC]:
    resPath = resFold.resDirGlobal + resFold.pictName + '/'
    if not os.path.exists(resPath):
        os.mkdir(resPath)                      
                      
# Ensures that the parameters are in their initial positions.           
for initState in [ParamA, ParamB, ParamC]:
    if initState.active == 'True':   
        initState.param.value = initState.startPar
        adsk.doEvents()
          
# Call of subroutines for parameterchanges.
for comp in [ParamA, ParamB, ParamC]:
    if comp.active == 'True':    
        chg_par(comp)
0 Likes
Message 6 of 9

marshaltu
Autodesk
Autodesk

Hello,

 

Thank you for detailed information. Unfortunately the sample codes cannot be run without the model you created. It would be great if you can invite me (marshal dot tu at autodesk dot com) to your project or send me (same email) your model.

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 7 of 9

Peter__B
Advocate
Advocate

Hi Marshal

 

I have deleted some part in order to get the model cleaner. The real model has several more folded structures modelled onto it, but I hope that this simplified model may show how the memory works even if this model does not make any problem because I have a lot of RAM.

Please also look into the model. Perhaps there is a more efficient way of modelling folded structures which will be "folded and unfolded" with a python script like the one I have attached or some comment on the code. Please see the attached file, "FoldedCylinder v3.f3d"

 

Thanks

Peter

0 Likes
Message 8 of 9

marshaltu
Autodesk
Autodesk
Accepted solution

Hello,

 

Thank you for sharing the design. I did see the memory issue and tracked it as FUS-38142 in our internal system.

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 9 of 9

GillesJrBisson
Contributor
Contributor

Hi,

Any progress on issue FUS-38142 ? Is your bug database accessible somewhere ?

I am experiencing the same kind of issue.

Regards !

 

0 Likes