GCJ vs. C++ in RAM
David Daney
ddaney@avtrex.com
Tue Apr 6 19:53:00 GMT 2004
Vladimir Levin wrote:
> For the time being I am thinking of statically linked executable. So
> what I am asking is, given that I have a moderately complex, 50,000
> line program which makes use of various libraries such as collections,
> threads, sockets, how much RAM will the program use if it is written
> in C++ vs. Java? Both the Java and C++ versions would be statically
> linked. I realize it may be difficult to formulate a very precise
> answer to this question without actually building the app in both
> cases, but if some experienced voices out there could give me an
> informed guess, I'd sure appreciate it. I am willing to strip the
> statically linked executable and I may also be able to gzexe it (not
> quite sure what the runtime performance penalty would be). I have a
> feeling that the garbage collection may be a significant factor, but I
> am not sure how big, so if I could get a sense of what the RAM usage
> in C++ would be with and without the Boehm garbage collector, that
> would be great.
I am running on a mips32, and have a java program that contains around
50,000 lines of code. When staticly linked and stripped, the executable
size is 3848796. This includes the application, java runtime, and libc.
Looking at the in memory size:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
REGINFO 0x0000e0 0x004000e0 0x004000e0 0x00018 0x00018 R 0x4
LOAD 0x000000 0x00400000 0x00400000 0x2b1750 0x2b1750 R E 0x1000
LOAD 0x2b2000 0x10000000 0x10000000 0xb1834 0xcae64 RW 0x1000
NOTE 0x0000c0 0x004000c0 0x004000c0 0x00020 0x00020 R 0x10
If you add them up you get 0x37c5b4 = 3655092.
That does not include any java heap. Our application uses about 10 - 12
MB of heap.
Hope that helps.
David Daney.
More information about the Java
mailing list