Since many different Language-Interpreters and other software uses Garbage-Collectors, and since Garbage Collectors usually produce Overhead, running more of them can make a System slower. For example, when running a Java VM, perl and SBCL for example, at the same time, on a small VPS, etc., any of these systems has its own garbage collector, reserving a lot more space than actually is needed to optimize runtime-speed, but taking this place from other processes. There are possibilities to leave non-used parts of virtually allocated space non-allocated (like for example setting /proc/sys/vm/overcommit_memory to 1), but these are dangerous, if a process really needs that much memory, and they change the behaviour of paging of the kernel, and hence as far as I know they can make a garbage collector even slower (maybe I am wrong, I dont know exactly).
So what I am wondering since a long time now is, whether it is possible to create a system-wide garbage-collector. I dont want to do this, and I am sure, if it was possible, someone else would have done it, but I just wonder, why it is not possible.
The naive way would be to specify some "protocol" how to access a huge shm, how to save structs, how to specify where the references to other objects are, and where boundings are, with one process running in the background rearranging all the memory. This would be very insecure since all processes could access all the other memory, but the kernel could block access to other parts of the memory. On the other hand, leave all of that work to the kernel, just define a syscall that tells the kernel "i need ... space to save all my objects" and then the kernel rearranges the space and translates addresses.
Ok, there are a lot of different types of garbage collection algorithms, but a "general" solution for all programs always has drawbacks. At least Systems like Java and Common Lisp wouldnt have to start their own garbage collector.
