Java JNI with QT application - Why it's use so many CPU resources?

  • I have Java JNI app with QT application.

    Java class:



    • @author ArtUrlWWW
      public class FfmpegStarter {

      public native void run(String pathToFfmpegExe, String paramsArr[]);


    QT code is:

    #include "ffmpegstarterjni.h"
    #include "mainwindow.h"
    #include <QApplication>
    #include <QStringList>


    JNIEXPORT void JNICALL Java_my_site_processors_files_jni_FfmpegStarter_run
    (JNIEnv *env, jobject object, jstring pathToFfmpegExe, jobjectArray stringArray) {

    int argc=0;
    char *argv[1];
    QApplication a(argc, argv);

    With this code Java JVM used 100% of one core (25% from 4-core CPU).

    If I comment a.exec(); code, then JVM doesn't use 100% of one CPU's core.

    As I understand, this caused by a.exec(); ( - it makes loop, what can be ended by the QApplication::quit(); .

    How to prevent huge CPU usage in JNI applications, which used QT and QApplication's function a.exec(); ?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.