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:
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.