From: Simon Krahnke Date: 2007-08-14T09:05:03+09:00 Subject: Re: Why don't Ruby libraries share memory? * Matt Harvey (22:19) schrieb: > Sorry, I started talking about Rails again. The question is not about > Rails. The questions are: Is there any way we can have shared Ruby > libraries without turning the relevant code into a C extension? Is it > necessary that code be compiled to be put into shared memory by the > OS? C-libraries have 2 nice features: They are read only, and ready to use in a disk file. So a modern OS can just map that file into memory and use the same physical memory for every process accessing the file. Ruby classes aren't read only. But you could just write the changes into memory and keep the constant part in a file. So the real problem is that the source aren't ready to use for a modern interpreter. The data structures the compiler works on are nowhere on disk, they are dynamically created when the source files are evaluated. The source files don't hog up memory, they can be freed after being parsed or just memory mapped. It's the parsers result, the structures the interpreter works on, that need the memory. Ruby would have to use "precompiled" source files to be able to use memory mapping. It could use copy-on-write to dynamically change the code. There still much work on Ruby, so there may be a chance for that. mfg, simon .... l