-1

I made a java program and packaged it into a Folder(named Folder) and then maked a batch file which i use to call the jar file. Also into the added the Java8_25 JRE.

Folder has (batch file,Java8_25 JRE,program.jar). Here is how i call the program from batch file:

1.Way

start "C:/Program Files (x86)/Folder/Java8/lib/javaw.exe -jar" "C:/Program Files (x86)/Folder/program.jar"

enter image description here

2.Way

start Java8/lib/javaw.exe -jar program.jar

enter image description here

The difference is enough big.Also i see that calling program with the 1 way it is 64 bits and with the second way 32 bits although i opened it with the same Java8 JRE.

1)Why is the first way calling 64 bit and not 32?

2)Why so big difference in memory?

I have also read questions related to this and i think 64 bit java cosumes more memory than 32 bit? but why is this happening here.

(If it helps:Also i have 64 bit OS and when i enter eclipse prefer java 32 bits)

crAlexander
  • 376
  • 1
  • 2
  • 12

2 Answers2

4

The memory difference is entirely because of the difference in JVM, although probably because the 32-bit is the "client" mode. HotSpot always runs 64-bit in "server" mode, which is tuned for long-running and high-GC programs like Web servers.

You definitely aren't using the same JVM for both runs; the "x86" directory is where Windows puts 32-bit programs on a 64-bit OS.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
2

This starts the 64bit java:

start Java8/lib/javaw.exe -jar program.jar 

This starts the 32bit java:

start "C:/Program Files (x86)/Folder/Java8/lib/javaw.exe -jar" "C:/Program Files (x86)/Folder/program.jar"

This accounts for the difference in memory: all those small values that fit into 32 bits are being stored in 64 bits of memory, for performance reasons. Therefore the memory footprint is larger.

Paul Hicks
  • 13,289
  • 5
  • 51
  • 78
  • The memory difference probably isn't because of the native word size; 64-bit HotSpot uses compressed OOPs. The 64-bit JVM always runs in server mode, and the Windows 32-bit defaults to client. – chrylis -cautiouslyoptimistic- Feb 17 '15 at 20:39
  • Interesting. What does explain the size difference? Memory requirements for 64bit java apps are always higher, so there must be some consistent factors. Feel free to edit the answer to list some alternative reasons. I guess my over-simple explanation might be right some of the time (different sorts of optimizations) but more information is always more useful :) – Paul Hicks Feb 17 '15 at 20:43
  • 2
    The server tuning is more aggressive about expanding the heap so that the generational garbage collector will be more efficient earlier, since server programs tend to create lots of short-lived objects to serve requests. – chrylis -cautiouslyoptimistic- Feb 17 '15 at 20:44
  • thanks for answer but 32 bit is called as i have write and 64 the same i have checked that.. – crAlexander Feb 17 '15 at 20:46
  • @crAlex The screenshot you posted disagrees – chrylis -cautiouslyoptimistic- Feb 17 '15 at 20:51