Was java heap memory limited in MATLAB 2025b?

73 views (last 30 days)
Nick
Nick on 30 Sep 2025 at 18:39
Commented: dpb on 2 Oct 2025 at 20:36
Has anyone else noticed that the java heap memory has been severely limited in MATLAB 2025b? In 2024b it was ~32000MB, now it is ~8000MB. Why the change? This is detrimental for my code and not worth working around. Hopefully this changes back or this is the last straw and I may finally move to Python...
  9 Comments
Benjamin Kraus
Benjamin Kraus on 2 Oct 2025 at 17:07
@dpb: Calling into Java from MATLAB is definitely not deprecated. It is still fully support and I am not aware of any plans to change that. That wasn't what I was trying to suggest by my question. I don't know the rational behind changing the upper limit for Java heap size (that is not my team at MathWorks), but it sounds like @Nick is already talking to the right people to answer that question, so I'll let them provide the answer to @Nick.
dpb
dpb on 2 Oct 2025 at 17:26
@Benjamin Kraus - I grok, I just wanted to express my very strong opinion that introducing barriers to the user in how they choose to use MATLAB is misguided direction on Mathworks' part. The external languages interface link was only to emphasize that it doesn't make a lot of sense to continue to support Java and then purposefully try to hamstring it unless there were any such intentions. I did go look at the current documentation just to confirm for myself that no such implications had been introduced.
Hopefully we'll get a report back on the reasoning behind introducing the limitation when @Nick gets an official response.

Sign in to comment.

Accepted Answer

Nick
Nick on 2 Oct 2025 at 19:16
Edited: Nick on 2 Oct 2025 at 19:16
After contacting MathWorks it seems that the maximum Java Heap Memory was in fact reduced in MATLAB 2025b. However, they said this was a 'bug', and that their 'development team will consider fixing this in one of the future releases'.
We'll await the fix!

More Answers (1)

Benjamin Kraus
Benjamin Kraus on 2 Oct 2025 at 20:18
Edited: Benjamin Kraus on 2 Oct 2025 at 20:20
@Nick: Now that you've got an answer from technical support that it was a bug, let's talk potential solutions/workarounds.
Have you tried using a java.opts file to change the maximum memory allocated to the Java heap?
I just did a quick experiment, and from what I can tell it seems to have worked.
I created a new java.opts file in my MATLAB startup directory (following these instructions: "Specifying Java Startup Options", but ignoring the part that says "To adjust the Java heap size on desktop versions of MATLAB, use Java Heap Memory Settings.").
Contents of java.opts:
-Xmx32689m
I then ran this command in MATLAB:
java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments
It showed two copies of "-Xmx", the one from MATLAB's preferences, and the one from java.opts. But the one from java.opts was second, and seems to take precidence over the earlier setting.
I then used the jstat command to verify that the new settings took effect, and they seem to have worked.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!