Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes (974M) > maxPhysicalBytes (512M) #1465

Closed
hongqimei opened this issue Jul 15, 2020 · 11 comments

Comments

@hongqimei
Copy link

hongqimei commented Jul 15, 2020

I tried to port the jar of this project to unreal engine 4, Android platform, but found that when I dynamically create a FFmpegFrameGrabber.createDefault(url);, when the memory exceeds 512M, an error will be reported, the error is as follows


2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes (974M) > maxPhysicalBytes (512M)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at org.bytedeco.javacpp.Pointer org.bytedeco.javacpp.Pointer.deallocator(org.bytedeco.javacpp.Pointer$Deallocator) (Pointer.java:682)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.javacpp.Pointer.init(long, long, long, long) (Pointer.java:127)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.ffmpeg.avcodec.Cb_PointerPointer_int.allocate() (Cb_PointerPointer_int.java:-2)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.ffmpeg.avcodec.Cb_PointerPointer_int.<init>() (Cb_PointerPointer_int.java:49)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.javacv.FFmpegLockCallback$1.<init>() (FFmpegLockCallback.java:20)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.javacv.FFmpegLockCallback.<clinit>() (FFmpegLockCallback.java:20)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.javacv.FFmpegLockCallback.init() (FFmpegLockCallback.java:-1)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void org.bytedeco.javacv.FFmpegFrameGrabber.<clinit>() (FFmpegFrameGrabber.java:129)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at org.bytedeco.javacv.FFmpegFrameGrabber org.bytedeco.javacv.FFmpegFrameGrabber.createDefault(java.lang.String) (FFmpegFrameGrabber.java:93)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at void com.epicgames.ue4.GameActivity$VideoPlayer.<init>(com.epicgames.ue4.GameActivity, android.os.Handler, int, java.lang.String, int, int, int, java.lang.String) (GameActivity.java:562)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]   at int com.epicgames.ue4.GameActivity.CreateVideoPlayer(java.lang.String, int, int, int, java.lang.String) (GameActivity.java:638)
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570] 
2020-07-15 13:02:32.786 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: java_vm_ext.cc:570]     in call to NewStringUTF
2020-07-15 13:02:33.024 15278-15524/com.YourCompany.JavaTest I/AudioTrack: isLongTimeZoreData zoer date time 16 Seconds
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630] Runtime aborting...
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630] Dumping all threads without mutator lock held
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630] All threads:
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630] DALVIK THREADS (75):
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630] "Thread-3" prio=10 tid=23 Runnable
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   | group="" sCount=0 dsCount=0 flags=0 obj=0x12c40000 self=0x74c9565000
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   | sysTid=15433 nice=-10 cgrp=default sched=0/0 handle=0x746ddfbd50
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   | state=R schedstat=( 14048268224 4402071433 84558 ) utm=1080 stm=324 core=5 HZ=100
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   | stack=0x746dd05000-0x746dd07000 stackSize=991KB
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   | held mutexes= "abort lock" "mutator lock"(shared held)
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   native: #00 pc 000000000041192c  /apex/com.android.runtime/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140)
2020-07-15 13:02:33.356 15278-15433/com.YourCompany.JavaTest A/ompany.JavaTes: runtime.cc:630]   native: #01 pc 00000000004f9190  /apex/com.android.runtime/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+512)
@saudet
Copy link
Member

saudet commented Jul 15, 2020

Please try again with JavaCV 1.5.4-SNAPSHOT: http://bytedeco.org/builds/

@cotfas
Copy link

cotfas commented Jul 15, 2020

I have similar errors:

Setup:

export JAVA_MIN_MEM=512M
export JAVA_MAX_MEM=1024M
export EXTRA_JAVA_OPTS=-XX:MaxMetaspaceSize=1024m

Javacv 1.3.3

Env: Karaf, Java8, Linux/Mac OSX

For two cases:

Caused by: java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes = 2G > maxPhysicalBytes = 1G
at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:576)
at org.bytedeco.javacpp.Pointer.init(Pointer.java:121)
at org.bytedeco.javacpp.opencv_core$Mat.allocate(Native Method)
at org.bytedeco.javacpp.opencv_core$Mat.(opencv_core.java:15512)
at org.bytedeco.javacv.OpenCVFrameConverter.convertToMat(OpenCVFrameConverter.java:141)
at org.bytedeco.javacv.OpenCVFrameConverter$ToMat.convert(OpenCVFrameConverter.java:49)

Caused by: java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes = 1G > maxPhysicalBytes = 1G
at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:576)
at org.bytedeco.javacpp.Pointer.init(Pointer.java:121)
at org.bytedeco.javacpp.opencv_core$MatVector.allocate(Native Method)
at org.bytedeco.javacpp.opencv_core$MatVector.(opencv_core.java:479)

*for 2nd error, accessed from >>> try (MatVector matVector = new MatVector()) { ... }

@hongqimei
Copy link
Author

@cotfas This one appeared on Android

@hongqimei
Copy link
Author

@saudet Due to network problems, it cannot be downloaded. When will 1.5.4 come out?

@saudet
Copy link
Member

saudet commented Jul 17, 2020

@saudet Due to network problems, it cannot be downloaded. When will 1.5.4 come out?

Please try again, the snapshots should work now.
Sometime before the end of year. It depends on how much help I get. :)

@hongqimei
Copy link
Author

@saudet I replaced to 1.5.4 but the problem still occurs

@saudet
Copy link
Member

saudet commented Jul 17, 2020

512 MB is not a lot of memory. You'll probably need more memory than that anyway. Make sure to set the "largeHeap" to "true":
https://developer.android.com/guide/topics/manifest/application-element

@saudet
Copy link
Member

saudet commented Jul 17, 2020

Duplicate of #707

@saudet saudet marked this as a duplicate of #707 Jul 17, 2020
@saudet saudet closed this as completed Jul 17, 2020
@hongqimei
Copy link
Author

@saudet this is not good idea,I want to increase automatically when the memory is insufficient, instead of doing so, it seems that this kind of problem rarely occurs, whether it is a problem with the code, I use the jni method to perform the creation of the grab

@saudet
Copy link
Member

saudet commented Jul 17, 2020

We can also let the process use more memory by setting the "org.bytedeco.javacpp.maxphysicalbytes" system property to the desired value or "0" to disable the check.

@hongqimei
Copy link
Author

@saudet Thanks, i will try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants