-3

I've written a simple program in two different languages, and the result has astonished me! My application is a simple program (Hello world!). The C-Sharp program took about 3 MB of RAM, but in Java-FX it was about 78 MB. Is Java really using that much memory?! Is there a way to reduce the amount of memory?

Cœur
  • 32,421
  • 21
  • 173
  • 232
programer
  • 13
  • 4
  • 4
    You can't draw any conclusions from that, and you're wasting your time if you're worrying about memory when you're still writing hello worlds. – Kayaman Dec 21 '17 at 17:47
  • 3
    All the difference means is jre is optimized differently at startup than .net. This from a C# guy that only does java on occasion. Unless you're writing a hello world program that needs to be highly optimized this is no reason to fret. – N-ate Dec 21 '17 at 17:51
  • see how much more memory it takes to print "Hello World" again on another line of your java code and if the memory doubles I'd start to worry... – RAZ_Muh_Taz Dec 21 '17 at 17:57

1 Answers1

1

Depending on the version of the java virtual machine, the default initial heap size is a reasonable minimum, varies by platform, and can be set at startup. So yes, you can reduce it.

About changing the size and more details: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc-ergonomics.html

About the default heap size: How is the default java heap size determined?

Johan Witters
  • 1,328
  • 7
  • 20