In the last post I've written about the file size. Of course disk
usage isn't the only measurement and so I wanted to add some
figures about RAM usage. The last article grow in length and it
turned out to be very complicated to provide those figures so that
I decided to give it an extra post.
I had written a simple JVM based web app. It has CRUD screens for four entities. One entity is the main one and has also a search dialog, while the other three are only supporting. I wanted to compare the memory consumption of it with Serve and Cserve.
The problem:
It turned out that it isn't easy to get the real memory usage figures. First the initial heap size of Java is either based on the RAM available or set explicitly via -Xms but it depends in no way on the needs of the application. To get the numbers of what the application really needs I would have to tune around with the JVM memory settings. Not a way I wanted to go.
That's because there is another pitfall in memory measure under Linux. I had to learn that ps calculates the memory as if it were the only process running. So the memory used by shared libraries is added to the memory used by the process. That may be correct for the libgo.so but not for the libc.so. You do memory measurement to estimate if the existing RAM is enough to run the application or how much extra RAM you need to get. Adding an already loaded library won't help here.
What I can provide:
For Java I've started jconsole to get memory information. There I saw that it uses 160MB of heap right after start without load. The heap isn't the only memory used by the JVM but as the application is much larger than Serve I didn't add this to the number. A kind of futile attempt to keep the numbers comparable.
The Serve program (compiled with gc, static) took only 2.5 MB of memory even though the binary is about 3.9MB large and it was under load. Sounds strange but as there are no shared libraries the result of ps should be accurate.
The Cserver program really caused me some headache. There are solutions to get the private memory of an application without the shared libraries but Cserver was responsible for loading libgo.so and thus libgo.so should be added to the memory consumption. I have to admit that I failed. I can only provide the number with all shared libraries. Under load it run up to 5.5MB of memory.
Conclusion:
Measuring memory turned out to be hell. I didn't expect this before.
The figures for Go seem very promising although they aren't comparable in any way to the JVM based web app.