GCJ vs. C++ in RAM
Wed Apr 7 10:26:00 GMT 2004
Vladimir Levin writes:
> For the time being I am thinking of statically linked executable.
Right. Well, Java is a dynamic language that sometimes has trouble
with static linkage: for example, some Java calls go via a string that
is the name of a method which is looked up at runtime. gcj can
mostly get around that, but some libraries such as crypto may need a
> 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.
Lat time I looked, all of libgcj was about 6 megabytes. libstdc++ is
smaller. However, you'll not link with all of libgcj.
Java has some additional overhead for reflection data, and it does a
bunch of runtime checking that C++ doesn't do. All this costs space.
> 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 don't think that any of us could do this without making an
experiment. But with all the reflection data and type checking, there
will be an increase in size.
More information about the Java