Posts: 1
Joined: Tue Sep 14, 2021 8:13 am

Raspberry Pi 4, program made in Java is very laggy.

Tue Sep 14, 2021 8:34 am

I recently got a Raspberry to run a graphics accelerated program I made in Processing. I've played around with the GPU overclocks and memory amounts, but nothing has helped this: The program is set to run at 60 FPS. it runs totally fine on my MacBook and since it only has a total of 2 bitmap images, where only one of which is 1080p, I'd expect it to run on a Raspberry no problem. However, it runs anywhere between 30 - 50 FPS, I cannot confirm this as there's no FPS counter on the program but the moving graphic just looks really unstable and gives a headache if looked at for too long. I did try changing the program to 720p, which did make it a little better, but it was still laggy.

I ran htop, and I'm getting 25% used at most for one CPU core when running the program. RAM is also at just 500 MB usage.

Could it be either the GPU or the version of Java? I installed default-jdk and that should be the best right? I was suggested somewhere else it could be an IO bottleneck, but I tried running the program from a USB stick and the internal storage, which had no difference.

As of writing, here are the "mods" I've made:
- GPU overclock is set to 600 (MHz)
- GPU mem is set to 128 MB (setting the number higher has not made a difference)
- FKMS is enabled
- All packages are up-to-date (Raspberry OS 32-bit, I tried the 64-bit version but there was no real difference)
- Display and the program are both running at 1080p
- The Raspberry is in a metal case with a fan running inside, so thermals shouldn't be an issue

User avatar
Posts: 6193
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4, program made in Java is very laggy.

Wed Sep 15, 2021 1:22 am

Probably software rendering?
I stopped using Java after they dropped support for JavaFX and the Pi's "GPU" acceleration.
Not sure of the current state of Java and Acceleration support.

Processing on PC's is cool but is best with accelerated video.

Edit - Looks like hardware support for Pi4 is around.
https://gluonhq.com/hardware-accelerate ... pberry-pi/
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Posts: 729
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: Raspberry Pi 4, program made in Java is very laggy.

Wed Sep 15, 2021 10:13 pm

Is it a JavaFX program or using AWT/Swing? If AWT/Swing and you have the FKMS driver enabled try using this command line switch:


I find Java graphics performance to be better without the KMS drivers and no command line switch.

If you really want fast Java graphics, nothing beats Windows and DirectX.

Return to “Java”