This is going to be short.
Taking as starting point the last code challenge posted by @oaktree ( Programming Challenge #6 thanks @oaktree! ) and just out of curiosity, I decided to take some memory performance numbers. This challenge was pretty straight forward and it does not looks like any of the posted solution could be farther optimized. So, I checked the memory resources used by them.
These is what I have got in my system as provided by the
gnome-system-monitor and bringing up the
Properties window for the different versions of the program:
Language | Memory | Virt Memory | Res Memory | Wr Memory | Sh Memory ---------+---------+-------------+------------+-----------+----------- Java | 8.4 MiB | 5.5 GiB | 15.6 MiB | 8.4 MiB | 7.5 MiB Python | 2.5 MiB | 23.7 MiB | 4.8 MiB | 2.5 MiB | 2.3 MiB Perl | 744 KiB | 26.4 MiB | 2.6 MiB | 744 KiB | 1.9 MiB lua | 212 KiB | 13.8 MiB | 1.0 MiB | 212 KiB | 840 Kib C++ | 176.KiB | 12.4 MiB | 1.0 MiB | 176.0 KiB | 900.0 KiB C | 100 KiB | 4.2 MiB | 352.0 KiB | 100.0 KiB | 276.0 KiB C-diet | 20 KiB | 172.0 KiB | 4.0 KiB | 20.0 KiB | N/A
Some comments to better understand the table.
I modify the programs to wait for a key press before they end so I could capture the numbers in the table.
C-diet is the C version compiled with dietLibC and therefore it is a static binary and that is the reason it does not share memory.
Java version was compiled with OpenJDK
Columns in the table are:
- Virt Memory: Virtual memory.
- Res Memory: Resident Memory.
- Wr Memory: Writable Memory.
- Sh Memory: Shared Memory.
There are pretty good explanations in the Internet for these parameters in case you are curious about its exact meaning.
Scripting languages are great and, for many different problems, they are the right solution. But that power and flexibility comes with a price that is good to understand.