Why does MATLAB crash or hang after interacting with a plot for some time?

MATLAB crashes suddenly and unexpectedly when zooming, panning and resetting the view in MATLAB figures. The crash log stack trace always points to "cef_string_utf16_to_upper" function of "libcef.dll":
Stack Trace (from fault):
[ 0] 0x00007ffc157341a9 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+65421737 GetHandleVerifier+03506153
[ 1] 0x00007ffc15733273 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+65417843 GetHandleVerifier+03502259
[ 2] 0x00007ffc176a89ca C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+98404810 GetHandleVerifier+36489226
[ 3] 0x00007ffc176a3a82 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+98384514 GetHandleVerifier+36468930
[ 4] 0x00007ffc176a2d82 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+98381186 GetHandleVerifier+36465602
[ 5] 0x00007ffc158c3951 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+67058001 GetHandleVerifier+05142417
[ 6] 0x00007ffc158c340f C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+67056655 GetHandleVerifier+05141071
[ 7] 0x00007ffca040e7e8 C:\WINDOWS\System32\USER32.dll+00059368 CallWindowProcW+00001016
[ 8] 0x00007ffca040e36c C:\WINDOWS\System32\USER32.dll+00058220 DispatchMessageW+00000924
[ 9] 0x00007ffca0420f93 C:\WINDOWS\System32\USER32.dll+00135059 SendMessageTimeoutW+00000323
[ 10] 0x00007ffca1d30ba4 C:\WINDOWS\SYSTEM32\ntdll.dll+00658340 KiUserCallbackDispatcher+00000036
[ 11] 0x00007ffc9f3a1704 C:\WINDOWS\System32\win32u.dll+00005892 NtUserDispatchMessage+00000020
[ 12] 0x00007ffca040e27a C:\WINDOWS\System32\USER32.dll+00057978 DispatchMessageW+00000682
[ 13] 0x00007ffc1481c119 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+49594649 cef_string_utf16_to_upper+00834329
[ 14] 0x00007ffc1481b655 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+49591893 cef_string_utf16_to_upper+00831573
[ 15] 0x00007ffc1481b3f5 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+49591285 cef_string_utf16_to_upper+00830965
[ 16] 0x00007ffc1481ad31 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+49589553 cef_string_utf16_to_upper+00829233
[ 17] 0x00007ffc153d060e C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+61867534 cef_time_delta+00270622
[ 18] 0x00007ffc147cbc89 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+49265801 cef_string_utf16_to_upper+00505481
[ 19] 0x00007ffc153713b0 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+61477808 IsSandboxedProcess+05688576
[ 20] 0x00007ffc15372243 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+61481539 IsSandboxedProcess+05692307
[ 21] 0x00007ffc14824762 C:\Program Files\MATLAB\R2022b\bin\win64\libcef.dll+49629026 cef_string_utf16_to_upper+00868706
[ 22] 0x00007ffca0b97034 C:\WINDOWS\System32\KERNEL32.DLL+00094260 BaseThreadInitThunk+00000020
[ 23] 0x00007ffca1ce2651 C:\WINDOWS\SYSTEM32\ntdll.dll+00337489 RtlUserThreadStart+00000033
A common stack trace is also the following:
[ 0] 0x00007ffe2016986e C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36018286 cef_string_utf16_to_upper+00193018
[ 1] 0x00007ffe22ad7e0e C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+79461902 VR_GetStringForHmdError+25495636
[ 2] 0x00007ffe22ad3bc6 C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+79444934 VR_GetStringForHmdError+25478668
[ 3] 0x00007ffe22ad3026 C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+79441958 VR_GetStringForHmdError+25475692
[ 4] 0x00007ffe20e5322b C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+49558059 GetHandleVerifier+03540171
[ 5] 0x00007ffe20e52d72 C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+49556850 GetHandleVerifier+03538962
[ 6] 0x00007ffee6b0e858 C:\Windows\System32\USER32.dll+00059480 CallWindowProcW+00001016
[ 7] 0x00007ffee6b0e3dc C:\Windows\System32\USER32.dll+00058332 DispatchMessageW+00000924
[ 8] 0x00007ffee6b20bc3 C:\Windows\System32\USER32.dll+00134083 SendMessageTimeoutW+00000323
[ 9] 0x00007ffee7890ba4 C:\Windows\SYSTEM32\ntdll.dll+00658340 KiUserCallbackDispatcher+00000036
[ 10] 0x00007ffee5241704 C:\Windows\System32\win32u.dll+00005892 NtUserDispatchMessage+00000020
[ 11] 0x00007ffee6b0e2ea C:\Windows\System32\USER32.dll+00058090 DispatchMessageW+00000682
[ 12] 0x00007ffe201dcb1e C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36490014 cef_string_utf16_to_upper+00664746
[ 13] 0x00007ffe201dc051 C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36487249 cef_string_utf16_to_upper+00661981
[ 14] 0x00007ffe201dbe95 C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36486805 cef_string_utf16_to_upper+00661537
[ 15] 0x00007ffe201db67e C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36484734 cef_string_utf16_to_upper+00659466
[ 16] 0x00007ffe20ae85e8 C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+45975016 cef_time_delta+00254065
[ 17] 0x00007ffe2018743a C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36140090 cef_string_utf16_to_upper+00314822
[ 18] 0x00007ffe20a98caf C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+45649071 IsSandboxedProcess+03981738
[ 19] 0x00007ffe201e18bd C:\Program Files\Matlab\R2021b\bin\win64\libcef.dll+36509885 cef_string_utf16_to_upper+00684617
[ 20] 0x00007ffee5857034 C:\Windows\System32\KERNEL32.DLL+00094260 BaseThreadInitThunk+00000020
[ 21] 0x00007ffee7842651 C:\Windows\SYSTEM32\ntdll.dll+00337489 RtlUserThreadStart+00000033
How can I resolve this? 

 Accepted Answer

Unfortunately, this is a known issue in MATLAB Releases R2021b, R2022a, and R2022b.
Please note that this issue has been fixed. You may want to upgrade your current version of MATLAB to the R2023a or a later release to help resolve the crash.
 
If you consider using R2021b, R2022a, or R2022b, please use the following workaround that may prevent MATLAB from crashing:
 
While you interact with plots, please monitor the Graphical Device Interface (GDI) handles in Windows Task Manager. When the number of GDI objects approaches 10,000, please execute the following command in MATLAB Command Window that will perform manual garbage collection and may prevent the crash from occurring: 
>> java.lang.System.gc() 
After the execution of the above command, you should observe a decrease in the number of GDI objects. You might have to execute this command multiple times during your interactive workflow.
 
You can add “java.lang.System.gc()” to your favorites so that you don’t have to type it every time. For an example please refer to the following documentation page:
How to monitor the GDI handles in Windows Task Manager:
  1. Press "Ctrl" + "Alt" + "Delete"
  2. Click "Task Manager"
  3. Click on "Details"
  4. Right click on the column headers (Name, PID, Status, etc)
  5. Click "Select columns"
  6. Find "GDI Objects" and check it
  7. Click "OK"

More Answers (0)

Categories

Products

Release

R2022b

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!