Adek336 wrote:
Well, instead of names you could pass integers. An array would hold the proper info, and you wouldn't spend time on searching for the object by name.
Ofcourse you'd use integers. The best way would probably be a simple pointer to pointer.
Then again, if we used integers we might as well stick to pointers, which are more effective and useful. If something happened to the integer, a wrong object would be found. If a string would happen to be damaged, the program would know about it through an error message from the object manager.
Like, my idea would be that have pointers to entries in one large table.. and have table entries that aren't resident in memory point to a zero-page or something.
Now, if the object is resident, you have a pointer to pointer to object. You therefore take a small performance penalty from the extra indirection. However, some garbage-collected languages/systems do it this way anyway, since it allows one to move objects around, which is nice for reducing heap fragmentation. If the object is not resident, then you have pointer to pointer to NULL, and you get a trap to VMM when dereferencing it. VMM can page the object in, fix the pointer, and resume.
If you use direct pointers, you are limited to 4GB total address space. If you dereference through an intermediate pointer, you can put any object in memory anywhere, as long as you have less than 4GB of objects in total mapped.
And I am NOT agaist traditional GC's. I just had this idea about how to get around the address space size limit. You can still collect garbage any way you want. But if you use direct pointers, you have to fit all stuff into 4GB, which would means you pretty much need separate address spaces for separate processes.
And indeed, a good GC does NOT suspend anything when collecting. There needs to be some amount of synchronization, but locks can be kept to a few cycles now and then, so the performance penalty is next to none (although to fully optimize this you need VMM support for it).
As for causing small delays now and then, with uniprocessor your only option is timesharing, which means that obviously when the collector runs, your other threads do not. The point is that garbage collector can be just like any other regular thread: it can be pre-empted at any time.