Potential memory leak on Reset

Potential memory leak on Reset

sastanin
Advocate Advocate
20 Views
1 Reply
Message 1 of 2

Potential memory leak on Reset

sastanin
Advocate
Advocate

[ FlexSim 20.0.9 ]

I noticed that memory allocation of the flexsim.exe process seems to go up with Resets and possibly some other operations. Initially a user has reported that the memory is not completely freed on File -> New Model, but after some tests I came to the conclusion, that even a single Reset is enough to see some memory allocated which is not freed later.

The bigger the model, the more noticeable is this effect.

How to reproduce

1. Create a model with 1600 Operators (the effect seems to be proportional to the number of objects in the model)

for (int i = 1; i <= 40; i++) {
     for (int j = 1; j <= 40; j++) {
         Object op = createinstance(library().find("?Operator"), model());
         op.location = Vec3(-20 + j, -10 + i, 0);
         op.rotation.z = -90;
     }
 }

2. Monitor Working Set size of the flexsim.exe process. I used this PowerShell script to sample it every 5 seconds:

Set-Content .\memlog.txt -value ""
while ($true){ 
     $p = Get-Process -Name flexsim ;
     if ($p) { 
        $s = "$(Get-Date -Format 'HH:mm:ss')`t$($p.WS / 1024 / 1024)`tMiB" 
        Write-Host $s 
        Add-Content -Path memlog.txt -Value $s 
        Sleep 5 
    } 
}

3. I used this AutoHotKey script (attached reset_repeat.ahk.txt, rename as reset_repeat.ahk, and flexsim_Reset.png, save it in the same directory) to click Reset button every second:

^!r:: ; on Ctrl-Alt-R click Reset repeatedly 
CoordMode Client
ImageSearch ResetLocX, ResetLocY, 0, 0, 300, 200, flexsim_Reset.png
if (ErrorLevel = 0) {
   Loop {
     ClickX := ResetLocX + 30
     ClickY := ResetLocY + 10
     MouseMove, ClickX, ClickY
     MouseClick
     MouseMove, ClickX+25, ClickY+15
     Sleep, 1000
  }
} 

Esc::ExitApp ; stop on Esc 

return

And this is the result:

33498-memlog.png

On average FlexSim is allocating 0.425 MiB per reset, or roughly 279 bytes per Operator object.

Expected behavior: WS is reaches a plateau after a number of iterations.


Accepted solutions (1)
21 Views
1 Reply
Reply (1)
Message 2 of 2

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

Thanks for pointing this out. We'll look into it.



Matthew Gillespie
FlexSim Software Developer

0 Likes