Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will the Java Compact Profiles actually reduce memory footprint?

Tags:

java

My understanding of Java Class loading is that its lazy loaded. Thus if you have a bunch of unused jars shipped with a Java application they will only waste disk space and not actually consume memory. However it seems to be implied on various Oracle blogs/documentation that compact profiles will actually reduce memory footprint (here and here).

To make it an easy yes or no question that is not subjective:

If I make a "hello world!" Java application (ie only using System.out) will it actually have a smaller runtime memory footprint when run by a compact1 profile instead of the full SE? (I would test this myself but having trouble compiling the compact profiles).

like image 698
Adam Gent Avatar asked Feb 11 '15 17:02

Adam Gent


1 Answers

Yes, compact profiles will reduce memory footprint.

During the JVM startup several things happen:

  • native libraries loaded into memory
  • rt.jar loaded into memory
  • referenced libraries loaded into memory only when they actually used

Different compact profiles include different set of technologies. Thus reducing number of loaded objects into memory. You could check what exactly loaded into memory using the command:

pmap <jvm pid>

On my raspberry pi with profile compact1 and default heap size I've got 12Mb.

like image 153
Andrey Rodionov Avatar answered Nov 14 '22 23:11

Andrey Rodionov