Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Java JNI with QT application - Why it's use so many CPU resources?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 661 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ArtUrlWWW
    wrote on last edited by
    #1

    I have Java JNI app with QT application.

    Java class:
    @
    package my.site.processors.files.jni;

    import java.io.File;

    /**
    *

    • @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>

    FfmpegStarterJNI::FfmpegStarterJNI()
    {
    }

    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);
    
    a.exec&#40;&#41;;
    

    }
    @
    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(); (http://qt-project.org/doc/qt-5/qapplication.html#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(); ?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved