java heap error when opening txt file
1 view (last 30 days)
Show older comments
Hello,
when opening a txt-file with
fid = open('testfile.txt');
I am getting an error:
Exception in thread "AWT-EventQueue-0": java.lang.OutOfMemoryError: Java heap space
at javax.swing.text.GapContent.allocateArray(GapContent.java:94)
at javax.swing.text.GapVector.resize(GapVector.java:214)
at javax.swing.text.GapVector.shiftEnd(GapVector.java:229)
at javax.swing.text.GapContent.shiftEnd(GapContent.java:345)
at javax.swing.text.GapVector.open(GapVector.java:201)
at javax.swing.text.GapVector.replace(GapVector.java:142)
at javax.swing.text.GapContent.insertString(GapContent.java:132)
at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:723)
at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
at javax.swing.text.PlainDocument.insertString(PlainDocument.java:130)
at javax.swing.text.DefaultEditorKit.read(DefaultEditorKit.java:273)
at com.mathworks.widgets.datamodel.TextFileBackingStore.readIntoDocument(TextFileBackingStore.java:200)
at com.mathworks.widgets.datamodel.TextFileBackingStore.loadDocumentFromFile(TextFileBackingStore.java:169)
at com.mathworks.widgets.datamodel.TextFileBackingStore.doLoad(TextFileBackingStore.java:241)
at com.mathworks.widgets.datamodel.TextFileBackingStore.doLoad(TextFileBackingStore.java:32)
at com.mathworks.widgets.datamodel.AbstractBackingStore.load(AbstractBackingStore.java:114)
at com.mathworks.mde.editor.EditorView.reload(EditorView.java:410)
at com.mathworks.mde.editor.EditorView.initSyntaxTextPane(EditorView.java:862)
at com.mathworks.mde.editor.EditorView.<init>(EditorView.java:222)
at com.mathworks.mde.editor.EditorView.<init>(EditorView.java:153)
at com.mathworks.mde.editor.EditorViewClient.init(EditorViewClient.java:232)
at com.mathworks.mde.editor.EditorViewClient.<init>(EditorViewClient.java:181)
at com.mathworks.mde.editor.MatlabEditorApplication.createEditorViewClient(MatlabEditorApplication.java:700)
at com.mathworks.mde.editor.MatlabEditorApplication.createEditorViewClient(MatlabEditorApplication.java:685)
at com.mathworks.mde.editor.MatlabEditorApplication.createEditorViewClientFromExistingFile(MatlabEditorApplication.java:677)
at com.mathworks.mde.editor.MatlabEditorApplication.access$300(MatlabEditorApplication.java:73)
at com.mathworks.mde.editor.MatlabEditorApplication$4.runWithOutput(MatlabEditorApplication.java:402)
at com.mathworks.jmi.AWTUtilities$Invoker$2.watchedRun(AWTUtilities.java:475)
at com.mathworks.jmi.AWTUtilities$WatchedRunnable.run(AWTUtilities.java:436)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
The file is approximately 820MB large. My system has 16 GB of ram. I changed java heap space under preferences to up to 4 GB, but that does not change anything (it just takes longer for the error to appear -> matlab is busy for a longer time)
I think 820MB shouldn't be too large, so what could I do differently? Btw, I tried this in 2018b and 2019b.
Kind regards.
0 Comments
Accepted Answer
Jan
on 31 Mar 2021
"I think 820MB shouldn't be too large"
What is the purpose to open a 820MB file in Matlab's editor? What do you want to do with it there?
Matlab's editor is not designed for such large files. Try Notepad++, if you are working on Windows. Under Linix I'd open it with vi.
4 Comments
More Answers (0)
See Also
Categories
Find more on Call Java from MATLAB 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!