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

조회 수: 3 (최근 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 CenterFile Exchange에서 Java Package Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by