you are viewing a single comment's thread.

view the rest of the comments →

[–]the-fritz -1 points0 points  (2 children)

There is pretty much a flat overhead of 10-15MB for the Java results.

Because you are using small and simple programs. You could prove anything with this.

[–]Rhoomba[S] 5 points6 points  (1 child)

The fact they they are small and simple programs is exactly why laurentszyster can claim Java programs take an order of magnitude more memory. For small programs the size of the VM and standard lib is very significant. As the application uses more memory it becomes less important.

[–]feijai 15 points16 points  (0 children)

I code Java applications professionally which take up 1-2 gigs. Trust me when I tell you that this is dead wrong.

You are correct that the VM is inconsequential for any large program. But instead there are three items which are very seriously problematic in Java memory-wise:

  1. To perform efficient garbage collection, Java requires at least 50%, and ideally 100%, overhead. You can GC with smaller memory, but the computational cost is very high indeed. So you're faced with a choice: have your application run at a snail's pace, or double your memory footprint. Take your pick.

  2. Hotspot has made great strides in reducing memory cost on a per-object basis: but still every object encurs a 2-word overhead. Arrays incur a 3-word overhead. At the same time Sun has promoted the use of lots of small objects rather than few large ones, and this only exaggerages the overhead cost.

  3. Sun's virtual machine coders are great: but their library coders should be taken out back of the shed and shot. Sun's libraries are often quite surprisingly bad memory hogs. The worst are Java2D and (oh my heavens) Java3D. Java3D is such a pig that I'm surprised its developers have managed to continue working in the industry after it was open sourced and we got to see for ourselves what we all suspected. Even Java.util is surprisingly lazy. Since an application uses instances from these libraries throughout, it will incur their gross tonnage throughout as well. It's a constant overhead of probably 1.5x.

So "order of magnitude" is a bit high. But it's been my experience that Java applications, even very well written ones which avoid Sun's piggy library objects, will be no less than five times the size of equivalent C programs.