4 ms·
I believe this is contrived to prove a point. And this isn't just a help in these contrived examples. I believe process cleanup (an extreme case of cleaning u
by epage 6y ago
I believe this is contrived to prove a point.
And this isn't just a help in these contrived examples. I believe process cleanup (an extreme case of cleaning up objects) is one of cases where garbage collection performs better because it doesn't have to unwind the stack, call cleanup functions that are not in the cache, and make a lot of `free` calls to the allocator.
I vaguely remember reading about Google killing processes rather than having them clean up correctly, relying on the OS to properly clean up any resources of significance.
Now this doesn't mean you should do this in all cases. Profile first, see if you can avoid the large objects, and then look into deferred de-allocations ... if the timing of resource cleanup meets your application's guarantees.
- Reelin 6y ago> killing processes rather than having them clean up correctly, relying on the OS I recall Firefox preventing cleanup code from running when you quit a few years ago. Prior to that, quitting with a lot of pages open (ie hundreds) could cause it to lock up for quite some time.
- seventh-chord 6y agoKilling a process without freeing all allocations is, as far as I can tell, routine in C. Especially for memory it makes no sense "freeing" allocations, the whole memory space is getting scrapped anyways. Of course, once you add RAAI the compiler cant reason about which destructors it can skip on program exit, and if programmers are negligent of this you get programs that are slow to close.
- gpderetta 6y agoexit(2) will only call destructors of static objects. Quick_exit not even those.
- estebank 6y ago> Killing a process without freeing all allocations is, as far as I can tell, routine in C. Many times by accident :) > if programmers are negligent of this you get programs that are slow to close. I wouldn't call that negligence, just not fully optimized.