Javacv: java.lang.OutOfMemoryError: Physical memory usage is too high: physicalByte > maxPhysicalBytes

Created on 2 Jun 2017  路  6Comments  路  Source: bytedeco/javacv

Sometimes when I start recording I get:

java.lang.OutOfMemoryError: Physical memory usage is too high: physicalByte > maxPhysicalBytes

FATAL EXCEPTION: main
Process: com.example.driverassistance, PID: 11047
java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes = 452M > maxPhysicalBytes = 384M
    at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:562)
    at org.bytedeco.javacpp.Pointer.init(Pointer.java:121)
    at org.bytedeco.javacpp.avcodec$AVPacket.allocate(Native Method)
    at org.bytedeco.javacpp.avcodec$AVPacket.<init>(avcodec.java:1696)
    at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
    at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:129)
    at com.example.driverassistance.FFmpegVideoRecord.initRecorder(FFmpegVideoRecord.java:272)
    at com.example.driverassistance.FFmpegVideoRecord.startStopRecord(FFmpegVideoRecord.java:201)
    at com.example.driverassistance.FFmpegVideoRecord$2.onClick(FFmpegVideoRecord.java:157)

mFrameRecorder = new FFmpegFrameRecorder(videoFilePath, videoWidth, videoHeight, 2);

question

Most helpful comment

On Android the easiest thing to try is the largeHeap attribute:
https://developer.android.com/guide/topics/manifest/application-element.html

All 6 comments

So, you might want to increase that limit...

Could you tell me how? Also I'm not sure what all of this means, could you also clarify this , why it requires bigger value for me sometimes?

I have phone with 3 GB ROM, usually 0.9-1.4 gb is free

On Android the easiest thing to try is the largeHeap attribute:
https://developer.android.com/guide/topics/manifest/application-element.html

I have the same issue on my RedHat server, maybe a memory leak? @saudet

@Deallinker Make sure you're using JavaCV 1.4.4. A couple of memory leaks have been fixed.

BTW, I think I've fixed all the memory leaks occurring in FFmpegFrameGrabber and FFmpegFrameRecorder.
Please give it a try with the snapshots: http://bytedeco.org/builds/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cansik picture cansik  路  4Comments

The-Crocop picture The-Crocop  路  5Comments

newstarbka picture newstarbka  路  5Comments

myScoopAndroidCamera picture myScoopAndroidCamera  路  4Comments

SenudaJayalath picture SenudaJayalath  路  3Comments