Why am I getting an NVIDIA Error code: 3 (subcode 2) popup?
15 views (last 30 days)
Show older comments
MathWorks Support Team
on 10 Jan 2023
Answered: MathWorks Support Team
on 6 Feb 2023
I am using MATLAB R2022a to create a plot with the "scatter" function from a 50,000-by-50,000 size matrix. I received a popup titled "NVIDIA OpenGL Driver" with the following message:
Unable to recover from a kernel exception. The application must close.
Error code: 3 (subcode 2)
Originally I was only getting the popup when trying to plot the large dataset, but eventually I was getting it even when plotting smaller datasets.
This popup would not appear when I used software OpenGL, but the plots would then come out grainy and pixelated. Why is this popup occurring, and how can I prevent it?
Accepted Answer
MathWorks Support Team
on 10 Jan 2023
This issue is being caused by the Java heap size being too small, and can be resolved by increasing the Java heap size.
There are two ways to change the Java heap size:
Method 1:
1. In MATLAB, open Preferences, which is under the Home tab.
2. Navigate to MATLAB > General > Java Heap Memory.
3. Set the slider to the maximum value.
If the crash is still occurring, try setting the value higher by using the following steps:
Method 2:
1. Open MATLAB as Administrator.
2. Execute the following commands in the Command Window:
>> matlabroot
>> computer(‘arch’)
3. Set the Current Folder in MATLAB to (result of “matlabroot”)\bin\(result of “computer(‘arch’)”). For example, "C:\Program Files\MATLAB\R2022a\bin\win64"
4. Create a new script with the following line:
-Xmx120m
This is case-sensitive, and you can change “120” to larger values. The number sets the number of MB that constitutes the maximum heap size.
5. Save the script as “java.opts”.
6. Close and reopen MATLAB in non-Administrator mode.
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!