Java exception occurred: java.lang.​OutOfMemor​yError: Java heap space

4 ビュー (過去 30 日間)
hao liu
hao liu 2017 年 10 月 3 日
コメント済み: Walter Roberson 2017 年 10 月 4 日
After running for several hours, the matlab stopped running and displayed like below:
Error using icinterface/flushinput (line 42)
Java exception occurred:
java.lang.OutOfMemoryError: Java heap space
at
com.mathworks.toolbox.instrument.LineInputStream.readByte(LineInputStream.java:59)
at
com.mathworks.toolbox.instrument.LineInputStream.flush(LineInputStream.java:47)
at
com.mathworks.toolbox.instrument.SerialComm.hardwareFlushInput(SerialComm.java:644)
at
com.mathworks.toolbox.instrument.InstrumentReader.flushinput(InstrumentReader.java:154)
Error in GUI_Aging_of_capacitor>testCAP (line 575)
flushinput(serialport_LCR);
Error in GUI_Aging_of_capacitor>START_Callback (line 430)
testCAP(LCR,0,handles);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI_Aging_of_capacitor (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GUI_Aging_of_capacitor('START_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Thanks in advance for your help!!!

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 10 月 3 日
Looking around a bit, it appears to me that the Java class being used, LineInputStream, is for CR/LF delimited streams. The flush method is probably handled by reading the line and discarding that until there is no more current input. That would be a problem if you happened to hit upon a block of bytes that had no CR/LF in it: it appears it might possibly try to keep reading.
  2 件のコメント
hao liu
hao liu 2017 年 10 月 4 日
編集済み: hao liu 2017 年 10 月 4 日
Hi walter, thanks for your answer! in terms of the issue you mentioned, do I have to delete the flushinput/flushoutput? I just increased the value of Java heap Memory to see if the method will help. BTW, the error above can happen after long time(20-30h) operation.
Walter Roberson
Walter Roberson 2017 年 10 月 4 日
If I am correct about the cause, then if for some reason a sufficiently large block with no CR/LF was present in the input stream, it would overfill any memory you might allocate. But perhaps it would be "good enough" for your purpose.
I cannot tell from what you posted what kind of device you are talking to (other than serial), or why you are talking to it. My speculation would be that you are doing a data transfer of some sort and you are losing synchronization.
What are the circumstances under which your program makes the flushinput() request?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by