java heap error when opening txt file
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Jan
2021-3-31
"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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!