필터 지우기
필터 지우기

Advice on Heisenbug causing crash in code

조회 수: 1 (최근 30일)
Paul Johnson
Paul Johnson 2022년 9월 8일
답변: Shivam Lahoti 2023년 10월 20일
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

답변 (1개)

Shivam Lahoti
Shivam Lahoti 2023년 10월 20일
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.

카테고리

Help CenterFile Exchange에서 JSON Format에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by