Hacker News new | ask | show | jobs
by rndgermandude 2001 days ago
Languages with garbage collection and/or tons of reflection (requiring memory for bookkeeping) and/or JIT (requiring memory for on-the-fly jitted code) would indeed be a problem due to the overhead of those technologies.

Python is not as "bad" as dotnet and go I'd think, as most of python is reference counted garbage collection (with a "full" GC just to break up cycles) while go and dotnet use essentially mark-and-sweep GC strategies which require a lot of object moving and thus scratch space.

Running a dotnet hello-world (on x86_64 linux admittedly) gives an RSS of 26MB, most of it mapped libraries and .net assemblies, some libraries shared between processes of course, like libc/libm/ld.so. But it also maps a ton memory for the JIT and the GC (including scratch space to move objects into during gc). With some swap, it may survive on a system with 25MB of free memory, but I'd think there'd be plenty of swap-thrashing and gc thrashing going on, making that less fun.

Running a python3's hello world comes in at 10MB RSS, but a large part of that is the shared libraries like libc/libm/ld.so. With some memory-conserving programming some real python programs may run just fine without excess swapping.

For comparison, a hello world in C maps about 1M RSS, while a rust one maps 2MB RSS, both times a big chunk in shared libraries specially libc.

1 comments

> Languages with garbage collection

Nim uses GC by default and uses 512KB of RSS without any tuning.

(With ARC/ORC and without libc it can run on microcontrollers with 1KB of RAM)