Advice on Heisenbug causing crash in code

1 Ansicht (letzte 30 Tage)
Paul Johnson
Paul Johnson am 8 Sep. 2022
Beantwortet: Shivam Lahoti am 20 Okt. 2023
Hi
I keep on getting a matlab crash when running a matlab script I have that routes simulink models using JSON data.
It's an odd bug as when i attempt to run the script in debug mode slowly the crash doesn't occur.
This suggests to me there is some form a memory management problem. Does anyone have any advice?
Should I institude delays in my code with a timer? Are there methods that i should be using to control these sorts of errors?
Thanks

Antworten (1)

Shivam Lahoti
Shivam Lahoti am 20 Okt. 2023
Hi Paul,
From what I can understand, you are getting a MATLAB crash while running a script that routes Simulink models using JSON data. The script runs successfully when run in debug mode.
The crash could be due to multiple reasons and as you pointed out it might be a memory management problem. MATLAB has a tool named MATLAB Profiler, which creates reports of the runtime of MATLAB code, broken down by individual function calls.
The profiler is primarily designed to analyze the runtime behavior of your code, identify performance bottlenecks, and suggest areas for optimization. However, if the crash is related to excessive memory usage or inefficient code that leads to out-of-memory errors, the profiler can help you identify memory-intensive operations or memory leaks that may contribute to the crash.
Have a look at the following documentation to understand how to use the MATLAB profiler.
  • the profiler will display a summary of the runtime behavior and performance metrics.
  • Analyze the profiler results, focusing on areas such as function execution time, memory usage, and function call hierarchy.
  • Look for any performance bottlenecks, memory-intensive operations, or functions that consume excessive memory.
This might not directly tell the cause of the crash but might point to some sections that might be the cause of the crash, later the code could be modified and check for the compatibility report to debug the section.
I hope this helps.
Regards,
Shivam Lahoti.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by