Excel crashes while creating a MATLAB Component

spattewar used Ask the Experts™
Hello Experts,

I am creating an object of a MATLAB component in excel VBA. But when I execute the create object command excel crashes and closes. The error log gives the following description.

Error occurred during initialization of VM
Could not reserve enough space for object heap
Stack Trace:
  [0] jmi.dll:void __stdcall mwJavaAbort(void)(0x78f95578 "Could not reserve enough space f..", 0, 0x78dd0000, 0x1d8014e0) + 21 bytes

        Fatal Java Exception detected at Fri Jan 29 11:18:53 2010

  MATLAB Version: (R2007b)
  MATLAB License:   unknown
  Operating System: Microsoft Windows XP
  Window System:    Version 5.1 (Build 2600: Service Pack 3)
  Processor ID:     x86 Family 6 Model 7 Stepping 10, GenuineIntel
  Virtual Machine:  Java is not enabled
  Default Charset:  windows-1252

Java is not enabled

It is failing in all the machines in our office in London but is working in our Boston office. We tried to install the latest java and also changed the MATLAB JAVA path as per a working machine in Boston. It was also working on London machine till Last Tuesday and suddenly it started failing on all the machines. We know it is something to do with the machine setting but are not able to figure it out.

The MATLAB runtime is same on all the machines across location and the MATLAB package that we install to get the MATLAB component is also same.

Would you be able to guide me in the correct direction?

Thanks a lot for your time and effort.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

look like the bug is already reported:

The bug report might not be accessible if you don't have an account on Mathworks.com. I copy-paste it here:

Standalone deployed application crashes due to memory fragmentation. JVM does not have enough memory to start.

When a standalone application is started, it launches the MATLAB Component Runtime (MCR) and the MCR tries to start a Java Virtual Machine (JVM). If the system memory is sufficiently fragmented, preventing the JVM from obtaining adequate resources to start up, it crashes. This causes the MCR and the initial standalone application to crash.

A Java dump occurs and a log file is generated in a temp folder. This log file will contain text similar to:

"Error occurred during initialization of VM
Could not reserve enough space for object heap "

"Java is not enabled"

Fatal Java Exception detected
------------------------------------------------------------------------ "


If this problem occurs, and your application doesn't require a JVM, use the -nojvm argument when starting your application.

Exists in Release (Version)

Exists in R2008b(4.9), R2008a(4.8), R2007b(4.7), R2009b(4.11), R2009a(4.10)

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Thanks yuk99 and nmcdermaid. I will test these setting tomorrow on the machine that is not working. I will update you with the results.

Thanks for your time on this issue.


So does it work on some machine but not on another?
Spattewar, in future you may wish to add your original question to another group rather than creating a brand new question.

As you can see it's causing some confusion as both questions now only have half the information.

Yuk99, there's a link above to arelated question with some different detail.
I understand nmcdermaid and sorry for the confusion. Next time I will add group to the original question instead of creating one.

I tried the setting mentioned by nmcdermaid. We created a user environmental variable MATLAB_RESERVE_LO and set its value to 0. But still the same error.

One additional information is that the machine that is not working has MATLAB 2007b runtime package installed and there is no actualy MATLAB software on that machine. Does this make a difference in the approach to tackle the problem?

Now we are trying to again compile the MATLAB dll with -nojvm arguments (if possible), deploy it on the machine and again test it.

Thanks for your time and effort.


Try to compile with -R -nojvm option. Does your application use any Matlab graphics, GUI?
no it does not use any graphics. We will try to compile using that option and test it.

what is the other way to set the nojvm option. I have found a compopts.bat file under the folder C:\Documents and Settings\p462976\Application Data\MathWorks\MATLAB\mcr_v77\ and then under the object folder.

Can we do any configuration changes here?

I believe you can alter this file directly (however I haven't done that myself) or using mbuild -setup command. Take care to use compopts.bat in proper location. See this:
You can find preference directory for your Matlab version just running prefdir command.
Users from other locations have replied. It looks like the error was because of other excel add-ins but are not clear on the issue. We tried all the responses and that has of course helped us to narrow down the issue.

Thank you very much for your time and the direction provided.

Thank you||

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial