MATLAB: How to resolve “AWT-EventQueue-0” exception errors when trying to open multiple instances of MATLAB

errorinstancesjavalimitlinuxMATLABmemorymultipleofoutoutofmemoryerrorresourcessystemthreadulimit

I am trying to open several instances of MATLAB at once. When I open the seventh instance, I receive the following error message:
Exception in thread "AWT-EventQueue-0": java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:717)
at com.mathworks.mlwidgets.help.addon.DemoPath$MatlabPathListener.actionPerformed(DemoPath.java:67)
at com.mathworks.jmi.MatlabPath$DeferredActionEvent.dispatch(MatlabPath.java:155)
at com.mathworks.util.QueueEvent$QueueTarget.processEvent(QueueEvent.java:85)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0": java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:717)
at com.mathworks.mlwidgets.help.addon.DemoPath$MatlabPathListener.actionPerformed(DemoPath.java:67)
at com.mathworks.jmi.MatlabPath$DeferredActionEvent.dispatch(MatlabPath.java:155)
at com.mathworks.util.QueueEvent$QueueTarget.processEvent(QueueEvent.java:85)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0": java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:717)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:957)
at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1603)
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:334)
at java.util.concurrent.ScheduledThreadPoolExecutor.scheduleWithFixedDelay(ScheduledThreadPoolExecutor.java:597)
at com.mathworks.util.ExecutorServiceFactory.createScheduledExecutorService(ExecutorServiceFactory.java:21)
at com.mathworks.util.RequestAggregator.request(RequestAggregator.java:195)
at com.mathworks.util.RequestFilter.request(RequestFilter.java:97)
at com.mathworks.util.RequestFilter.request(RequestFilter.java:88)
at com.mathworks.widgets.grouptable.AffordanceManager$5.tableChanged(AffordanceManager.java:163)
at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:296)
at com.jidesoft.grid.TableModelWrapperImpl.fireTableChanged(Unknown Source)
at com.jidesoft.grid.SortableTableModel.fireTableChanged(Unknown Source)
at com.jidesoft.grid.CompoundTableModelEvent.fireTableModelEvent(Unknown Source)
at com.jidesoft.grid.SortableTableModel.tableChanged(Unknown Source)
at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:296)
at javax.swing.table.AbstractTableModel.fireTableDataChanged(AbstractTableModel.java:198)
at com.jidesoft.grid.TreeTableModel.a(Unknown Source)
at com.jidesoft.grid.TreeTableModel.refresh(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableModel.access$1501(GroupingTableModel.java:36)
at com.mathworks.widgets.grouptable.GroupingTableModel$8.run(GroupingTableModel.java:728)
at com.mathworks.widgets.grouptable.GroupingTable$19.run(GroupingTable.java:605)
at com.mathworks.widgets.grouptable.GroupingTable$19.run(GroupingTable.java:595)
at com.mathworks.widgets.grouptable.GroupingTableModel.refresh(GroupingTableModel.java:725)
at com.mathworks.widgets.grouptable.GroupingTablePopulator.refreshModel(GroupingTablePopulator.java:163)
at com.mathworks.widgets.grouptable.GroupingTableRow$4.commitRows(GroupingTableRow.java:551)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:124)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Best Answer

To resolve this, check the thread limit using the command 'ulimit -a' at the Linux command line. This command will report various resource limits applied to all users of the system. These limits may be preventing MATLAB from creating enough threads or using enough memory to handle multiple instances. For details on these limits and how to increase them, please refer to the following link in conjunction with your Linux distribution's man page on 'ulimit':
Related Question