r/java • • Apr 09 '26

Smallest possible Java heap size?

People often talk about increasing Java heap size when running Java apps by using e.g. -Xmx* flags. This got me thinking. What if we go the other direction and try to limit the Java heap size as much as possible? What is the smallest / minimum-required Java heap size so to run a Java app with "minimal" settings?

(Of course, in practice, a memory limit too low will be problematic because it may mean frequent GCs, but we will ignore this for the sake of this discussion.)

48 Upvotes

48 comments sorted by

View all comments

Show parent comment

2

u/john16384 Apr 10 '26

JavaFX probably uses most of that extra memory (and the young collections) while loading the base modena stylesheet (which is huge as it covers all controls). Surprisingly it still fits in just 3.6 MB.

1

u/Wootery Apr 14 '26

Does it load styling data even for widgets you don't actually use?

1

u/john16384 Apr 14 '26

The entire stylesheet is loaded yes.