Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMU Crash in Python with OMSimulator #1299

Open
Primkins opened this issue May 16, 2024 · 8 comments
Open

FMU Crash in Python with OMSimulator #1299

Primkins opened this issue May 16, 2024 · 8 comments

Comments

@Primkins
Copy link

Primkins commented May 16, 2024

Application crashes, when the OMSimulator method (stepUntil) is called inside the loop in Python code,

error:   [fmi2logger] D:/TestFMU/test_tmp/test-nv1eatv0/temp/0001_A (logFmi2Call): fmi2CompletedIntegratorStep: terminated by an assertion.
idx : 6595
idx : 6596
idx : 6597
idx : 6598
LOG_ASSERT        | debug   | C:/Users/Demo/AppData/Local/Temp/OpenModelica/OMEdit/Test_X11/Test_X11.fmutmp/sources/gc/memory_pool.c:100: pool_expand: Assertion `0 && "Attempt to allocate an unusually large memory. The memory management does not seem to be working as intended. Please create an issue on https://github.com/OpenModelica/OpenModelica/issues."` failed.
  • Version: `OMSimulator-V2.1.1Post257
  • OS: Win11, 64bit
@Primkins
Copy link
Author

@lochel Can you take a look on this issue as you are working on FMU memory issues

@arun3688
Copy link
Contributor

@Primkins can you please attach a new zip file, when downloading the zip file, it says virus detected, Can you please tell the name of the Model, so that we can generate the fmu's ourself

@Primkins
Copy link
Author

@lochel

generate the FMU and test.

model Test_X11
function fraction
input Integer size "Array size";
input Real Y[size] "input array 1";
output Real Z[size] "Sum of products value";
algorithm
for i in 1:size loop
Z[i] := Y[i]/sum(Y);
end for;
end fraction;

function SumProd
//Calculates sum of products for two arrays
input Integer size "Array size";
input Real X[size] "input array 1";
input Real Y[size] "input array 2";
output Real Z "Sum of products value";
algorithm
Z := sum(X[:].*Y[:]);

end SumProd;
constant Real MWs[10]={44.0095,18.015,28.014,28.01,2.01588,1,17,16,30.006,31.999};
Real x[:]={2.823840247,3.849832585,19.95975706,0.176159753,0.046351706,0.066372392,0.141259026,0.001503924,0.08048587,0.051539174};
output Real MoleFrac[10](each min=0, each max=1);
output Real ppmCO(min=0);
output Real ppmNO(min=0);
output Real MW ;
equation
MoleFrac=fraction(size=10, Y=x);
MW=SumProd(size=10, X=MoleFrac, Y=MWs);
ppmCO = MoleFrac[4]*1E6;
ppmNO = MoleFrac[9]*1E6;
end Test_X11;

@lochel
Copy link
Member

lochel commented Nov 27, 2024

@Primkins The model works just fine. So maybe it is connected to how you run it. Can you provide a python script to reproduce your problem?

I tested with standard settings, and changing stopTime to 2000. Both simulations went fine.

@Primkins
Copy link
Author

@lochel: Attached the test script Test.zip

@lochel
Copy link
Member

lochel commented Nov 27, 2024

@Primkins I can reproduce the issue and will keep you updated. Thanks for reporting the issue.

@lochel
Copy link
Member

lochel commented Nov 27, 2024

I ran the example with valgrind (reducing the number of steps to 2000), and no memory leaks were detected:

==44603== HEAP SUMMARY:
==44603==     in use at exit: 0 bytes in 0 blocks
==44603==   total heap usage: 6,027,224 allocs, 6,027,224 frees, 3,918,693,264 bytes allocated
==44603==
==44603== All heap blocks were freed -- no leaks are possible

However, when simulating the model directly in OpenModelica, it seems there is no reason for the memory pool to grow to such an extent. @OpenModelica/developers, can anyone with knowledge of the memory pool investigate this issue?

@arun3688
Copy link
Contributor

@Primkins I have removed the zip file because it warns about virus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants