On 05/24/13 08:52, Diggory wrote: > After doing some further investigation I think I've found a fairly awesome > way of doing garbage collection on windows, hopefully linux has a similar > mechanism. It doesn't require memory mapped files or anything special, it can > be done retroactively, and it allows a kind of reverse copy on write which is > what's actually needed. > > When the GC is run: > - Use VirtualProtect to mark all mutable memory pages as read-only > - Add a vectored exception handler to handle the access violation exception > - Resume the GC thread > > In the exception handler: > - Copy the page being modified to a new page
A page fault per every page written to between every GC run + a user space callback for every such fault + a page sized copy every time is not going to perform very well... (There are ways to avoid these costs, but no idea if it's easily doable on windows...) artur